3 #-----------------------------------------------------------------------
4 # Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License as
8 # published by the Free Software Foundation.
10 # This program is distributed in the hope that it would be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write the Free Software Foundation,
17 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 #-----------------------------------------------------------------------
33 status=1 # FAILure is the default!
34 trap "_cleanup; exit \$status" 0 1 2 3 15
36 # get standard environment, filters and checks
45 [ -n "$testdir" ] && rm -rf $testdir/$seq.dir1
50 # minimal access ACL has ACEs: USER_OBJ, GROUP_OBJ, OTHER_OBJ
51 # This is set with chacl(1) and can be changed by chmod(1).
53 # Test that this is being set for ACL and for std unix permissions
54 # Test that we can get back the same ACL.
55 # Test std permissions for rwx.
58 # Test out default ACLs and that the ACL is being PASSed
59 # onto the children of the dir.
62 # Test out access check for extended ACLs.
63 # -> 3 extra ACEs: MASK, GROUP, USER
64 # -> the GROUP compares with egid of process _and_ the supplementary
65 # groups (as found in /etc/group)
67 # Test that mask works for USER, GROUP, GROUP_OBJ
68 # Test that the ACE type priority is working
69 # -> this would be done by simultaneously matching on ACEs
70 # -> interesting if it allows user to specify ACEs in any order
73 # real QA test starts here
77 [ -x /usr/bin/chacl ] || _notrun "chacl executable not found"
78 [ -x $runas ] || _notrun "$runas executable not found"
94 echo "QA output created by $seq"
96 echo "=== Test minimal ACE ==="
99 # Note: as this is a shell script,
100 # will need read and execute permission set
101 # in order to execute it.
105 echo "Test was executed"
110 chown $acl1.$acl2 file1
114 echo "--- Test get and set of ACL ---"
115 echo "Note: Old interface gave an empty ACL - now output an ACL"
116 chacl -l file1 | _acl_filter_id
117 echo "Try using single colon separator"
118 echo "Note: Old interface FAILed because of single colon - new one allows it"
119 chacl u::r--,g::rwx,o:rw- file1 2>&1
120 echo "Expect to PASS"
121 chacl u::r--,g::rwx,o::rw- file1 2>&1
122 chacl -l file1 | _acl_filter_id
125 echo "--- Test sync of ACL with std permissions ---"
129 chacl -l file1 | _acl_filter_id
132 echo "--- Test owner permissions ---"
133 chacl u::r-x,g::---,o::--- file1 2>&1
134 chacl -l file1 | _acl_filter_id
136 echo "Expect to PASS"
137 $runas -u $acl1 -g $acl1 ./file1 2>&1
138 echo "Expect to FAIL"
139 $runas -u $acl2 -g $acl2 ./file1 2>&1
142 echo "--- Test group permissions ---"
143 chacl u::---,g::r-x,o::--- file1 2>&1
144 chacl -l file1 | _acl_filter_id
145 echo "Expect to FAIL - acl1 is owner"
146 $runas -u $acl1 -g $acl1 ./file1 2>&1
147 echo "Expect to PASS - acl2 matches group"
148 $runas -u $acl2 -g $acl2 ./file1 2>&1
149 echo "Expect to PASS - acl2 matches sup group"
150 $runas -u $acl2 -g $acl3 -s $acl2 ./file1 2>&1
151 echo "Expect to FAIL - acl3 is not in group"
152 $runas -u $acl3 -g $acl3 ./file1 2>&1
155 echo "--- Test other permissions ---"
156 chacl u::---,g::---,o::r-x file1 2>&1
157 chacl -l file1 | _acl_filter_id
158 echo "Expect to FAIL - acl1 is owner"
159 $runas -u $acl1 -g $acl1 ./file1 2>&1
160 echo "Expect to FAIL - acl2 is in group"
161 $runas -u $acl2 -g $acl2 ./file1 2>&1
162 echo "Expect to FAIL - acl2 is in sup. group"
163 $runas -u $acl2 -g $acl3 -s $acl2 ./file1 2>&1
164 echo "Expect to PASS - acl3 is not owner or in group"
165 $runas -u $acl3 -g $acl3 ./file1 2>&1
167 #-------------------------------------------------------
170 echo "=== Test Extended ACLs ==="
173 echo "--- Test adding a USER ACE ---"
174 echo "Expect to FAIL as no MASK provided"
175 chacl u::---,g::---,o::---,u:$acl2:r-x file1 2>&1 | _acl_filter_id
176 echo "Ensure that ACL has not been changed"
177 chacl -l file1 | _acl_filter_id
178 echo "Expect to PASS - USER ACE matches user"
179 chacl u::---,g::---,o::---,u:$acl2:r-x,m::rwx file1 2>&1
180 chacl -l file1 | _acl_filter_id
181 $runas -u $acl2 -g $acl2 ./file1 2>&1
182 echo "Expect to FAIL - USER ACE does not match user"
183 $runas -u $acl3 -g $acl3 ./file1 2>&1
186 echo "--- Test adding a GROUP ACE ---"
187 echo "Expect to FAIL as no MASK provided"
188 chacl u::---,g::---,o::---,g:$acl2:r-x file1 2>&1 | _acl_filter_id
189 echo "Ensure that ACL has not been changed"
190 chacl -l file1 | _acl_filter_id
191 chacl u::---,g::---,o::---,g:$acl2:r-x,m::rwx file1 2>&1
192 chacl -l file1 | _acl_filter_id
193 echo "Expect to PASS - GROUP ACE matches group"
194 $runas -u $acl2 -g $acl2 ./file1 2>&1
195 echo "Expect to PASS - GROUP ACE matches sup group"
196 $runas -u $acl2 -g $acl1 -s $acl2 ./file1 2>&1
197 echo "Expect to FAIL - GROUP ACE does not match group"
198 $runas -u $acl3 -g $acl3 ./file1 2>&1
200 #-------------------------------------------------------
203 echo "--- Test MASK ---"
206 chacl u::---,g::---,o::---,g:$acl2:r-x,m::-w- file1 2>&1
207 chacl -l file1 | _acl_filter_id
208 echo "Expect to FAIL as MASK prohibits execution"
209 $runas -u $acl2 -g $acl2 ./file1 2>&1
212 chacl u::---,g::---,o::---,u:$acl2:r-x,m::-w- file1 2>&1
213 echo "Expect to FAIL as MASK prohibits execution"
214 $runas -u $acl2 -g $acl2 ./file1 2>&1
217 chacl u::---,g::---,o::---,u:$acl2:r-x,m::r-x file1 2>&1
218 echo "Expect to PASS as MASK allows execution"
219 $runas -u $acl2 -g $acl2 ./file1 2>&1
221 #-------------------------------------------------------
224 echo "--- Test ACE priority ---"
226 chacl o::rwx,g::rwx,u:$acl1:rwx,u::---,m::rwx file1 2>&1
227 echo "Expect to FAIL as should match on owner"
228 $runas -u $acl1 -g $acl2 ./file1 2>&1
230 chacl o::---,g::---,u:$acl2:rwx,u::---,m::rwx file1 2>&1
231 echo "Expect to PASS as should match on user"
232 $runas -u $acl2 -g $acl2 ./file1 2>&1
235 #-------------------------------------------------------
238 echo "=== Test can read ACLs without access permissions ==="
239 # This was a bug in kernel code where syscred wasn't being used
240 # to override the capabilities
241 chacl o::---,g::---,u::--- file1 2>&1
242 chacl -l file1 | _acl_filter_id
244 #-------------------------------------------------------
247 echo "=== Test Default ACLs ==="
248 # make test clearer by testing with and without umask
252 chacl -b "u::rwx,g::rwx,o::rwx" "u::r-x,g::r--,o::---" acldir 2>&1
253 chacl -l acldir | _acl_filter_id
258 chacl -l file2 | _acl_filter_id
260 #ensure that umask is not having an effect
265 chacl -l file3 | _acl_filter_id
271 #-------------------------------------------------------
274 echo "=== Removing ACLs ==="
275 chacl -l file1 | _acl_filter_id
276 chacl -l acldir | _acl_filter_id
277 chacl -l acldir/file2 | _acl_filter_id
278 echo "Remove ACLs..."
281 chacl -R acldir/file2
282 echo "Note: Old interface would mean empty ACLs - now we show mode ACLs"
283 chacl -l file1 | _acl_filter_id
284 chacl -l acldir | _acl_filter_id
285 chacl -l acldir/file2 | _acl_filter_id
288 #-------------------------------------------------------
291 echo "=== Recursive change ACL ==="
294 pushd root >/dev/null
295 # create an arbitrary little tree
296 for i in 1 2 3 4 5 6 7 8 9 0
303 chown -R 12345.54321 root
305 $runas -u 12345 -g 54321 -- `which chacl` -r u::rwx,g::-w-,o::--x root
306 find root -print | xargs chacl -l
308 $runas -u 12345 -g 54321 -- `which chacl` -r u::---,g::---,o::--- root
309 find root -print | xargs chacl -l
312 #-------------------------------------------------------
315 echo "=== Test out error messages for ACL text parsing ==="
316 echo "Note: Old interface gave more informative error msgs"
322 chacl u:rumpledumpleunknownuser file1
323 chacl u:rumpledumpleunknownuser: file1
324 chacl g:rumpledumpleunknowngrp file1
325 chacl g:rumpledumpleunknowngrp: file1
326 chacl o:user1:rwx file1
327 chacl m:user1:rwx file1
331 #-------------------------------------------------------
334 echo "=== Test out large ACLs ==="
336 XFS_ACL_MAX_ENTRIES=25
337 num_aces_pre=`expr $XFS_ACL_MAX_ENTRIES - 1`
338 num_aces_post=`expr $XFS_ACL_MAX_ENTRIES + 1`
340 acl1=`_create_n_aces $num_aces_pre`
341 acl2=`_create_n_aces $XFS_ACL_MAX_ENTRIES`
342 acl3=`_create_n_aces $num_aces_post`
343 acl4=`_create_n_aces 16` # Andreas G. libacl size for initial get
344 acl5=`_create_n_aces 17` # 1 over A.G. libacl initial size
346 echo "1 below xfs acl max"
347 chacl $acl1 largeaclfile
348 getfacl largeaclfile | _filter_aces
351 chacl $acl2 largeaclfile
352 getfacl largeaclfile | _filter_aces
354 echo "1 above xfs acl max"
355 chacl $acl3 largeaclfile
356 getfacl largeaclfile | _filter_aces
359 chacl $acl4 largeaclfile
360 getfacl largeaclfile | _filter_aces
363 chacl $acl5 largeaclfile
364 getfacl largeaclfile | _filter_aces
366 #-------------------------------------------------------