s3: tests: Add "SMB2-LIST-DIR-ASYNC" test.
authorJeremy Allison <jra@samba.org>
Wed, 14 Jul 2021 22:29:01 +0000 (15:29 -0700)
committerRalph Boehme <slow@samba.org>
Thu, 15 Jul 2021 05:02:30 +0000 (05:02 +0000)
Add as knownfail.

Shows our "smbd async dosmode" code wasn't working.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14758

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
selftest/knownfail.d/smb2_list_dir_async [new file with mode: 0644]
source3/selftest/tests.py
source3/torture/proto.h
source3/torture/test_smb2.c
source3/torture/torture.c

diff --git a/selftest/knownfail.d/smb2_list_dir_async b/selftest/knownfail.d/smb2_list_dir_async
new file mode 100644 (file)
index 0000000..bc38582
--- /dev/null
@@ -0,0 +1 @@
+^samba3.smbtorture_s3.plain.SMB2-LIST-DIR-ASYNC.smbtorture\(simpleserver\)
index 876cd41e4868f4cf4f89e0c1b2cf50c899315dd1..cf7459072193345a8d7df079c39450f2066e807a 100755 (executable)
@@ -242,6 +242,22 @@ plantestsuite("samba3.smbtorture_s3.plain.%s" % "SMB2-STREAM-ACL",
                 "",
                 "-l $LOCAL_PATH"])
 
+#
+# SMB2-LIST-DIR-ASYNC needs to run against a special share vfs_aio_pthread_async_dosmode_default1
+#
+plantestsuite("samba3.smbtorture_s3.plain.%s" % "SMB2-LIST-DIR-ASYNC",
+                "simpleserver",
+                [os.path.join(samba3srcdir,
+                              "script/tests/test_smbtorture_s3.sh"),
+                'SMB2-LIST-DIR-ASYNC',
+                '//$SERVER_IP/vfs_aio_pthread_async_dosmode_default1',
+                '$USERNAME',
+                '$PASSWORD',
+                smbtorture3,
+                "",
+                "-l $LOCAL_PATH"])
+
+
 shares = [
     "vfs_aio_pthread_async_dosmode_default1",
     "vfs_aio_pthread_async_dosmode_default2",
index 90363577ad9344263461b0ade58c0f032ed70ed2..4db267c92b0723ac7fced22df924fe19f2847229 100644 (file)
@@ -119,6 +119,7 @@ bool run_smb2_path_slash(int dummy);
 bool run_smb2_sacl(int dummy);
 bool run_smb2_quota1(int dummy);
 bool run_smb2_stream_acl(int dummy);
+bool run_list_dir_async_test(int dummy);
 bool run_chain3(int dummy);
 bool run_local_conv_auth_info(int dummy);
 bool run_local_sprintf_append(int dummy);
index c7fcb3994ba592faa0af077dd46cbbd750365fc1..b186ea4edac87cd6db9b947f11d751823414e518 100644 (file)
@@ -3144,3 +3144,87 @@ bool run_smb2_stream_acl(int dummy)
        (void)cli_unlink(cli, fname, 0);
        return ret;
 }
+
+static NTSTATUS list_fn(struct file_info *finfo,
+                       const char *name,
+                       void *state)
+{
+       bool *matched = (bool *)state;
+       if (finfo->attr & FILE_ATTRIBUTE_DIRECTORY) {
+               *matched = true;
+       }
+       return NT_STATUS_OK;
+}
+
+/*
+ * Must be run against a share with "smbd async dosmode = yes".
+ * Checks we can return DOS attriutes other than "N".
+ * BUG: https://bugzilla.samba.org/show_bug.cgi?id=14758
+ */
+
+bool run_list_dir_async_test(int dummy)
+{
+       struct cli_state *cli = NULL;
+       NTSTATUS status;
+       const char *dname = "ASYNC_DIR";
+       bool ret = false;
+       bool matched = false;
+
+       printf("SMB2 list dir async\n");
+
+       if (!torture_init_connection(&cli)) {
+               return false;
+       }
+
+       status = smbXcli_negprot(cli->conn,
+                               cli->timeout,
+                               PROTOCOL_SMB2_02,
+                               PROTOCOL_SMB3_11);
+       if (!NT_STATUS_IS_OK(status)) {
+               printf("smbXcli_negprot returned %s\n", nt_errstr(status));
+               return false;
+       }
+
+       status = cli_session_setup_creds(cli, torture_creds);
+       if (!NT_STATUS_IS_OK(status)) {
+               printf("cli_session_setup returned %s\n", nt_errstr(status));
+               return false;
+       }
+
+       status = cli_tree_connect(cli, share, "?????", NULL);
+       if (!NT_STATUS_IS_OK(status)) {
+               printf("cli_tree_connect returned %s\n", nt_errstr(status));
+               return false;
+       }
+
+       /* Ensure directory doesn't exist. */
+       (void)cli_rmdir(cli, dname);
+
+       status = cli_mkdir(cli, dname);
+       if (!NT_STATUS_IS_OK(status)) {
+               printf("cli_mkdir %s returned %s\n", dname, nt_errstr(status));
+               return false;
+       }
+
+       status = cli_list(cli,
+                         dname,
+                         FILE_ATTRIBUTE_NORMAL|FILE_ATTRIBUTE_DIRECTORY,
+                         list_fn,
+                         &matched);
+       if (!NT_STATUS_IS_OK(status)) {
+               printf("cli_list %s returned %s\n", dname, nt_errstr(status));
+               goto fail;
+       }
+
+       if (!matched) {
+               printf("Failed to find %s\n", dname);
+               goto fail;
+       }
+
+       ret = true;
+
+  fail:
+
+       (void)cli_rmdir(cli, dname);
+       return ret;
+}
index 5deffab6dc21e7af312da5b5e202df32125a3755..79a9c65073c902b72b35a77b527a9940b32e15cb 100644 (file)
@@ -15245,6 +15245,10 @@ static struct {
                .name  = "SMB2-STREAM-ACL",
                .fn    = run_smb2_stream_acl,
        },
+       {
+               .name  = "SMB2-LIST-DIR-ASYNC",
+               .fn    = run_list_dir_async_test,
+       },
        {
                .name  = "CLEANUP1",
                .fn    = run_cleanup1,