1
0
mirror of https://github.com/samba-team/samba.git synced 2025-12-17 04:23:50 +03:00

tests: Check that posix extensions return the file type

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>
This commit is contained in:
Volker Lendecke
2024-09-23 18:23:43 +02:00
committed by Ralph Boehme
parent 5a3fd9c0f5
commit 3b63170f50
2 changed files with 14 additions and 1 deletions

View 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-"))