1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-22 05:57:43 +03:00

python/samba/tests/blackbox: Tests with nested DFS container

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Jeremy Allison <jra@samba.org>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Mon Aug 31 19:09:24 UTC 2020 on sn-devel-184
This commit is contained in:
Noel Power 2020-07-27 16:58:31 +01:00 committed by Jeremy Allison
parent 5b04affc73
commit e3079c5387
3 changed files with 118 additions and 1 deletions

View File

@ -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 <http://www.gnu.org/licenses/>.
#
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)

View File

@ -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]

View File

@ -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
#