2 # Blackbox tests for samba-tool ntacl get/set on member server
3 # Copyright (C) 2018 Björn Baumbach <bb@sernet.de>
6 echo "Usage: test_samba-tool_ntacl.sh PREFIX DOMSID"
15 CONFIGURATION="--configfile=$PREFIX/ad_member/lib/server.conf"
19 samba4bindir="$BINDIR"
20 samba_tool="$samba4bindir/samba-tool"
22 testdirtop="$PREFIX/ntacl_testdirtop"
23 testfile="$testdirtop/testfile"
24 testdir1="$testdirtop/dir1"
25 testdir1f="$testdirtop/dir1/file"
26 testdir1l="$testdirtop/dir1/symlink"
28 # acl from samba_tool/ntacl.py tests
29 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)"
30 new_acl="O:S-1-5-21-2212615479-2695158682-2101375468-512G:S-1-5-21-2212615479-2695158682-2101375468-513D:P(A;OICI;0x001f01ff;;;S-1-5-21-2212615479-2695158682-2101375468-512)(A;OICI;0x001f01ff;;;S-1-5-21-2212615479-2695158682-2101375468-519)(A;OICIIO;0x001f01ff;;;CO)(A;OICI;0x001f01ff;;;S-1-5-21-2212615479-2695158682-2101375468-512)(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)"
31 new_domain_sid="S-1-5-21-2212615479-2695158682-2101375468"
33 . $(dirname $0)/subunit.sh
36 export UID_WRAPPER_ROOT
44 retacl=$($PYTHON $samba_tool ntacl get "$testfile" --as-sddl "$@") || return $?
46 test "$retacl" = "$exptextedacl"
55 $PYTHON $samba_tool ntacl set "$acl" "$testfile" "$@"
63 retacl=$($PYTHON $samba_tool ntacl get "$testfile" --as-sddl --use-ntvfs --xattr-backend=tdb $CONFIGURATION) || return $?
65 test "$retacl" = "$exptextedacl"
73 $PYTHON $samba_tool ntacl set "$acl" "$testfile" --use-ntvfs --xattr-backend=tdb $CONFIGURATION
81 $PYTHON $samba_tool ntacl changedomsid \
82 "$domain_sid" "$new_domain_sid" "$testfile" \
87 test_changedomsid_ntvfs()
91 $PYTHON $samba_tool ntacl changedomsid \
92 "$domain_sid" "$new_domain_sid" "$testfile" \
97 retacl=$($PYTHON $samba_tool ntacl get \
100 --xattr-backend=tdb \
102 $CONFIGURATION) || return $?
104 test "$retacl" = "$new_acl"
107 # work around include error - s4-loadparm does not allow missing include files
109 # Unable to load file /home/bbaumba/src/git/samba/st/ad_member/lib/server.conf
110 # File "bin/python/samba/netcmd/__init__.py", line 183, in _run
111 # return self.run(*args, **kwargs)
112 # File "bin/python/samba/netcmd/ntacl.py", line 175, in run
113 # lp = sambaopts.get_loadparm()
114 # File "bin/python/samba/getopt.py", line 92, in get_loadparm
115 # self._lp.load(os.getenv("SMB_CONF_PATH"))
116 # Processing section "[global]"
117 touch "$(dirname $SMB_CONF_PATH)/error_inject.conf"
118 touch "$(dirname $SMB_CONF_PATH)/delay_inject.conf"
124 ln -s "$testfile" "$testdir1l"
126 testit "set_ntacl" test_set_acl "$testfile" "$acl" || failed=$(expr $failed + 1)
128 testit "get_ntacl" test_get_acl "$testfile" "$acl" || failed=$(expr $failed + 1)
130 testit "changedomsid" test_changedomsid "$testfile" || failed=$(expr $failed + 1)
131 testit "get_ntacl_after_changedomsid" \
132 test_get_acl "$testfile" "$new_acl" \
135 || failed=$(expr $failed + 1)
137 testit "set_ntacl_ntvfs" test_set_acl_ntvfs "$testfile" "$acl" || failed=$(expr $failed + 1)
138 testit "get_ntacl_ntvfs" test_get_acl_ntvfs "$testfile" "$acl" || failed=$(expr $failed + 1)
140 testit "changedomsid_ntvfs" test_changedomsid_ntvfs "$testfile" || failed=$(expr $failed + 1)
142 testit_grep "set_ntacl_recursive1 testdirtop" \
143 "ignored symlink: $testdirtop" \
144 test_set_acl "$testdirtop" "$acl" --recursive || failed=$(expr $failed + 1)
145 testit "get_ntacl_after_set_recursive1 testdirtop" \
146 test_get_acl "$testdirtop" "$acl_without_padding" \
149 || failed=$(expr $failed + 1)
150 testit "get_ntacl_after_set_recursive1 testfile" \
151 test_get_acl "$testfile" "$acl_without_padding" \
154 || failed=$(expr $failed + 1)
155 testit "get_ntacl_after_set_recursive1 testdir1" \
156 test_get_acl "$testdir1" "$acl_without_padding" \
159 || failed=$(expr $failed + 1)
160 testit "get_ntacl_after_set_recursive1 testdir1f" \
161 test_get_acl "$testdir1f" "$acl_without_padding" \
164 || failed=$(expr $failed + 1)
166 testit_grep "changedomsid_recursive1 testdir1" \
167 "ignored symlink: $testdir1l" \
168 test_changedomsid "$testdir1" --recursive || failed=$(expr $failed + 1)
169 testit "get_ntacl_after_changedomsid_recursive1 testdirtop" \
170 test_get_acl "$testdirtop" "$acl_without_padding" \
173 || failed=$(expr $failed + 1)
174 testit "get_ntacl_after_changedomsid_recursive1 testfile" \
175 test_get_acl "$testfile" "$acl_without_padding" \
178 || failed=$(expr $failed + 1)
179 testit "get_ntacl_after_changedomsid_recursive1 testdir1" \
180 test_get_acl "$testdir1" "$new_acl_without_padding" \
183 || failed=$(expr $failed + 1)
184 testit "get_ntacl_after_changedomsid_recursive1 testdir1f" \
185 test_get_acl "$testdir1f" "$new_acl_without_padding" \
188 || failed=$(expr $failed + 1)
190 testit_grep "changedomsid_recursive2 testdirtop" \
191 "ignored symlink: $testdir1l" \
192 test_changedomsid "$testdirtop" --recursive || failed=$(expr $failed + 1)
193 testit "get_ntacl_after_changedomsid_recursive2 testdirtop" \
194 test_get_acl "$testdirtop" "$new_acl_without_padding" \
197 || failed=$(expr $failed + 1)
198 testit "get_ntacl_after_changedomsid_recursive2 testfile" \
199 test_get_acl "$testfile" "$new_acl_without_padding" \
202 || failed=$(expr $failed + 1)
203 testit "get_ntacl_after_changedomsid_recursive2 testdir1" \
204 test_get_acl "$testdir1" "$new_acl_without_padding" \
207 || failed=$(expr $failed + 1)
208 testit "get_ntacl_after_changedomsid_recursive2 testdir1f" \
209 test_get_acl "$testdir1f" "$new_acl_without_padding" \
212 || failed=$(expr $failed + 1)
214 testit_grep "set_ntacl_recursive2 testdir1" \
215 "ignored symlink: $testdir1l" \
216 test_set_acl "$testdir1" "$acl" --recursive || failed=$(expr $failed + 1)
217 testit "get_ntacl_after_set_recursive2 testdirtop" \
218 test_get_acl "$testdirtop" "$new_acl_without_padding" \
221 || failed=$(expr $failed + 1)
222 testit "get_ntacl_after_set_recursive2 testfile" \
223 test_get_acl "$testfile" "$new_acl_without_padding" \
226 || failed=$(expr $failed + 1)
227 testit "get_ntacl_after_set_recursive2 testdir1" \
228 test_get_acl "$testdir1" "$acl_without_padding" \
231 || failed=$(expr $failed + 1)
232 testit "get_ntacl_after_set_recursive2 testdir1f" \
233 test_get_acl "$testdir1f" "$acl_without_padding" \
236 || failed=$(expr $failed + 1)
238 testit_grep "set_ntacl_recursive3 testdir1" \
239 "symlink: $testdir1l" \
240 test_set_acl "$testdir1" "$acl" --recursive --follow-symlinks --verbose || failed=$(expr $failed + 1)
241 testit "get_ntacl_after_set_recursive3 testdirtop" \
242 test_get_acl "$testdirtop" "$new_acl_without_padding" \
245 || failed=$(expr $failed + 1)
246 testit "get_ntacl_after_set_recursive3 testfile" \
247 test_get_acl "$testfile" "$acl_without_padding" \
250 || failed=$(expr $failed + 1)
251 testit "get_ntacl_after_set_recursive3 testdir1" \
252 test_get_acl "$testdir1" "$acl_without_padding" \
255 || failed=$(expr $failed + 1)
256 testit "get_ntacl_after_set_recursive3 testdir1f" \
257 test_get_acl "$testdir1f" "$acl_without_padding" \
260 || failed=$(expr $failed + 1)