From: Noel Power Date: Mon, 27 Jul 2020 15:58:31 +0000 (+0100) Subject: python/samba/tests/blackbox: Tests with nested DFS container X-Git-Tag: talloc-2.3.2~665 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e3079c53877e48defe384efe713e8cfeb9d8fa86;p=thirdparty%2Fsamba.git python/samba/tests/blackbox: Tests with nested DFS container Signed-off-by: Noel Power Reviewed-by: Jeremy Allison Autobuild-User(master): Jeremy Allison Autobuild-Date(master): Mon Aug 31 19:09:24 UTC 2020 on sn-devel-184 --- diff --git a/python/samba/tests/blackbox/smbcacls_dfs_propagate_inherit.py b/python/samba/tests/blackbox/smbcacls_dfs_propagate_inherit.py new file mode 100644 index 00000000000..1df60149176 --- /dev/null +++ b/python/samba/tests/blackbox/smbcacls_dfs_propagate_inherit.py @@ -0,0 +1,96 @@ +# Blackbox tests for smbcaclcs +# +# Copyright (C) Noel Power noel.power@suse.com +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +from __future__ import print_function +from samba.tests import BlackboxProcessError +import os +from samba.tests.blackbox.smbcacls_propagate_inhertance import InheritanceSmbCaclsTests +from samba.tests.blackbox.smbcacls import SmbCaclsBlockboxTestBase + +class DfsInheritanceSmbCaclsTests(InheritanceSmbCaclsTests): + + def setUp(self): + # This is some intentional trickery to ensure we skip + # InheritanceSmbCaclsTests.setUp so we can create a new + # test directory & file hierachy (including a nested dfs link) + SmbCaclsBlockboxTestBase.setUp(self) + smbclient_args = self.build_test_cmd("smbclient", ["//%s/%s" % (self.server, self.share), "-c", "mkdir %s" % os.getenv("TESTDIR", "smbcacls")]) + self.check_output(smbclient_args) + + # create toplevel testdir structure with desired ACL(s) + # + # +-tar_test_dir/ (OI)(CI)(I)(F) + # +-oi_dir/ (OI)(CI)(I)(F) + # | +-file.1 (I)(F) + # | +-nested/ (OI)(CI)(I)(F) + # | +-file.2 (I)(F) + # DFS=>| +-nested_again/ (OI)(CI)(I)(F) + # | +-file.3 (I)(F) + + self.toplevel = self.create_remote_test_file("tar_test_dir/file-0") + self.dfs_target_share = os.getenv("DFS_TARGET_SHARE", "smbcacls_sharedir_dfs") + self.f1 = self.create_remote_test_file("tar_test_dir/oi_dir/file-1") + self.f2 = self.create_remote_test_file("tar_test_dir/oi_dir/nested/file-2") +# self.f3 = self.create_remote_test_file("tar_test_dir/oi_dir/nested/nested_again/file-3") + + + self.tar_dir = os.path.split(self.toplevel)[0] + self.oi_dir = os.path.split(self.f1)[0] + self.nested_dir = os.path.split(self.f2)[0] + + self.nested_again_dir = os.path.join(self.nested_dir, "nested_again") + + # dfs link + link_val = "msdfs:%s\\%s" % (self.server, self.dfs_target_share) + dfs_share_path = "smbcacls_share" + local_link_path = os.path.join(os.environ["LOCAL_PATH"], dfs_share_path) + link_source = link_val + link_dest = os.path.join(local_link_path, self.nested_again_dir) + + + # unfortunately os.link won't work with a source file that doesn't + # exist, we need to run 'ln' directly + #os.link(link_source, link_dest) + link_args = ["ln", "-s", link_source, link_dest] + out = self.check_output(link_args) + + self.f3 = self.create_remote_test_file("tar_test_dir/oi_dir/nested/nested_again/file-3") + + + + dir_acl_str = "ACL:%s:ALLOWED/OI|CI/FULL" % self.user + inherited_dir_acl_str = "ACL:%s:ALLOWED/OI|CI|I/FULL" % self.user + file_acl_str = "ACL:%s:ALLOWED/I/FULL" % self.user + + self.smb_cacls(["--modify", dir_acl_str, self.tar_dir]) + self.smb_cacls(["--modify", inherited_dir_acl_str, self.oi_dir]) + self.smb_cacls(["--modify", inherited_dir_acl_str, self.nested_dir]) + self.smb_cacls(["--modify", inherited_dir_acl_str, self.nested_again_dir]) + self.smb_cacls(["--modify", file_acl_str, self.f1]) + self.smb_cacls(["--modify", file_acl_str, self.f2]) + self.smb_cacls(["--modify", file_acl_str, self.f3]) + + def tearDown(self): + super(DfsInheritanceSmbCaclsTests, self).tearDown() + # for dfs tests inevitably we fallback to remove the local files in + # the base class, the base class however doesn't know about the + # target dfs share (or its contents) so we have to assume we need to + # remove the file on the dfs share + smbclient_args = self.build_test_cmd("smbclient", ["//%s/%s" % (self.server, self.dfs_target_share), "-c", "rm file-3"]) + self.check_output(smbclient_args) + + diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm index 0a8cefa811d..444c837d816 100755 --- a/selftest/target/Samba3.pm +++ b/selftest/target/Samba3.pm @@ -1999,6 +1999,12 @@ sub provision($$) my $smbcacls_sharedir_dfs="$shrdir/smbcacls_sharedir_dfs"; push(@dirs,$smbcacls_sharedir_dfs); + my $smbcacls_share="$shrdir/smbcacls_share"; + push(@dirs,$smbcacls_share); + + my $smbcacls_share_testdir="$shrdir/smbcacls_share/smbcacls"; + push(@dirs,$smbcacls_share_testdir); + my $badnames_shrdir="$shrdir/badnames"; push(@dirs,$badnames_shrdir); @@ -2327,6 +2333,11 @@ sub provision($$) } print CONF " +[smbcacls_share] + path = $smbcacls_share + comment = smb username is [%U] + msdfs root = yes + [smbcacls_sharedir_dfs] path = $smbcacls_sharedir_dfs comment = smb username is [%U] diff --git a/source4/selftest/tests.py b/source4/selftest/tests.py index 5c4e9cef46b..5dec3cba17d 100755 --- a/source4/selftest/tests.py +++ b/source4/selftest/tests.py @@ -947,9 +947,19 @@ planoldpythontestsuite("fileserver", "samba.tests.blackbox.smbcacls_basic(DFS)", environ={'SHARE': 'msdfs-share', 'TESTDIR': 'smbcacls_sharedir_dfs'}) +# Run smbcacls_propagate_inhertance tests on non msdfs root share planoldpythontestsuite("fileserver", "samba.tests.blackbox.smbcacls_propagate_inhertance") - +# +# A) Run the smbcacls_propagate_inhertance tests on a msdfs root share +# *without* any nested dfs links +# B) Run the smbcacls_propagate_inhertance tests on a msdfs root share +# *with* a nested dfs link +# +planoldpythontestsuite("fileserver", + "samba.tests.blackbox.smbcacls_dfs_propagate_inherit", + "samba.tests.blackbox.smbcacls_dfs_propagate_inherit(DFS-msdfs-root)", + environ={'SHARE': 'smbcacls_share'}) # # Want a selection of environments across the process models #