From: Stefan Metzmacher Date: Thu, 25 Jul 2019 12:38:26 +0000 (+0200) Subject: libcli/smb: send SMB2_NETNAME_NEGOTIATE_CONTEXT_ID X-Git-Tag: tdb-1.4.2~381 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=21f6cece543dd791e0f4636458bfe9819823420c;p=thirdparty%2Fsamba.git 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 --- diff --git a/libcli/smb/smbXcli_base.c b/libcli/smb/smbXcli_base.c index 98c928795ec..0375101b034 100644 --- a/libcli/smb/smbXcli_base.c +++ b/libcli/smb/smbXcli_base.c @@ -4771,6 +4771,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]; @@ -4803,6 +4805,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; + } + + status = smb2_negotiate_context_add(state, &c, + SMB2_NETNAME_NEGOTIATE_CONTEXT_ID, + netname_utf16, netname_utf16_len); + if (!NT_STATUS_IS_OK(status)) { + return NULL; + } + status = smb2_negotiate_context_push(state, &b, c); if (!NT_STATUS_IS_OK(status)) { return NULL;