s3:client: smbclient -L can't do workgroup listing over SMB2/3
authorStefan Metzmacher <metze@samba.org>
Mon, 19 Jun 2017 06:49:05 +0000 (08:49 +0200)
committerStefan Metzmacher <metze@samba.org>
Thu, 22 Jun 2017 11:07:40 +0000 (13:07 +0200)
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/client/client.c

index 3285240d404640d731431c7a8495e2c843069b5b..375d9e3e4d91191eb3b0604fe03ca571d53bc3aa 100644 (file)
@@ -5646,16 +5646,21 @@ static int do_host_query(const char *query_host)
                goto out;
        }
 
-       if (port != NBT_SMB_PORT) {
+       if (port != NBT_SMB_PORT ||
+           smbXcli_conn_protocol(cli->conn) > PROTOCOL_NT1)
+       {
+               int max_proto = MIN(max_protocol, PROTOCOL_NT1);
 
-               /* Workgroups simply don't make sense over anything
-                  else but port 139... */
+               /*
+                * Workgroups simply don't make sense over anything
+                * else but port 139 and SMB1.
+                */
 
                cli_shutdown(cli);
                status = cli_cm_open(talloc_tos(), NULL,
                                     have_ip ? dest_ss_str : query_host,
                                     "IPC$", popt_get_cmdline_auth_info(),
-                                    true, smb_encrypt, max_protocol,
+                                    true, smb_encrypt, max_proto,
                                     NBT_SMB_PORT, name_type, &cli);
                if (!NT_STATUS_IS_OK(status)) {
                        cli = NULL;