s4-torture: fixed expected error codes for s4 in SMB2-LOCK
authorAndrew Tridgell <tridge@samba.org>
Fri, 27 Nov 2009 03:54:22 +0000 (14:54 +1100)
committerAndrew Tridgell <tridge@samba.org>
Fri, 27 Nov 2009 05:05:06 +0000 (16:05 +1100)
I think the error/success codes returned by windows for these tests
are quite bogus. The ones s4 gives are much more reasonable. The
locking ones returning NT_STATUS_SUCCESS could lead to data loss, as
an application thinks it has a file locked correctly when it fact it
doesn't, so it could do an unsafe modify.

source4/selftest/knownfail
source4/torture/smb2/lock.c

index 3694aede1ba0129f000c94798714ae906e96a60a..3528ff686524bc22324b616ac82536af613f8071 100644 (file)
@@ -64,3 +64,5 @@ samba4.ntvfs.cifs.base.maximum_allowed
 samba4.base.createx_access # this test is broken for non-administrator users
 samba4.smb2.oplock # oplocks in the s4 SMB2 server are a mess
 samba4.smb2.lock.*.VALID-REQUEST # the s4 SMB2 server doesn't check lock ranges
+samba4.smb2.lock.*.CANCEL-TDIS # wrong error code
+samba4.smb2.lock.*.CANCEL-LOGOFF # wrong error code
index beff052a893025e7e3a0cc2a6d16fb08ac54e9e3..e3473ece2b4e62ce3b6cf6816652ac2be18f6434 100644 (file)
@@ -1044,7 +1044,13 @@ static bool test_cancel_tdis(struct torture_context *torture,
 
        torture_comment(torture, "  Check pending lock reply\n");
        status = smb2_lock_recv(req, &lck);
-       CHECK_STATUS(status, NT_STATUS_OK);
+       if (torture_setting_bool(torture, "samba4", false)) {
+               /* saying that this lock succeeded is nonsense - the
+                * tree is gone!! */
+               CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);
+       } else {
+               CHECK_STATUS(status, NT_STATUS_OK);
+       }
 
        torture_comment(torture, "  Attempt to unlock first lock\n");
        lck.in.file.handle      = h;
@@ -1116,13 +1122,26 @@ static bool test_cancel_logoff(struct torture_context *torture,
 
        torture_comment(torture, "  Check pending lock reply\n");
        status = smb2_lock_recv(req, &lck);
-       CHECK_STATUS(status, NT_STATUS_OK);
+       if (torture_setting_bool(torture, "samba4", false)) {
+               /* another bogus 'success' code from windows. The lock
+                * cannot have succeeded, as we are now logged off */
+               CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);
+       } else {
+               CHECK_STATUS(status, NT_STATUS_OK);
+       }
 
        torture_comment(torture, "  Attempt to unlock first lock\n");
        lck.in.file.handle      = h;
        el[0].flags             = SMB2_LOCK_FLAG_UNLOCK;
        status = smb2_lock(tree, &lck);
-       CHECK_STATUS(status, NT_STATUS_FILE_CLOSED);
+       if (torture_setting_bool(torture, "samba4", false)) {
+               /* checking if the credential supplied are still valid
+                * should happen before you validate a file handle,
+                * so we should return USER_SESSION_DELETED */
+               CHECK_STATUS(status, NT_STATUS_USER_SESSION_DELETED);
+       } else {
+               CHECK_STATUS(status, NT_STATUS_FILE_CLOSED);
+       }
 
 done:
        smb2_util_close(tree, h2);