From 880eb2bd56d6044e7407f98cc0af45df616267ae Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 9 Mar 2023 16:16:50 +0100 Subject: [PATCH] libsmb: Test smb1 mknod Requires O_PATH to work correctly Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- python/samba/tests/smb1posix.py | 20 ++++++++++++++++++++ selftest/skip.opath-required | 7 +++++++ 2 files changed, 27 insertions(+) diff --git a/python/samba/tests/smb1posix.py b/python/samba/tests/smb1posix.py index 52b0312ac8b..d77c49d0664 100644 --- a/python/samba/tests/smb1posix.py +++ b/python/samba/tests/smb1posix.py @@ -19,6 +19,7 @@ from samba.samba3 import libsmb_samba_internal as libsmb from samba import (ntstatus,NTSTATUSError) from samba.dcerpc import security as sec import samba.tests.libsmb +import stat class Smb1PosixTests(samba.tests.libsmb.LibsmbTests): @@ -47,6 +48,25 @@ class Smb1PosixTests(samba.tests.libsmb.LibsmbTests): conn.rmdir("lower/second") conn.rmdir("lower") + def test_mknod(self): + """Test SMB1 posix mknod""" + conn = libsmb.Conn( + self.server_ip, + "posix_share", + self.lp, + self.creds, + force_smb1=True) + conn.smb1_posix() + + def do_test(name, filetype): + conn.mknod(name, filetype | 0o755) + st = conn.smb1_stat(name) + self.assertEqual(st["mode"], filetype | 0o755) + conn.unlink(name) + + do_test("fifo", stat.S_IFIFO) + do_test("sock", stat.S_IFSOCK) + if __name__ == '__main__': import unittest unittest.main() diff --git a/selftest/skip.opath-required b/selftest/skip.opath-required index 0faf0c4bd6c..c3a13f5ec6e 100644 --- a/selftest/skip.opath-required +++ b/selftest/skip.opath-required @@ -7,3 +7,10 @@ # These fail because become_root() doesn't work in make test ^samba3.blackbox.dropbox.* ^samba3.raw.samba3hide.* + +# samba.tests.smb1posix.samba.tests.smb1posix.Smb1PosixTests.test_mknod +# creates a socket and posix stat() gives an error because opening the +# socket from filename_covert_dirfsp() returns ENXIO. With O_PATH +# available this works fine. So for now restrict testing posix +# extensions to environments where we have O_PATH around +^samba.tests.smb1posix