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 21:33:57 +0000 (13:33 -0800)
committerKarolin Seeger <kseeger@samba.org>
Thu, 4 Dec 2014 20:55:15 +0000 (21:55 +0100)
Required as some servers return zero when asked for
zero credits in an initial SMB2-only negprot.

Back-port of c426f97238e4f664d1b13781101ca9c942aa7d0d
from master.

https://bugzilla.samba.org/show_bug.cgi?id=10966

Signed-off-by: Jeremy Allison <jra@samba.org>
Autobuild-User(v4-1-test): Karolin Seeger <kseeger@samba.org>
Autobuild-Date(v4-1-test): Thu Dec  4 21:55:16 CET 2014 on sn-devel-104

libcli/smb/smbXcli_base.c
source3/include/local.h

index 25fbabd00d03f0b4f57b2ee1fdbba6760475b5a1..0ceb1ddef88f1eedb33f7609c994c9ca336c9f78 100644 (file)
@@ -31,6 +31,7 @@
 #include "../libcli/smb/read_smb.h"
 #include "smbXcli_base.h"
 #include "librpc/ndr/libndr.h"
+#include "local.h"
 
 struct smbXcli_conn;
 struct smbXcli_req;
@@ -3791,6 +3792,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);
index a87ab8f100d7ae7cf40289c9033b44a718fd7367..5ea7960ad33a91adfd3515c6549a2222fcf31a41 100644 (file)
 #define DEFAULT_SMB2_MAX_TRANSACT (1024*1024)
 #define DEFAULT_SMB2_MAX_CREDITS 8192
 
+#define WINDOWS_CLIENT_PURE_SMB2_NEGPROT_INITIAL_CREDIT_ASK    31
+
 #endif