s3:libsmbclient: Do not call cli_RNetShareEnum if SMB1 is disabled
authorAndreas Schneider <asn@samba.org>
Tue, 4 Sep 2018 14:08:58 +0000 (16:08 +0200)
committerJeremy Allison <jra@samba.org>
Wed, 5 Sep 2018 16:22:24 +0000 (18:22 +0200)
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/libsmb/libsmb_dir.c

index ff19ed57f14ac222dff9ca783f71139ed5f6ff62..886aa6265094e039db0d371b7a36dbce57b2eb81 100644 (file)
@@ -825,6 +825,7 @@ SMBC_opendir_ctx(SMBCCTX *context,
                                }
                        } else if (srv ||
                                    (resolve_name(server, &rem_ss, 0x20, false))) {
+                               int rc;
 
                                 /*
                                  * If we hadn't found the server, get one now
@@ -851,24 +852,24 @@ SMBC_opendir_ctx(SMBCCTX *context,
 
                                 /* List the shares ... */
 
-                                if (net_share_enum_rpc(
-                                            srv->cli,
-                                            list_fn,
-                                            (void *) dir) < 0 &&
-                                    cli_RNetShareEnum(
-                                            srv->cli,
-                                            list_fn,
-                                            (void *)dir) < 0) {
-
-                                        errno = cli_errno(srv->cli);
-                                        if (dir) {
-                                                SAFE_FREE(dir->fname);
-                                                SAFE_FREE(dir);
-                                        }
+                               rc = net_share_enum_rpc(srv->cli,
+                                                       list_fn,
+                                                       (void *)dir);
+                               if (rc != 0 &&
+                                   lp_client_min_protocol() <= PROTOCOL_NT1) {
+                                       rc = cli_RNetShareEnum(srv->cli,
+                                                              list_fn,
+                                                              (void *)dir);
+                               }
+                               if (rc != 0) {
+                                       errno = cli_errno(srv->cli);
+                                       if (dir != NULL) {
+                                               SAFE_FREE(dir->fname);
+                                               SAFE_FREE(dir);
+                                       }
                                        TALLOC_FREE(frame);
-                                        return NULL;
-
-                                }
+                                       return NULL;
+                               }
                         } else {
                                 /* Neither the workgroup nor server exists */
                                 errno = ECONNREFUSED;