Detect when command line max protocol < min protocol
authorDavid Mulder <dmulder@suse.com>
Fri, 8 Nov 2019 17:10:47 +0000 (17:10 +0000)
committerNoel Power <npower@samba.org>
Tue, 12 Nov 2019 17:52:28 +0000 (17:52 +0000)
Due to the increased default minimum protocol
level to SMB2, some users notice that
specifying smbclient -m NT1 fails with
NT_STATUS_CONNECTION_DISCONNECTED, with no SMB
traffic on the wire. Report when the max protocol
is set less than the min protocol.

Signed-off-by: David Mulder <dmulder@suse.com>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
Autobuild-User(master): Noel Power <npower@samba.org>
Autobuild-Date(master): Tue Nov 12 17:52:28 UTC 2019 on sn-devel-184

lib/param/loadparm.c
lib/param/param_table.c
source3/param/loadparm.c

index 9a577aa188c52cfeb359fd0c285b2bd0c066b4a0..5334e9c4e5d0f3c2a6c2949d1b9310e86d940b0a 100644 (file)
@@ -3117,6 +3117,7 @@ const char *lp_default_path(void)
 static bool lpcfg_update(struct loadparm_context *lp_ctx)
 {
        struct debug_settings settings;
+       int max_protocol, min_protocol;
        TALLOC_CTX *tmp_ctx;
 
        tmp_ctx = talloc_new(lp_ctx);
@@ -3160,6 +3161,19 @@ static bool lpcfg_update(struct loadparm_context *lp_ctx)
                unsetenv("SOCKET_TESTNONBLOCK");
        }
 
+       /* Check if command line max protocol < min protocol, if so
+        * report a warning to the user.
+        */
+       max_protocol = lpcfg_client_max_protocol(lp_ctx);
+       min_protocol = lpcfg_client_min_protocol(lp_ctx);
+       if (lpcfg_client_max_protocol(lp_ctx) < lpcfg_client_min_protocol(lp_ctx)) {
+               const char *max_protocolp, *min_protocolp;
+               max_protocolp = lpcfg_get_smb_protocol(max_protocol);
+               min_protocolp = lpcfg_get_smb_protocol(min_protocol);
+               DBG_ERR("Max protocol %s is less than min protocol %s.\n",
+                       max_protocolp, min_protocolp);
+       }
+
        TALLOC_FREE(tmp_ctx);
        return true;
 }
index 2fd3361f99615b062d0d6945eec166dd43df2c77..47b85de1f876528f36a67684d320bad099e12bf9 100644 (file)
@@ -61,6 +61,17 @@ static const struct enum_list enum_protocol[] = {
        {-1, NULL}
 };
 
+const char* lpcfg_get_smb_protocol(int type)
+{
+       int i;
+       for (i = 1; enum_protocol[i].value != -1; i++) {
+               if (enum_protocol[i].value == type) {
+                       return enum_protocol[i].name;
+               }
+       }
+       return NULL;
+}
+
 static const struct enum_list enum_security[] = {
        {SEC_AUTO, "AUTO"},
        {SEC_USER, "USER"},
index b1a52055ade7d85ace4c384e6d8dd2990a9482bc..433762eedfb650c11ad1702ff027b2d7945f5131 100644 (file)
@@ -3861,6 +3861,7 @@ static bool lp_load_ex(const char *pszFname,
        bool bRetval;
        TALLOC_CTX *frame = talloc_stackframe();
        struct loadparm_context *lp_ctx;
+       int max_protocol, min_protocol;
 
        DEBUG(3, ("lp_load_ex: refreshing parameters\n"));
 
@@ -3999,6 +4000,19 @@ static bool lp_load_ex(const char *pszFname,
 
        bAllowIncludeRegistry = true;
 
+       /* Check if command line max protocol < min protocol, if so
+        * report a warning to the user.
+        */
+       max_protocol = lp_client_max_protocol();
+       min_protocol = lp_client_min_protocol();
+       if (max_protocol < min_protocol) {
+               const char *max_protocolp, *min_protocolp;
+               max_protocolp = lpcfg_get_smb_protocol(max_protocol);
+               min_protocolp = lpcfg_get_smb_protocol(min_protocol);
+               DBG_ERR("Max protocol %s is less than min protocol %s.\n",
+                       max_protocolp, min_protocolp);
+       }
+
        TALLOC_FREE(frame);
        return (bRetval);
 }