summaryrefslogtreecommitdiff
path: root/source3/smbd
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2009-05-15 11:40:19 +0200
committerStefan Metzmacher <metze@samba.org>2009-05-22 10:28:37 +0200
commit1f5978851627eff9190f42f82acedaf03e5c61e5 (patch)
treef43549541b01908dc7ff2ffda16e122b0141ef74 /source3/smbd
parent53de3b136edbb0b8e7c3a0293dce657cf732f1d2 (diff)
downloadsamba-1f5978851627eff9190f42f82acedaf03e5c61e5.tar.gz
samba-1f5978851627eff9190f42f82acedaf03e5c61e5.tar.bz2
samba-1f5978851627eff9190f42f82acedaf03e5c61e5.zip
s3:smbd: implement SMB2 Logoff
metze
Diffstat (limited to 'source3/smbd')
-rw-r--r--source3/smbd/globals.h1
-rw-r--r--source3/smbd/smb2_server.c2
-rw-r--r--source3/smbd/smb2_sesssetup.c45
3 files changed, 47 insertions, 1 deletions
diff --git a/source3/smbd/globals.h b/source3/smbd/globals.h
index 345f748802..c03da19981 100644
--- a/source3/smbd/globals.h
+++ b/source3/smbd/globals.h
@@ -225,6 +225,7 @@ NTSTATUS smbd_smb2_request_check_session(struct smbd_smb2_request *req);
NTSTATUS smbd_smb2_request_process_negprot(struct smbd_smb2_request *req);
NTSTATUS smbd_smb2_request_process_sesssetup(struct smbd_smb2_request *req);
+NTSTATUS smbd_smb2_request_process_logoff(struct smbd_smb2_request *req);
NTSTATUS smbd_smb2_request_process_keepalive(struct smbd_smb2_request *req);
struct smbd_smb2_request {
diff --git a/source3/smbd/smb2_server.c b/source3/smbd/smb2_server.c
index a16a3d6c3d..83ce7c4358 100644
--- a/source3/smbd/smb2_server.c
+++ b/source3/smbd/smb2_server.c
@@ -308,7 +308,7 @@ static NTSTATUS smbd_smb2_request_dispatch(struct smbd_smb2_request *req)
if (!NT_STATUS_IS_OK(status)) {
return smbd_smb2_request_error(req, status);
}
- return smbd_smb2_request_error(req, NT_STATUS_NOT_IMPLEMENTED);
+ return smbd_smb2_request_process_logoff(req);
case SMB2_OP_TCON:
status = smbd_smb2_request_check_session(req);
diff --git a/source3/smbd/smb2_sesssetup.c b/source3/smbd/smb2_sesssetup.c
index d322223ad5..50476bfbe5 100644
--- a/source3/smbd/smb2_sesssetup.c
+++ b/source3/smbd/smb2_sesssetup.c
@@ -118,6 +118,10 @@ static int smbd_smb2_session_destructor(struct smbd_smb2_session *session)
idr_remove(session->conn->smb2.sessions.idtree, session->vuid);
DLIST_REMOVE(session->conn->smb2.sessions.list, session);
+ session->vuid = 0;
+ session->status = NT_STATUS_USER_SESSION_DELETED;
+ session->conn = NULL;
+
return 0;
}
@@ -219,3 +223,44 @@ NTSTATUS smbd_smb2_request_check_session(struct smbd_smb2_request *req)
req->session = session;
return NT_STATUS_OK;
}
+
+NTSTATUS smbd_smb2_request_process_logoff(struct smbd_smb2_request *req)
+{
+ const uint8_t *inbody;
+ int i = req->current_idx;
+ DATA_BLOB outbody;
+ size_t expected_body_size = 0x04;
+ size_t body_size;
+
+ if (req->in.vector[i+1].iov_len != (expected_body_size & 0xFFFFFFFE)) {
+ return smbd_smb2_request_error(req, NT_STATUS_INVALID_PARAMETER);
+ }
+
+ inbody = (const uint8_t *)req->in.vector[i+1].iov_base;
+
+ body_size = SVAL(inbody, 0x00);
+ if (body_size != expected_body_size) {
+ return smbd_smb2_request_error(req, NT_STATUS_INVALID_PARAMETER);
+ }
+
+ /*
+ * TODO: cancel all outstanding requests on the session
+ * and delete all tree connections.
+ */
+ smbd_smb2_session_destructor(req->session);
+ /*
+ * we may need to sign the response, so we need to keep
+ * the session until the response is sent to the wire.
+ */
+ talloc_steal(req, req->session);
+
+ outbody = data_blob_talloc(req->out.vector, NULL, 0x04);
+ if (outbody.data == NULL) {
+ return smbd_smb2_request_error(req, NT_STATUS_NO_MEMORY);
+ }
+
+ SSVAL(outbody.data, 0x00, 0x04); /* struct size */
+ SSVAL(outbody.data, 0x02, 0); /* reserved */
+
+ return smbd_smb2_request_done(req, outbody, NULL);
+}