From: Jeremy Allison Date: Wed, 14 Jul 2021 22:29:01 +0000 (-0700) Subject: s3: tests: Add "SMB2-LIST-DIR-ASYNC" test. X-Git-Tag: samba-4.15.0rc1~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8f8d0eaad68620561eb5bdc95fbb855b90f31fc5;p=thirdparty%2Fsamba.git s3: tests: Add "SMB2-LIST-DIR-ASYNC" test. 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 Reviewed-by: Ralph Boehme --- diff --git a/selftest/knownfail.d/smb2_list_dir_async b/selftest/knownfail.d/smb2_list_dir_async new file mode 100644 index 00000000000..bc3858276f7 --- /dev/null +++ b/selftest/knownfail.d/smb2_list_dir_async @@ -0,0 +1 @@ +^samba3.smbtorture_s3.plain.SMB2-LIST-DIR-ASYNC.smbtorture\(simpleserver\) diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py index 876cd41e486..cf745907219 100755 --- a/source3/selftest/tests.py +++ b/source3/selftest/tests.py @@ -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", diff --git a/source3/torture/proto.h b/source3/torture/proto.h index 90363577ad9..4db267c92b0 100644 --- a/source3/torture/proto.h +++ b/source3/torture/proto.h @@ -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); diff --git a/source3/torture/test_smb2.c b/source3/torture/test_smb2.c index c7fcb3994ba..b186ea4edac 100644 --- a/source3/torture/test_smb2.c +++ b/source3/torture/test_smb2.c @@ -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; +} diff --git a/source3/torture/torture.c b/source3/torture/torture.c index 5deffab6dc2..79a9c65073c 100644 --- a/source3/torture/torture.c +++ b/source3/torture/torture.c @@ -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,