s4: torture: vfs_fruit. Change test_fruit_locking_conflict() to match the vfs_fruit...
authorJeremy Allison <jra@samba.org>
Thu, 7 Feb 2019 02:01:52 +0000 (18:01 -0800)
committerJeremy Allison <jra@samba.org>
Fri, 8 Feb 2019 22:26:46 +0000 (23:26 +0100)
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 <jra@samba.org>
Reviewed-by: Ralph Böhme <slow@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Fri Feb  8 23:26:46 CET 2019 on sn-devel-144

source4/torture/vfs/fruit.c

index 1296ba82e93a9b2f6fc654605ed89966d24a140c..884a7acdccb1248487151953d1e99834696b32fc 100644 (file)
@@ -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;