s4:torture/smb2: let us have a common torture_smb2_con_share()
authorStefan Metzmacher <metze@samba.org>
Mon, 7 Aug 2023 09:03:41 +0000 (11:03 +0200)
committerAndreas Schneider <asn@cryptomilk.org>
Tue, 8 Aug 2023 12:57:29 +0000 (12:57 +0000)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15346

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
source4/torture/smb2/acls.c
source4/torture/smb2/util.c
source4/torture/vfs/acl_xattr.c

index 2f15ad27e48ba40a6ec2cfd7530e4d98dd39bc3f..7e3d8b5ee7d7d6a838f51f011d9bd380a0740f47 100644 (file)
@@ -2139,40 +2139,6 @@ done:
 }
 #endif
 
-/**
- * SMB2 connect with explicit share
- **/
-static bool torture_smb2_con_share(struct torture_context *tctx,
-                           const char *share,
-                           struct smb2_tree **tree)
-{
-        struct smbcli_options options;
-        NTSTATUS status;
-        const char *host = torture_setting_string(tctx, "host", NULL);
-
-        lpcfg_smbcli_options(tctx->lp_ctx, &options);
-
-        status = smb2_connect_ext(tctx,
-                                  host,
-                                  lpcfg_smb_ports(tctx->lp_ctx),
-                                  share,
-                                  lpcfg_resolve_context(tctx->lp_ctx),
-                                  samba_cmdline_get_creds(),
-                                  0,
-                                  tree,
-                                  tctx->ev,
-                                  &options,
-                                  lpcfg_socket_options(tctx->lp_ctx),
-                                  lpcfg_gensec_settings(tctx, tctx->lp_ctx)
-                                  );
-        if (!NT_STATUS_IS_OK(status)) {
-               torture_comment(tctx, "Failed to connect to SMB2 share \\\\%s\\%s - %s\n",
-                       host, share, nt_errstr(status));
-                return false;
-        }
-        return true;
-}
-
 static bool test_access_based(struct torture_context *tctx,
                                struct smb2_tree *tree)
 {
index 01b1b2f0793aa447781c3ed04e157fdfed06375b..ecf80d9105b14495fb2ab3cd948d86bbc8f57693 100644 (file)
@@ -459,22 +459,16 @@ bool torture_smb2_connection(struct torture_context *tctx, struct smb2_tree **tr
 /**
  * SMB2 connect with share from soption
  **/
-bool torture_smb2_con_sopt(struct torture_context *tctx,
-                          const char *soption,
-                          struct smb2_tree **tree)
+bool torture_smb2_con_share(struct torture_context *tctx,
+                           const char *share,
+                           struct smb2_tree **tree)
 {
        struct smbcli_options options;
        NTSTATUS status;
        const char *host = torture_setting_string(tctx, "host", NULL);
-       const char *share = torture_setting_string(tctx, soption, NULL);
 
        lpcfg_smbcli_options(tctx->lp_ctx, &options);
 
-       if (share == NULL) {
-               torture_comment(tctx, "No share for option %s\n", soption);
-               return false;
-       }
-
        status = smb2_connect(tctx,
                              host,
                              lpcfg_smb_ports(tctx->lp_ctx),
@@ -495,6 +489,23 @@ bool torture_smb2_con_sopt(struct torture_context *tctx,
        return true;
 }
 
+/**
+ * SMB2 connect with share from soption
+ **/
+bool torture_smb2_con_sopt(struct torture_context *tctx,
+                          const char *soption,
+                          struct smb2_tree **tree)
+{
+       const char *share = torture_setting_string(tctx, soption, NULL);
+
+       if (share == NULL) {
+               torture_comment(tctx, "No share for option %s\n", soption);
+               return false;
+       }
+
+       return torture_smb2_con_share(tctx, share, tree);
+}
+
 /*
   create and return a handle to a test file
   with a specific access mask
index 46d8ead6cb03db16ada8dabde34af76179cce3a2..1deb2b3b9984c04a204f601f536c060fa6b352bc 100644 (file)
        } \
 } while (0)
 
-/**
- * SMB2 connect with explicit share
- **/
-static bool torture_smb2_con_share(struct torture_context *tctx,
-                           const char *share,
-                           struct smb2_tree **tree)
-{
-        struct smbcli_options options;
-        NTSTATUS status;
-        const char *host = torture_setting_string(tctx, "host", NULL);
-
-        lpcfg_smbcli_options(tctx->lp_ctx, &options);
-
-        status = smb2_connect_ext(tctx,
-                                  host,
-                                  lpcfg_smb_ports(tctx->lp_ctx),
-                                  share,
-                                  lpcfg_resolve_context(tctx->lp_ctx),
-                                  samba_cmdline_get_creds(),
-                                  0,
-                                  tree,
-                                  tctx->ev,
-                                  &options,
-                                  lpcfg_socket_options(tctx->lp_ctx),
-                                  lpcfg_gensec_settings(tctx, tctx->lp_ctx)
-                                  );
-        if (!NT_STATUS_IS_OK(status)) {
-                printf("Failed to connect to SMB2 share \\\\%s\\%s - %s\n",
-                       host, share, nt_errstr(status));
-                return false;
-        }
-        return true;
-}
-
 static bool test_default_acl_posix(struct torture_context *tctx,
                                   struct smb2_tree *tree_unused)
 {