From: Michael Adam Date: Tue, 26 Jan 2016 09:12:46 +0000 (+0100) Subject: smbd:smb2_negprot: implement connection passing based on client_guid X-Git-Tag: samba-4.4.0rc1~20 X-Git-Url: http://git.samba.org/samba.git/?p=kai%2Fsamba-autobuild%2F.git;a=commitdiff_plain;h=7a890a785547361e609c135bf65bf364f2eaf23f smbd:smb2_negprot: implement connection passing based on client_guid Pair-Programmed-With: Stefan Metzmacher Signed-off-by: Michael Adam Signed-off-by: Stefan Metzmacher --- diff --git a/source3/smbd/smb2_negprot.c b/source3/smbd/smb2_negprot.c index 158207225a0..0bb13bcd636 100644 --- a/source3/smbd/smb2_negprot.c +++ b/source3/smbd/smb2_negprot.c @@ -587,6 +587,8 @@ NTSTATUS smbd_smb2_request_process_negprot(struct smbd_smb2_request *req) req->sconn->using_smb2 = true; if (dialect != SMB2_DIALECT_REVISION_2FF) { + struct smbXsrv_client_global0 *global0 = NULL; + status = smbXsrv_connection_init_tables(xconn, protocol); if (!NT_STATUS_IS_OK(status)) { return smbd_smb2_request_error(req, status); @@ -613,6 +615,62 @@ NTSTATUS smbd_smb2_request_process_negprot(struct smbd_smb2_request *req) xconn->smb2.server.max_trans = max_trans; xconn->smb2.server.max_read = max_read; xconn->smb2.server.max_write = max_write; + + if (xconn->protocol < PROTOCOL_SMB2_10) { + /* + * SMB2_02 doesn't support client guids + */ + return smbd_smb2_request_done(req, outbody, &outdyn); + } + + if (!xconn->client->server_multi_channel_enabled) { + /* + * Only deal with the client guid database + * if multi-channel is enabled. + */ + return smbd_smb2_request_done(req, outbody, &outdyn); + } + + if (xconn->smb2.client.guid_verified) { + /* + * The connection was passed from another + * smbd process. + */ + return smbd_smb2_request_done(req, outbody, &outdyn); + } + + status = smb2srv_client_lookup_global(xconn->client, + xconn->smb2.client.guid, + req, &global0); + /* + * TODO: check for races... + */ + if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECTID_NOT_FOUND)) { + /* + * This stores the new client information in + * smbXsrv_client_global.tdb + */ + xconn->client->global->client_guid = + xconn->smb2.client.guid; + status = smbXsrv_client_update(xconn->client); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + xconn->smb2.client.guid_verified = true; + } else if (NT_STATUS_IS_OK(status)) { + status = smb2srv_client_connection_pass(req, + global0); + if (!NT_STATUS_IS_OK(status)) { + return smbd_smb2_request_error(req, status); + } + + smbd_server_connection_terminate(xconn, + "passed connection"); + return NT_STATUS_OBJECTID_EXISTS; + } else { + return smbd_smb2_request_error(req, status); + } } return smbd_smb2_request_done(req, outbody, &outdyn);