summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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);
+}