From: Ralph Boehme Date: Mon, 7 Jun 2021 17:03:05 +0000 (+0200) Subject: smbtorture: verify attributes on fake quota file handle X-Git-Tag: tevent-0.11.0~452 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1e338d51602a7dca6108e5e8704f5cdde4740713;p=thirdparty%2Fsamba.git smbtorture: verify attributes on fake quota file handle 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 Reviewed-by: Jeremy Allison --- diff --git a/selftest/knownfail b/selftest/knownfail index 0be542c5c1e..84d2999500a 100644 --- a/selftest/knownfail +++ b/selftest/knownfail @@ -144,6 +144,7 @@ ^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 index 00000000000..e1ca027872c --- /dev/null +++ b/selftest/knownfail.d/samba3.smb2.create @@ -0,0 +1,2 @@ +^samba3.smb2.create.quota-fake-file\(nt4_dc\) +^samba3.smb2.create.quota-fake-file\(ad_dc\) diff --git a/source4/torture/smb2/create.c b/source4/torture/smb2/create.c index c97dfef16d3..5c559bf2d1d 100644 --- a/source4/torture/smb2/create.c +++ b/source4/torture/smb2/create.c @@ -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");