From 2095ae524021d355e58ec190f3ef2a42f4e2a359 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 25 Jul 2019 14:37:31 +0200 Subject: [PATCH 1/2] libcli/smb: add new COMPRESSION and NETNAME negotiate context ids BUG: https://bugzilla.samba.org/show_bug.cgi?id=14055 Signed-off-by: Stefan Metzmacher Reviewed-by: Aurelien Aptel (cherry picked from commit e10b90f33bb812600886656a1124e2d434416563) --- libcli/smb/smb2_constants.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libcli/smb/smb2_constants.h b/libcli/smb/smb2_constants.h index f6edf6ba109d..e50e437d0584 100644 --- a/libcli/smb/smb2_constants.h +++ b/libcli/smb/smb2_constants.h @@ -131,6 +131,8 @@ /* Types of SMB2 Negotiate Contexts - only in dialect >= 0x310 */ #define SMB2_PREAUTH_INTEGRITY_CAPABILITIES 0x0001 #define SMB2_ENCRYPTION_CAPABILITIES 0x0002 +#define SMB2_COMPRESSION_CAPABILITIES 0x0003 +#define SMB2_NETNAME_NEGOTIATE_CONTEXT_ID 0x0005 /* Values for the SMB2_PREAUTH_INTEGRITY_CAPABILITIES Context (>= 0x310) */ #define SMB2_PREAUTH_INTEGRITY_SHA512 0x0001 -- 2.17.1 From 151d85e211adbc120c7ec9317abd0da721a94f9a Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 25 Jul 2019 14:38:26 +0200 Subject: [PATCH 2/2] libcli/smb: send SMB2_NETNAME_NEGOTIATE_CONTEXT_ID Note: Unlike the current documentation, the utf16 string is not null-terminated, that matches Windows Server 1903 as a client. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14055 RN: Add the target server name of SMB 3.1.1 connections as a hint to load balancers or servers with "multi-tenancy" support. Signed-off-by: Stefan Metzmacher Reviewed-by: Aurelien Aptel (similar to commit 21f6cece543dd791e0f4636458bfe9819823420c) --- libcli/smb/smbXcli_base.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/libcli/smb/smbXcli_base.c b/libcli/smb/smbXcli_base.c index a8c73be445a1..4bbe61670533 100644 --- a/libcli/smb/smbXcli_base.c +++ b/libcli/smb/smbXcli_base.c @@ -4756,6 +4756,8 @@ static struct tevent_req *smbXcli_negprot_smb2_subreq(struct smbXcli_negprot_sta if (state->conn->max_protocol >= PROTOCOL_SMB3_10) { NTSTATUS status; struct smb2_negotiate_contexts c = { .num_contexts = 0, }; + uint8_t *netname_utf16 = NULL; + size_t netname_utf16_len = 0; uint32_t offset; DATA_BLOB b; uint8_t p[38]; @@ -4790,6 +4792,21 @@ static struct tevent_req *smbXcli_negprot_smb2_subreq(struct smbXcli_negprot_sta return NULL; } + ok = convert_string_talloc(state, CH_UNIX, CH_UTF16, + state->conn->remote_name, + strlen(state->conn->remote_name), + &netname_utf16, &netname_utf16_len); + if (!ok) { + return NULL; + } + + b = data_blob_const(netname_utf16, netname_utf16_len); + status = smb2_negotiate_context_add(state, &c, + SMB2_NETNAME_NEGOTIATE_CONTEXT_ID, b); + if (!NT_STATUS_IS_OK(status)) { + return NULL; + } + status = smb2_negotiate_context_push(state, &b, c); if (!NT_STATUS_IS_OK(status)) { return NULL; -- 2.17.1