From c31840ee73981a5f81cdef225c2b97758f5b86de Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 26 Nov 2014 13:15:24 -0800 Subject: [PATCH] libcli: SMB2: Pure SMB2-only negprot fix to make us behave as a Windows client does. 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 --- libcli/smb/smbXcli_base.c | 11 +++++++++++ source3/include/local.h | 2 ++ 2 files changed, 13 insertions(+) diff --git a/libcli/smb/smbXcli_base.c b/libcli/smb/smbXcli_base.c index 8a8bbd0..e0c5ff9 100644 --- a/libcli/smb/smbXcli_base.c +++ b/libcli/smb/smbXcli_base.c @@ -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; @@ -3830,6 +3831,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); diff --git a/source3/include/local.h b/source3/include/local.h index 85f0861..5f52d9c 100644 --- a/source3/include/local.h +++ b/source3/include/local.h @@ -207,4 +207,6 @@ #define CLIENT_NDR_PADDING_SIZE 8 #define SERVER_NDR_PADDING_SIZE 8 +#define WINDOWS_CLIENT_PURE_SMB2_NEGPROT_INITIAL_CREDIT_ASK 31 + #endif -- 2.2.0.rc0.207.ga3a616c