1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-26 10:04:02 +03:00

s3:smbd: implement SMB2 Logoff

metze
This commit is contained in:
Stefan Metzmacher 2009-05-15 11:40:19 +02:00
parent 53de3b136e
commit 1f59788516
3 changed files with 47 additions and 1 deletions

View File

@ -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 {

View File

@ -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);

View File

@ -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);
}