From 28990e4ba23695ecf264117efad90cc4e573302e Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 6 Feb 2019 18:01:52 -0800 Subject: [PATCH] s4: torture: vfs_fruit. Change test_fruit_locking_conflict() to match the vfs_fruit working server code. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Originally added for BUG: https://bugzilla.samba.org/show_bug.cgi?id=13584 to demonstrate a lock order violation, this test exposed problems in the mapping of SMB1/2 share modes and open modes to NetATalk modes once we moved to OFD locks. Change the test slightly (and add comments) so it demonstrates working NetATalk share modes on an open file. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13770 Signed-off-by: Jeremy Allison Reviewed-by: Ralph Böhme Autobuild-User(master): Jeremy Allison Autobuild-Date(master): Fri Feb 8 23:26:46 CET 2019 on sn-devel-144 --- source4/torture/vfs/fruit.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/source4/torture/vfs/fruit.c b/source4/torture/vfs/fruit.c index 1296ba82e93..884a7acdccb 100644 --- a/source4/torture/vfs/fruit.c +++ b/source4/torture/vfs/fruit.c @@ -6361,7 +6361,8 @@ done: } static bool test_fruit_locking_conflict(struct torture_context *tctx, - struct smb2_tree *tree) + struct smb2_tree *tree, + struct smb2_tree *tree2) { TALLOC_CTX *mem_ctx; struct smb2_create create; @@ -6399,6 +6400,7 @@ static bool test_fruit_locking_conflict(struct torture_context *tctx, CHECK_STATUS(status, NT_STATUS_OK); h = create.out.file.handle; + /* Add AD_FILELOCK_RSRC_DENY_WR lock. */ el = (struct smb2_lock_element) { .offset = 0xfffffffffffffffc, .length = 1, @@ -6410,12 +6412,21 @@ static bool test_fruit_locking_conflict(struct torture_context *tctx, .in.locks = &el, }; + /* + * Lock up to and including: + * AD_FILELOCK_OPEN_WR + * AD_FILELOCK_OPEN_RD + * This is designed to cause a NetAtalk + * locking conflict on the next open, + * even though the share modes are + * compatible. + */ status = smb2_lock(tree, &lck); CHECK_STATUS(status, NT_STATUS_OK); el = (struct smb2_lock_element) { .offset = 0, - .length = 0x7fffffffffffffff, + .length = 0x7ffffffffffffff7, .flags = SMB2_LOCK_FLAG_EXCLUSIVE, }; status = smb2_lock(tree, &lck); @@ -6431,8 +6442,13 @@ static bool test_fruit_locking_conflict(struct torture_context *tctx, .in.fname = fname, }; - status = smb2_create(tree, mem_ctx, &create); - CHECK_STATUS(status, NT_STATUS_FILE_LOCK_CONFLICT); + /* + * Open on the second tree - ensure we are + * emulating trying to access with a NetATalk + * process with an existing open/deny mode. + */ + status = smb2_create(tree2, mem_ctx, &create); + CHECK_STATUS(status, NT_STATUS_SHARING_VIOLATION); { struct smb2_close cl = { @@ -6456,7 +6472,7 @@ struct torture_suite *torture_vfs_fruit_netatalk(TALLOC_CTX *ctx) torture_suite_add_1smb2_test(suite, "read netatalk metadata", test_read_netatalk_metadata); torture_suite_add_1smb2_test(suite, "stream names with locally created xattr", test_stream_names_local); - torture_suite_add_1smb2_test( + torture_suite_add_2smb2_test( suite, "locking conflict", test_fruit_locking_conflict); return suite; -- 2.34.1