]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
tests: Check that posix extensions return the file type
authorVolker Lendecke <vl@samba.org>
Mon, 23 Sep 2024 16:23:43 +0000 (18:23 +0200)
committerRalph Boehme <slow@samba.org>
Thu, 26 Sep 2024 15:22:46 +0000 (15:22 +0000)
We'll need to check more, but this is a start

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
python/samba/tests/smb3unix.py
selftest/knownfail.d/smb3unix [new file with mode: 0644]

index 6c04eed0403fd1c54646754ccc155d3a9b3a1b88..5a005889298935b9fbf5d4f0420d908d61c6120f 100644 (file)
@@ -26,6 +26,7 @@ from samba.dcerpc.security import dom_sid
 from samba import reparse_symlink
 import os
 import subprocess
+import stat
 
 def posix_context(mode):
     return (libsmb.SMB2_CREATE_TAG_POSIX, mode.to_bytes(4, 'little'))
@@ -69,6 +70,13 @@ class Smb3UnixTests(samba.tests.libsmb.LibsmbTests):
 
         return (conn1, conn2)
 
+    def wire_mode_to_unix(self, wire):
+        mode = libsmb.wire_mode_to_unix(wire)
+        type = stat.S_IFMT(mode)
+        perms = mode & (stat.S_IRWXU|stat.S_IRWXG|stat.S_IRWXO|
+                        stat.S_ISUID|stat.S_ISGID|stat.S_ISVTX)
+        return (type, perms)
+
     def test_negotiate_context_posix(self):
         c = libsmb.Conn(
             self.server_ip,
@@ -384,7 +392,11 @@ class Smb3UnixTests(samba.tests.libsmb.LibsmbTests):
                 self.assertEqual(cc.nlinks, 2)
 
             self.assertEqual(cc.reparse_tag, libsmb.IO_REPARSE_TAG_RESERVED_ZERO)
-            self.assertEqual(cc.posix_mode, 0o700)
+
+            (type, perms) = self.wire_mode_to_unix(cc.posix_mode);
+            self.assertEqual(type, stat.S_IFDIR)
+            self.assertEqual(perms, 0o700)
+
             self.assertEqual(cc.owner, dom_sid(self.samsid + "-1000"))
             self.assertTrue(str(cc.group).startswith("S-1-22-2-"))
 
diff --git a/selftest/knownfail.d/smb3unix b/selftest/knownfail.d/smb3unix
new file mode 100644 (file)
index 0000000..1bbd7f7
--- /dev/null
@@ -0,0 +1 @@
+samba.tests.smb3unix.samba.tests.smb3unix.Smb3UnixTests.test_create_context_basic1