From 3a7591436e68d6f18ac8db0fddf853236b5378d0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bj=C3=B6rn=20Baumbach?= Date: Thu, 13 Feb 2025 18:05:44 +0100 Subject: [PATCH] pytests: test pysmbd with relative path names via samba-tool ntacl MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit BUG: https://bugzilla.samba.org/show_bug.cgi?id=15806 Signed-off-by: Björn Baumbach Reviewed-by: Douglas Bagnall Autobuild-User(master): Björn Baumbach Autobuild-Date(master): Fri Feb 14 16:18:19 UTC 2025 on atb-devel-224 (cherry picked from commit 3e1c19c2c3f8b0bdf21301431bc886757fd4b3ce) --- python/samba/tests/samba_tool/ntacl.py | 61 ++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/python/samba/tests/samba_tool/ntacl.py b/python/samba/tests/samba_tool/ntacl.py index 414ff982bf7..8dd3d236989 100644 --- a/python/samba/tests/samba_tool/ntacl.py +++ b/python/samba/tests/samba_tool/ntacl.py @@ -142,6 +142,67 @@ class NtACLCmdGetSetTestCase(SambaToolCmdTest): "No such file or directory expected") self.assertEqual(out, "", "Shouldn't be any output messages") + def test_set_with_relative_path(self): + path = os.environ['SELFTEST_PREFIX'] + tempf_basename = f"{self.unique_name()}-{secrets.token_hex(10)}" + tempf = os.path.join(path, tempf_basename) + workdir = os.getcwd() + + open(tempf, 'w').write("empty") + + os.chdir(path) + + for fs_arg in ["--use-s3fs", "--use-ntvfs"]: + (result, out, err) = self.runsubcmd("ntacl", + "set", + self.acl, + tempf_basename, + fs_arg) + + self.assertCmdSuccess(result, out, err) + if fs_arg == "--use-s3fs": + self.assertEqual(err, "", "Shouldn't be any error messages") + elif fs_arg == "--use-ntvfs": + self.assertIn("only the stored NT ACL", + err, + "only the stored NT ACL warning expected") + self.assertEqual(out, "", "Shouldn't be any output messages") + + os.chdir(workdir) + + def test_set_with_relative_parent_path(self): + path = os.environ['SELFTEST_PREFIX'] + tempf_basename = f"{self.unique_name()}-{secrets.token_hex(10)}" + tempf = os.path.join(path, tempf_basename) + subdir_basename = f"{self.unique_name()}-subdir-{secrets.token_hex(10)}" + subdir_path = os.path.join(path, subdir_basename) + workdir = os.getcwd() + + os.mkdir(subdir_path) + open(tempf, 'w').write("empty") + + tempf_relative_path = os.path.join("../", tempf_basename) + + os.chdir(subdir_path) + + for fs_arg in ["--use-s3fs", "--use-ntvfs"]: + (result, out, err) = self.runsubcmd("ntacl", + "set", + self.acl, + tempf_relative_path, + fs_arg) + + self.assertCmdSuccess(result, out, err) + if fs_arg == "--use-s3fs": + self.assertEqual(err, "", "Shouldn't be any error messages") + elif fs_arg == "--use-ntvfs": + self.assertIn("only the stored NT ACL", + err, + "only the stored NT ACL warning expected") + self.assertEqual(out, "", "Shouldn't be any output messages") + + os.chdir(workdir) + def test_ntvfs_check(self): path = os.environ['SELFTEST_PREFIX'] tempf = os.path.join(path, "pytests" + str(int(100000 * random.random()))) -- 2.47.2