]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbtorture: verify attributes on fake quota file handle
authorRalph Boehme <slow@samba.org>
Mon, 7 Jun 2021 17:03:05 +0000 (19:03 +0200)
committerJeremy Allison <jra@samba.org>
Wed, 9 Jun 2021 19:47:34 +0000 (19:47 +0000)
The expected DOS attributes are taken from a Windows 2016 server. The expected
timestamps are what Samba has returned before commit 572d4e3a56eef00e29f9348:
NTTIME(0), ie no value.

The upcoming fix will restore this behaviour. Windows of course does
return *some* timestamps, but as it's neither documented nor was I able to
figure out where they would be coming from, as well as the Windows client apparently
doesn't care, I didn't bother with implementing some sophisticated heuristic to
return some timestamps.

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

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

index 0be542c5c1eb3f1160115d6d972ec29e17c0cf6f..84d2999500a72160cac615e611b700c894f50f47 100644 (file)
 ^samba4.raw.acls.*.create_owner_file
 ^samba4.smb2.create.*.acldir
 ^samba4.smb2.create.*.impersonation
+^samba4.smb2.create.quota-fake-file\(ad_dc_ntvfs\) # not supported by the NTVFS
 ^samba4.smb2.acls.*.generic
 ^samba4.smb2.acls.*.inheritflags
 ^samba4.smb2.acls.*.owner
diff --git a/selftest/knownfail.d/samba3.smb2.create b/selftest/knownfail.d/samba3.smb2.create
new file mode 100644 (file)
index 0000000..e1ca027
--- /dev/null
@@ -0,0 +1,2 @@
+^samba3.smb2.create.quota-fake-file\(nt4_dc\)
+^samba3.smb2.create.quota-fake-file\(ad_dc\)
index c97dfef16d3ec0165ac41e6a8b77f75fc935c598..5c559bf2d1d8a46af84342c134d0ccf0ab3192af 100644 (file)
@@ -2707,6 +2707,68 @@ done:
        return ret;
 }
 
+/*
+  test opening quota fakefile handle and returned attributes
+*/
+static bool test_smb2_open_quota_fake_file(struct torture_context *tctx,
+                                          struct smb2_tree *tree)
+{
+       const char *fname = "$Extend\\$Quota:$Q:$INDEX_ALLOCATION";
+       struct smb2_create create;
+       struct smb2_handle h = {{0}};
+       NTSTATUS status;
+       bool ret = true;
+
+       create = (struct smb2_create) {
+               .in.desired_access = SEC_RIGHTS_FILE_READ,
+               .in.file_attributes = FILE_ATTRIBUTE_NORMAL,
+               .in.share_access = NTCREATEX_SHARE_ACCESS_MASK,
+               .in.create_disposition = NTCREATEX_DISP_OPEN,
+               .in.impersonation_level = SMB2_IMPERSONATION_ANONYMOUS,
+               .in.fname = fname,
+       };
+
+       status = smb2_create(tree, tree, &create);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "smb2_create failed\n");
+       h = create.out.file.handle;
+
+       torture_assert_u64_equal_goto(tctx,
+                                     create.out.file_attr,
+                                     FILE_ATTRIBUTE_HIDDEN
+                                     | FILE_ATTRIBUTE_SYSTEM
+                                     | FILE_ATTRIBUTE_DIRECTORY
+                                     | FILE_ATTRIBUTE_ARCHIVE,
+                                     ret,
+                                     done,
+                                     "Wrong attributes\n");
+
+       torture_assert_u64_equal_goto(tctx,
+                                     create.out.create_time, 0,
+                                     ret,
+                                     done,
+                                     "create_time is not 0\n");
+       torture_assert_u64_equal_goto(tctx,
+                                     create.out.access_time, 0,
+                                     ret,
+                                     done,
+                                     "access_time is not 0\n");
+       torture_assert_u64_equal_goto(tctx,
+                                     create.out.write_time, 0,
+                                     ret,
+                                     done,
+                                     "write_time is not 0\n");
+       torture_assert_u64_equal_goto(tctx,
+                                     create.out.change_time, 0,
+                                     ret,
+                                     done,
+                                     "change_time is not 0\n");
+
+done:
+       smb2_util_close(tree, h);
+       return ret;
+}
+
 /*
    basic testing of SMB2 read
 */
@@ -2727,6 +2789,7 @@ struct torture_suite *torture_smb2_create_init(TALLOC_CTX *ctx)
        torture_suite_add_1smb2_test(suite, "nulldacl", test_create_null_dacl);
        torture_suite_add_1smb2_test(suite, "mkdir-dup", test_mkdir_dup);
        torture_suite_add_1smb2_test(suite, "dir-alloc-size", test_dir_alloc_size);
+       torture_suite_add_1smb2_test(suite, "quota-fake-file", test_smb2_open_quota_fake_file);
 
        suite->description = talloc_strdup(suite, "SMB2-CREATE tests");