]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s4/torture: add torture_smb2_connection_share_ext()
authorRalph Boehme <slow@samba.org>
Sat, 29 Nov 2025 15:02:26 +0000 (16:02 +0100)
committerRalph Boehme <slow@samba.org>
Fri, 17 Jul 2026 10:18:37 +0000 (10:18 +0000)
Takes an additional share paramter compared to torture_smb2_connection_ext().

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
source4/torture/smb2/util.c

index 704eeb883317e75fadf0172e7695d8967d7d73da..b197d19a03317e0e5b2c7f8ca6af9f323eb0be03 100644 (file)
@@ -446,6 +446,41 @@ bool torture_smb2_connection_ext(struct torture_context *tctx,
        return true;
 }
 
+/*
+  open a smb2 connection
+*/
+bool torture_smb2_connection_share_ext(struct torture_context *tctx,
+                                      const char *share,
+                                      uint64_t previous_session_id,
+                                      const struct smbcli_options *options,
+                                      struct smb2_tree **tree)
+{
+       NTSTATUS status;
+       const char *host = torture_setting_string(tctx, "host", NULL);
+
+       status = smb2_connect_ext(tctx,
+                                 host,
+                                 share,
+                                 tctx->lp_ctx,
+                                 lpcfg_resolve_context(tctx->lp_ctx),
+                                 samba_cmdline_get_creds(),
+                                 NULL, /* existing_conn */
+                                 previous_session_id,
+                                 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;
+}
+
 bool torture_smb2_connection(struct torture_context *tctx, struct smb2_tree **tree)
 {
        bool ret;