testprogs/blackbox: add --recursive tests to test_samba-tool_ntacl.sh
authorStefan Metzmacher <metze@samba.org>
Wed, 17 May 2023 09:26:48 +0000 (11:26 +0200)
committerStefan Metzmacher <metze@samba.org>
Mon, 11 Dec 2023 14:55:16 +0000 (15:55 +0100)
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Thu Jun 22 00:22:47 UTC 2023 on atb-devel-224
(cherry picked from commit 91eb3f1d2236ad88eb3cf6ad036ae16ea2eac6b8)

testprogs/blackbox/test_samba-tool_ntacl.sh

index abe74511b296ab54b8359712ad876535295b604d..ca6dcbe39d096dde3e79cdc981ea4083c2bc22c8 100755 (executable)
@@ -7,6 +7,9 @@ if [ $# -ne 2 ]; then
        exit 1
 fi
 
+set -u
+set -e
+
 PREFIX=$1
 domain_sid=$2
 CONFIGURATION="--configfile=$PREFIX/ad_member/lib/server.conf"
@@ -16,7 +19,11 @@ failed=0
 samba4bindir="$BINDIR"
 samba_tool="$samba4bindir/samba-tool"
 
-testfile="$PREFIX/ntacl_testfile"
+testdirtop="$PREFIX/ntacl_testdirtop"
+testfile="$testdirtop/testfile"
+testdir1="$testdirtop/dir1"
+testdir1f="$testdirtop/dir1/file"
+testdir1l="$testdirtop/dir1/symlink"
 
 # acl from samba_tool/ntacl.py tests
 acl="O:DAG:DUD:P(A;OICI;0x001f01ff;;;DA)(A;OICI;0x001f01ff;;;EA)(A;OICIIO;0x001f01ff;;;CO)(A;OICI;0x001f01ff;;;DA)(A;OICI;0x001f01ff;;;SY)(A;OICI;0x001200a9;;;AU)(A;OICI;0x001200a9;;;ED)S:AI(OU;CIIDSA;WP;f30e3bbe-9ff0-11d1-b603-0000f80367c1;bf967aa5-0de6-11d0-a285-00aa003049e2;WD)(OU;CIIDSA;WP;f30e3bbf-9ff0-11d1-b603-0000f80367c1;bf967aa5-0de6-11d0-a285-00aa003049e2;WD)"
@@ -43,8 +50,9 @@ test_set_acl()
 {
        testfile="$1"
        acl="$2"
+       shift 2
 
-       $PYTHON $samba_tool ntacl set "$acl" "$testfile"
+       $PYTHON $samba_tool ntacl set "$acl" "$testfile" "$@"
 }
 
 test_get_acl_ntvfs()
@@ -109,7 +117,11 @@ test_changedomsid_ntvfs()
 touch "$(dirname $SMB_CONF_PATH)/error_inject.conf"
 touch "$(dirname $SMB_CONF_PATH)/delay_inject.conf"
 
+mkdir "$testdirtop"
 touch "$testfile"
+mkdir "$testdir1"
+touch "$testdir1f"
+ln -s "$testfile" "$testdir1l"
 
 testit "set_ntacl" test_set_acl "$testfile" "$acl" || failed=$(expr $failed + 1)
 
@@ -127,6 +139,126 @@ testit "get_ntacl_ntvfs" test_get_acl_ntvfs "$testfile" "$acl" || failed=$(expr
 
 testit "changedomsid_ntvfs" test_changedomsid_ntvfs "$testfile" || failed=$(expr $failed + 1)
 
-rm -f "$testfile"
+testit_grep "set_ntacl_recursive1 testdirtop" \
+       "ignored symlink: $testdirtop" \
+       test_set_acl "$testdirtop" "$acl" --recursive || failed=$(expr $failed + 1)
+testit "get_ntacl_after_set_recursive1 testdirtop" \
+       test_get_acl "$testdirtop" "$acl_without_padding" \
+               --service=tmp \
+               $CONFIGURATION \
+       || failed=$(expr $failed + 1)
+testit "get_ntacl_after_set_recursive1 testfile" \
+       test_get_acl "$testfile" "$acl_without_padding" \
+               --service=tmp \
+               $CONFIGURATION \
+       || failed=$(expr $failed + 1)
+testit "get_ntacl_after_set_recursive1 testdir1" \
+       test_get_acl "$testdir1" "$acl_without_padding" \
+               --service=tmp \
+               $CONFIGURATION \
+       || failed=$(expr $failed + 1)
+testit "get_ntacl_after_set_recursive1 testdir1f" \
+       test_get_acl "$testdir1f" "$acl_without_padding" \
+               --service=tmp \
+               $CONFIGURATION \
+       || failed=$(expr $failed + 1)
+
+testit_grep "changedomsid_recursive1 testdir1" \
+       "ignored symlink: $testdir1l" \
+       test_changedomsid "$testdir1" --recursive || failed=$(expr $failed + 1)
+testit "get_ntacl_after_changedomsid_recursive1 testdirtop" \
+       test_get_acl "$testdirtop" "$acl_without_padding" \
+               --service=tmp \
+               $CONFIGURATION \
+       || failed=$(expr $failed + 1)
+testit "get_ntacl_after_changedomsid_recursive1 testfile" \
+       test_get_acl "$testfile" "$acl_without_padding" \
+               --service=tmp \
+               $CONFIGURATION \
+       || failed=$(expr $failed + 1)
+testit "get_ntacl_after_changedomsid_recursive1 testdir1" \
+       test_get_acl "$testdir1" "$new_acl_without_padding" \
+               --service=tmp \
+               $CONFIGURATION \
+       || failed=$(expr $failed + 1)
+testit "get_ntacl_after_changedomsid_recursive1 testdir1f" \
+       test_get_acl "$testdir1f" "$new_acl_without_padding" \
+               --service=tmp \
+               $CONFIGURATION \
+       || failed=$(expr $failed + 1)
+
+testit_grep "changedomsid_recursive2 testdirtop" \
+       "ignored symlink: $testdir1l" \
+       test_changedomsid "$testdirtop" --recursive || failed=$(expr $failed + 1)
+testit "get_ntacl_after_changedomsid_recursive2 testdirtop" \
+       test_get_acl "$testdirtop" "$new_acl_without_padding" \
+               --service=tmp \
+               $CONFIGURATION \
+       || failed=$(expr $failed + 1)
+testit "get_ntacl_after_changedomsid_recursive2 testfile" \
+       test_get_acl "$testfile" "$new_acl_without_padding" \
+               --service=tmp \
+               $CONFIGURATION \
+       || failed=$(expr $failed + 1)
+testit "get_ntacl_after_changedomsid_recursive2 testdir1" \
+       test_get_acl "$testdir1" "$new_acl_without_padding" \
+               --service=tmp \
+               $CONFIGURATION \
+       || failed=$(expr $failed + 1)
+testit "get_ntacl_after_changedomsid_recursive2 testdir1f" \
+       test_get_acl "$testdir1f" "$new_acl_without_padding" \
+               --service=tmp \
+               $CONFIGURATION \
+       || failed=$(expr $failed + 1)
+
+testit_grep "set_ntacl_recursive2 testdir1" \
+       "ignored symlink: $testdir1l" \
+       test_set_acl "$testdir1" "$acl" --recursive || failed=$(expr $failed + 1)
+testit "get_ntacl_after_set_recursive2 testdirtop" \
+       test_get_acl "$testdirtop" "$new_acl_without_padding" \
+               --service=tmp \
+               $CONFIGURATION \
+       || failed=$(expr $failed + 1)
+testit "get_ntacl_after_set_recursive2 testfile" \
+       test_get_acl "$testfile" "$new_acl_without_padding" \
+               --service=tmp \
+               $CONFIGURATION \
+       || failed=$(expr $failed + 1)
+testit "get_ntacl_after_set_recursive2 testdir1" \
+       test_get_acl "$testdir1" "$acl_without_padding" \
+               --service=tmp \
+               $CONFIGURATION \
+       || failed=$(expr $failed + 1)
+testit "get_ntacl_after_set_recursive2 testdir1f" \
+       test_get_acl "$testdir1f" "$acl_without_padding" \
+               --service=tmp \
+               $CONFIGURATION \
+       || failed=$(expr $failed + 1)
+
+testit_grep "set_ntacl_recursive3 testdir1" \
+       "symlink: $testdir1l" \
+       test_set_acl "$testdir1" "$acl" --recursive --follow-symlinks --verbose || failed=$(expr $failed + 1)
+testit "get_ntacl_after_set_recursive3 testdirtop" \
+       test_get_acl "$testdirtop" "$new_acl_without_padding" \
+               --service=tmp \
+               $CONFIGURATION \
+       || failed=$(expr $failed + 1)
+testit "get_ntacl_after_set_recursive3 testfile" \
+       test_get_acl "$testfile" "$acl_without_padding" \
+               --service=tmp \
+               $CONFIGURATION \
+       || failed=$(expr $failed + 1)
+testit "get_ntacl_after_set_recursive3 testdir1" \
+       test_get_acl "$testdir1" "$acl_without_padding" \
+               --service=tmp \
+               $CONFIGURATION \
+       || failed=$(expr $failed + 1)
+testit "get_ntacl_after_set_recursive3 testdir1f" \
+       test_get_acl "$testdir1f" "$acl_without_padding" \
+               --service=tmp \
+               $CONFIGURATION \
+       || failed=$(expr $failed + 1)
+
+rm -rf "$testdirtop"
 
 exit $failed