]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
libcli/smb: send SMB2_NETNAME_NEGOTIATE_CONTEXT_ID
authorStefan Metzmacher <metze@samba.org>
Thu, 25 Jul 2019 12:38:26 +0000 (14:38 +0200)
committerKarolin Seeger <kseeger@samba.org>
Wed, 11 Sep 2019 13:27:24 +0000 (13:27 +0000)
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 <metze@samba.org>
Reviewed-by: Aurelien Aptel <aaptel@suse.com>
(similar to commit 21f6cece543dd791e0f4636458bfe9819823420c)

Autobuild-User(v4-9-test): Karolin Seeger <kseeger@samba.org>
Autobuild-Date(v4-9-test): Wed Sep 11 13:27:24 UTC 2019 on sn-devel-144

libcli/smb/smbXcli_base.c

index a8c73be445a18aa496ce69d346dbe7a887d98e57..4bbe616705337f96c3c0ef38507e36d3e6242704 100644 (file)
@@ -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;