]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbtorture: add a test trying to create a stream on share without streams support
authorRalph Boehme <slow@samba.org>
Thu, 1 Sep 2022 16:55:23 +0000 (18:55 +0200)
committerJule Anger <janger@samba.org>
Tue, 6 Sep 2022 06:32:13 +0000 (06:32 +0000)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15126
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15161

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
(backported from commit 3dcdab86f13fabb7a8c6ce71c59a565287d11244)
[slow@samba.org: context changes from different tests]

selftest/knownfail.d/samba3.smb2.create_no_streams [new file with mode: 0644]
source3/selftest/tests.py
source4/selftest/tests.py
source4/torture/smb2/create.c
source4/torture/smb2/smb2.c

diff --git a/selftest/knownfail.d/samba3.smb2.create_no_streams b/selftest/knownfail.d/samba3.smb2.create_no_streams
new file mode 100644 (file)
index 0000000..c847608
--- /dev/null
@@ -0,0 +1 @@
+^samba3.smb2.create_no_streams.no_stream\(fileserver\)
index 05690b75c8430ca342de6deb941eb49611c03845..2f1549bc99ebe3c06bbe3df8d65b7728ba6c3c7e 100755 (executable)
@@ -1019,6 +1019,8 @@ for t in tests:
     elif t == "smb2.twrp":
         # This is being driven by samba3.blackbox.shadow_copy_torture
         pass
+    elif t == "smb2.create_no_streams":
+        plansmbtorture4testsuite(t, "fileserver", '//$SERVER_IP/nfs4acl_simple_40 -U$USERNAME%$PASSWORD')
     elif t == "rpc.wkssvc":
         plansmbtorture4testsuite(t, "ad_member", '//$SERVER/tmp -U$DC_USERNAME%$DC_PASSWORD')
     elif t == "rpc.srvsvc":
index 102b17f53760c7eb24ec25b32826610fef4bd525..bc06cba310d2d34c31bafa6b7ee2a7d934fb2bfd 100755 (executable)
@@ -373,6 +373,7 @@ smb2_s3only = [
     "smb2.timestamps",
     "smb2.async_dosmode",
     "smb2.twrp",
+    "smb2.create_no_streams",
 ]
 smb2 = [x for x in smbtorture4_testsuites("smb2.") if x not in smb2_s3only]
 
index 09eab3f1331074d1134ba4bb40416cb74fae7390..94dbae917fd2434af60acb298dfd8c1818771de7 100644 (file)
@@ -3196,3 +3196,51 @@ struct torture_suite *torture_smb2_fileid_unique_init(TALLOC_CTX *ctx)
 
        return suite;
 }
+
+static bool test_no_stream(struct torture_context *tctx,
+                          struct smb2_tree *tree)
+{
+       struct smb2_create c;
+       NTSTATUS status;
+       bool ret = true;
+       const char *names[] = {
+               "test_no_stream::$DATA",
+               "test_no_stream::foooooooooooo",
+               "test_no_stream:stream",
+               "test_no_stream:stream:$DATA",
+               NULL
+       };
+       int i;
+
+       for (i = 0; names[i] != NULL; i++) {
+               c = (struct smb2_create) {
+                       .in.desired_access = SEC_FLAG_MAXIMUM_ALLOWED,
+                       .in.file_attributes = FILE_ATTRIBUTE_NORMAL,
+                       .in.create_disposition = NTCREATEX_DISP_OPEN,
+                       .in.share_access = NTCREATEX_SHARE_ACCESS_MASK,
+                       .in.fname = names[i],
+               };
+
+               status = smb2_create(tree, tctx, &c);
+               if (!NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_INVALID)) {
+                       torture_comment(
+                               tctx, "Expected NT_STATUS_OBJECT_NAME_INVALID, "
+                               "got %s, name: '%s'\n",
+                               nt_errstr(status), names[i]);
+                       torture_fail_goto(tctx, done, "Bad create result\n");
+               }
+       }
+done:
+       return ret;
+}
+
+struct torture_suite *torture_smb2_create_no_streams_init(TALLOC_CTX *ctx)
+{
+       struct torture_suite *suite = torture_suite_create(ctx, "create_no_streams");
+
+       torture_suite_add_1smb2_test(suite, "no_stream", test_no_stream);
+
+       suite->description = talloc_strdup(suite, "SMB2-CREATE stream test on share without streams support");
+
+       return suite;
+}
index 3c69d8c7fa0b61463dbef0c8006154cd062acf42..1d9b7d5573f4dd68c7a0b37239cc6c7f328613b4 100644 (file)
@@ -215,6 +215,7 @@ NTSTATUS torture_smb2_init(TALLOC_CTX *ctx)
        torture_suite_add_1smb2_test(suite, "session-id", run_sessidtest);
        torture_suite_add_suite(suite, torture_smb2_deny_init(suite));
        torture_suite_add_suite(suite, torture_smb2_fileid_unique_init(suite));
+       torture_suite_add_suite(suite, torture_smb2_create_no_streams_init(suite));
 
        suite->description = talloc_strdup(suite, "SMB2-specific tests");