summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2020-11-17 15:24:43 +0100
committerJeremy Allison <jra@samba.org>2020-11-19 22:56:41 +0000
commit0f67dd540fe11f6543ed759d3d947600c265e889 (patch)
tree67e90ca3364eafb73503c6da19db8968a537e496 /python
parentd680d392685b2501111b1bb9e879f821a348628c (diff)
downloadsamba-0f67dd540fe11f6543ed759d3d947600c265e889.tar.gz
samba-0f67dd540fe11f6543ed759d3d947600c265e889.tar.bz2
samba-0f67dd540fe11f6543ed759d3d947600c265e889.zip
tests: SMB2 rename fails to check del-on-close on dst dir
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'python')
-rw-r--r--python/samba/tests/libsmb.py35
1 files changed, 34 insertions, 1 deletions
diff --git a/python/samba/tests/libsmb.py b/python/samba/tests/libsmb.py
index 0f0d27c9b32..1acb5b12a16 100644
--- a/python/samba/tests/libsmb.py
+++ b/python/samba/tests/libsmb.py
@@ -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()