s4-torture: in smb2.lock.replay try testing lock sequence checking against SMB3 samba...
authorGünther Deschner <gd@samba.org>
Mon, 25 Jan 2016 17:55:37 +0000 (18:55 +0100)
committerStefan Metzmacher <metze@samba.org>
Mon, 10 Feb 2020 13:37:49 +0000 (14:37 +0100)
Guenther

Signed-off-by: Guenther Deschner <gd@samba.org>
source4/torture/smb2/lock.c

index 099b2cde8df0261e6b2861fbf3c27cdb4f864901..cd71e0a60ae6052bc37fbd9f1d8e0f7d776415cd 100644 (file)
@@ -2913,19 +2913,31 @@ static bool test_replay(struct torture_context *torture,
                .in.file.handle = h
        };
 
-       torture_comment(torture, "Testing Lock (ignored) Replay detection:\n");
-       lck.in.lock_sequence = 0x010 + 0x1;
-       el.flags = SMB2_LOCK_FLAG_EXCLUSIVE | SMB2_LOCK_FLAG_FAIL_IMMEDIATELY;
-       status = smb2_lock(tree, &lck);
-       CHECK_STATUS(status, NT_STATUS_OK);
-       status = smb2_lock(tree, &lck);
-       CHECK_STATUS(status, NT_STATUS_LOCK_NOT_GRANTED);
+       if (TARGET_IS_SAMBA3(torture)) {
 
-       el.flags = SMB2_LOCK_FLAG_UNLOCK;
-       status = smb2_lock(tree, &lck);
-       CHECK_STATUS(status, NT_STATUS_OK);
-       status = smb2_lock(tree, &lck);
-       CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);
+               if (smbXcli_conn_protocol(transport->conn) < PROTOCOL_SMB2_22) {
+                       torture_warning(torture, "SMB 2.22 Dialect family or above \
+                                       required for Lock Replay tests against \
+                                       Samba\n");
+                       goto done;
+               }
+
+       } else {
+
+               torture_comment(torture, "Testing Lock (ignored) Replay detection:\n");
+               lck.in.lock_sequence = 0x010 + 0x1;
+               el.flags = SMB2_LOCK_FLAG_EXCLUSIVE | SMB2_LOCK_FLAG_FAIL_IMMEDIATELY;
+               status = smb2_lock(tree, &lck);
+               CHECK_STATUS(status, NT_STATUS_OK);
+               status = smb2_lock(tree, &lck);
+               CHECK_STATUS(status, NT_STATUS_LOCK_NOT_GRANTED);
+
+               el.flags = SMB2_LOCK_FLAG_UNLOCK;
+               status = smb2_lock(tree, &lck);
+               CHECK_STATUS(status, NT_STATUS_OK);
+               status = smb2_lock(tree, &lck);
+               CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);
+       }
 
        torture_comment(torture, "Testing Set Resiliency:\n");
        SIVAL(res_req, 0, 1000); /* timeout */
@@ -2940,7 +2952,12 @@ static bool test_replay(struct torture_context *torture,
                .in.out.length = sizeof(res_req)
        };
        status = smb2_ioctl(tree, torture, &ioctl);
-       CHECK_STATUS(status, NT_STATUS_OK);
+       if (NT_STATUS_EQUAL(status, NT_STATUS_INVALID_DEVICE_REQUEST)) {
+               torture_warning(torture, "Server does not support "
+                                        "Resilient File Handles");
+       } else {
+               CHECK_STATUS(status, NT_STATUS_OK);
+       }
 
        torture_comment(torture, "Testing Lock (ignored) Replay detection "
                                 "(Bucket No: 0):\n");