]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
torture: add a test that verifies SMB2 close fields without postqueryattrib
authorRalph Boehme <slow@samba.org>
Mon, 24 May 2021 10:21:38 +0000 (12:21 +0200)
committerJeremy Allison <jra@samba.org>
Mon, 24 May 2021 16:05:32 +0000 (16:05 +0000)
The server must set all fields to 0 if postqueryattrib is not set.

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
selftest/knownfail.d/samba3.smb2.timestamps [new file with mode: 0644]
source4/torture/smb2/timestamps.c

diff --git a/selftest/knownfail.d/samba3.smb2.timestamps b/selftest/knownfail.d/samba3.smb2.timestamps
new file mode 100644 (file)
index 0000000..04bdab8
--- /dev/null
@@ -0,0 +1 @@
+^samba3.smb2.timestamps.test_close_not_attrib.*
index f0cc9c269fff12721feb3351d7cc4f5fb423cb88..c37e81d2adcacc316468fd3c5117a0211f141dfb 100644 (file)
 #define BASEDIR "smb2-timestamps"
 #define FNAME "testfile.dat"
 
+static bool test_close_no_attrib(struct torture_context *tctx,
+                                struct smb2_tree *tree)
+{
+       const char *filename = BASEDIR "/" FNAME;
+       struct smb2_create cr;
+       struct smb2_handle handle = {{0}};
+       struct smb2_handle testdirh = {{0}};
+       struct smb2_close c;
+       NTSTATUS status;
+       bool ret = true;
+
+       smb2_deltree(tree, BASEDIR);
+
+       status = torture_smb2_testdir(tree, BASEDIR, &testdirh);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "torture_smb2_testdir failed\n");
+       smb2_util_close(tree, testdirh);
+
+       cr = (struct smb2_create) {
+               .in.desired_access = SEC_FLAG_MAXIMUM_ALLOWED,
+               .in.file_attributes = FILE_ATTRIBUTE_NORMAL,
+               .in.share_access = NTCREATEX_SHARE_ACCESS_MASK,
+               .in.create_disposition = NTCREATEX_DISP_OPEN_IF,
+               .in.impersonation_level = NTCREATEX_IMPERSONATION_ANONYMOUS,
+               .in.fname = filename,
+       };
+
+       status = smb2_create(tree, tctx, &cr);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "smb2_create failed\n");
+       handle = cr.out.file.handle;
+
+       c = (struct smb2_close) {
+               .in.file.handle = handle,
+       };
+
+       status = smb2_close(tree, &c);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "close failed\n");
+       ZERO_STRUCT(handle);
+
+       torture_assert_u64_equal_goto(tctx, c.out.create_time, NTTIME_OMIT,
+                                     ret, done, "Unexpected create time\n");
+       torture_assert_u64_equal_goto(tctx, c.out.access_time, NTTIME_OMIT,
+                                     ret, done, "Unexpected access time\n");
+       torture_assert_u64_equal_goto(tctx, c.out.write_time, NTTIME_OMIT,
+                                     ret, done, "Unexpected write time\n");
+       torture_assert_u64_equal_goto(tctx, c.out.change_time, NTTIME_OMIT,
+                                     ret, done, "Unexpected change time\n");
+       torture_assert_u64_equal_goto(tctx, c.out.alloc_size, 0,
+                                     ret, done, "Unexpected allocation size\n");
+       torture_assert_u64_equal_goto(tctx, c.out.size, 0,
+                                     ret, done, "Unexpected size\n");
+       torture_assert_u64_equal_goto(tctx, c.out.file_attr, 0,
+                                     ret, done, "Unexpected attributes\n");
+
+done:
+       if (!smb2_util_handle_empty(handle)) {
+               smb2_util_close(tree, handle);
+       }
+       smb2_deltree(tree, BASEDIR);
+       return ret;
+}
+
 static bool test_time_t(struct torture_context *tctx,
                        struct smb2_tree *tree,
                        const char *fname,
@@ -907,6 +971,7 @@ struct torture_suite *torture_smb2_timestamps_init(TALLOC_CTX *ctx)
 {
        struct torture_suite *suite = torture_suite_create(ctx, "timestamps");
 
+       torture_suite_add_1smb2_test(suite, "test_close_not_attrib", test_close_no_attrib);
        torture_suite_add_1smb2_test(suite, "time_t_15032385535", test_time_t_15032385535);
        torture_suite_add_1smb2_test(suite, "time_t_10000000000", test_time_t_10000000000);
        torture_suite_add_1smb2_test(suite, "time_t_4294967295", test_time_t_4294967295);