libcli: SMB2: Pure SMB2-only negprot fix to make us behave as a Windows client does.
authorJeremy Allison <jra@samba.org>
Wed, 26 Nov 2014 01:43:25 +0000 (17:43 -0800)
committerJeremy Allison <jra@samba.org>
Wed, 26 Nov 2014 18:05:37 +0000 (19:05 +0100)
Required as some servers return zero when asked for
zero credits in an initial SMB2-only negprot.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Böhme <rb@sernet.de>
libcli/smb/smb2_negotiate_context.h
libcli/smb/smbXcli_base.c

index d98104a1a76d40dac4c8004e6f66dce0bb65a184..55aa032665ea54e74dff6a8abe68fce113e0d799 100644 (file)
@@ -50,5 +50,6 @@ NTSTATUS smb2_negotiate_context_add(TALLOC_CTX *mem_ctx, struct smb2_negotiate_c
  */
 struct smb2_negotiate_context *smb2_negotiate_context_find(const struct smb2_negotiate_contexts *b,
                                                           uint16_t type);
+#define WINDOWS_CLIENT_PURE_SMB2_NEGPROT_INITIAL_CREDIT_ASK    31
 
 #endif /* _LIBCLI_SMB_SMB2_NEGOTIATE_BLOB_H_ */
index 61ac6f04f127dd6d67e409abf5236d6b8b79f673..a3a7ecb801cf4dfb3339e3f47395d3dd2a7962da 100644 (file)
@@ -3864,6 +3864,16 @@ struct tevent_req *smbXcli_negprot_send(TALLOC_CTX *mem_ctx,
                 */
                conn->dispatch_incoming = smb2cli_conn_dispatch_incoming;
 
+               /*
+                * As we're starting with an SMB2 negprot, emulate Windows
+                * and ask for 31 credits in the initial SMB2 negprot.
+                * If we don't and leave requested credits at
+                * zero, MacOSX servers return zero credits on
+                * the negprot reply and we fail to connect.
+                */
+               smb2cli_conn_set_max_credits(conn,
+                       WINDOWS_CLIENT_PURE_SMB2_NEGPROT_INITIAL_CREDIT_ASK);
+
                subreq = smbXcli_negprot_smb2_subreq(state);
                if (tevent_req_nomem(subreq, req)) {
                        return tevent_req_post(req, ev);