]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
tests: SMB2 rename fails to check del-on-close on dst dir
authorVolker Lendecke <vl@samba.org>
Tue, 17 Nov 2020 14:24:43 +0000 (15:24 +0100)
committerJeremy Allison <jra@samba.org>
Thu, 19 Nov 2020 22:56:41 +0000 (22:56 +0000)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
python/samba/tests/libsmb.py
selftest/knownfail.d/rename_to_del_on_close_dir [new file with mode: 0644]

index 0f0d27c9b32e3ee698fa3ce0e5e84276c3539c80..1acb5b12a16ccd9ea7ad0fd11d779b8598a4a617 100644 (file)
@@ -20,7 +20,8 @@
 from samba.samba3 import libsmb_samba_internal as libsmb
 from samba.dcerpc import security
 from samba.samba3 import param as s3param
-from samba import credentials
+from samba import (credentials,NTSTATUSError)
+from samba.ntstatus import NT_STATUS_DELETE_PENDING
 from samba.credentials import SMB_ENCRYPTION_REQUIRED
 import samba.tests
 import threading
@@ -107,6 +108,38 @@ class LibsmbTestCase(samba.tests.TestCase):
         c.mkdir(test_dir)
         c.rmdir(test_dir)
 
+    def test_RenameDstDelOnClose(self):
+        (lp,creds) = self.prep_creds()
+
+        dstdir = "\\dst-subdir"
+
+        c1 = libsmb.Conn(os.getenv("SERVER_IP"), "tmp", lp, creds)
+        c2 = libsmb.Conn(os.getenv("SERVER_IP"), "tmp", lp, creds)
+
+        try:
+            c1.deltree(dstdir)
+        except:
+            pass
+
+        c1.mkdir(dstdir)
+        dnum = c1.create(dstdir, DesiredAccess=security.SEC_STD_DELETE)
+        c1.delete_on_close(dnum,1)
+        c2.savefile("\\src.txt", b"Content")
+
+        with self.assertRaises(NTSTATUSError) as cm:
+            c2.rename("\\src.txt", dstdir + "\\dst.txt")
+        if (cm.exception.args[0] != NT_STATUS_DELETE_PENDING):
+            raise AssertionError("Rename must fail with DELETE_PENDING")
+
+        c1.delete_on_close(dnum,0)
+        c1.close(dnum)
+
+        try:
+            c1.deltree(dstdir)
+            c1.unlink("\\src.txt")
+        except:
+            pass
+
 if __name__ == "__main__":
     import unittest
     unittest.main()
diff --git a/selftest/knownfail.d/rename_to_del_on_close_dir b/selftest/knownfail.d/rename_to_del_on_close_dir
new file mode 100644 (file)
index 0000000..dc450e0
--- /dev/null
@@ -0,0 +1 @@
+^samba.tests.libsmb.samba.tests.libsmb.LibsmbTestCase.test_RenameDstDelOnClose\(nt4_dc_smb1\)
\ No newline at end of file