6 #-----------------------------------------------------------------------
7 # Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation.
13 # This program is distributed in the hope that it would be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write the Free Software Foundation,
20 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #-----------------------------------------------------------------------
26 seqres=$RESULT_DIR/$seq
31 status=1 # FAILure is the default!
32 trap "_cleanup; exit \$status" 0 1 2 3 15
34 # get standard environment, filters and checks
43 [ -n "$TEST_DIR" ] && rm -rf $TEST_DIR/$seq.dir1
47 # minimal access ACL has ACEs: USER_OBJ, GROUP_OBJ, OTHER_OBJ
48 # This is set with chacl(1) and can be changed by chmod(1).
50 # Test that this is being set for ACL and for std unix permissions
51 # Test that we can get back the same ACL.
52 # Test std permissions for rwx.
55 # Test out default ACLs and that the ACL is being PASSed
56 # onto the children of the dir.
59 # Test out access check for extended ACLs.
60 # -> 3 extra ACEs: MASK, GROUP, USER
61 # -> the GROUP compares with egid of process _and_ the supplementary
62 # groups (as found in /etc/group)
64 # Test that mask works for USER, GROUP, GROUP_OBJ
65 # Test that the ACE type priority is working
66 # -> this would be done by simultaneously matching on ACEs
67 # -> interesting if it allows user to specify ACEs in any order
70 # real QA test starts here
75 [ -x $runas ] || _notrun "$runas executable not found"
89 echo "QA output created by $seq"
91 echo "=== Test minimal ACE ==="
94 # Note: as this is a shell script,
95 # will need read and execute permission set
96 # in order to execute it.
100 echo "Test was executed"
105 chown $acl1.$acl2 file1
109 echo "--- Test get and set of ACL ---"
110 echo "Note: Old interface gave an empty ACL - now output an ACL"
111 chacl -l file1 | _acl_filter_id
112 echo "Try using single colon separator"
113 echo "Note: Old interface FAILed because of single colon - new one allows it"
114 chacl u::r--,g::rwx,o:rw- file1 2>&1
115 echo "Expect to PASS"
116 chacl u::r--,g::rwx,o::rw- file1 2>&1
117 chacl -l file1 | _acl_filter_id
120 echo "--- Test sync of ACL with std permissions ---"
124 chacl -l file1 | _acl_filter_id
127 echo "--- Test owner permissions ---"
128 chacl u::r-x,g::---,o::--- file1 2>&1
129 chacl -l file1 | _acl_filter_id
131 echo "Expect to PASS"
132 $runas -u $acl1 -g $acl1 ./file1 2>&1
133 echo "Expect to FAIL"
134 $runas -u $acl2 -g $acl2 ./file1 2>&1
137 echo "--- Test group permissions ---"
138 chacl u::---,g::r-x,o::--- file1 2>&1
139 chacl -l file1 | _acl_filter_id
140 echo "Expect to FAIL - acl1 is owner"
141 $runas -u $acl1 -g $acl1 ./file1 2>&1
142 echo "Expect to PASS - acl2 matches group"
143 $runas -u $acl2 -g $acl2 ./file1 2>&1
144 echo "Expect to PASS - acl2 matches sup group"
145 $runas -u $acl2 -g $acl3 -s $acl2 ./file1 2>&1
146 echo "Expect to FAIL - acl3 is not in group"
147 $runas -u $acl3 -g $acl3 ./file1 2>&1
150 echo "--- Test other permissions ---"
151 chacl u::---,g::---,o::r-x file1 2>&1
152 chacl -l file1 | _acl_filter_id
153 echo "Expect to FAIL - acl1 is owner"
154 $runas -u $acl1 -g $acl1 ./file1 2>&1
155 echo "Expect to FAIL - acl2 is in group"
156 $runas -u $acl2 -g $acl2 ./file1 2>&1
157 echo "Expect to FAIL - acl2 is in sup. group"
158 $runas -u $acl2 -g $acl3 -s $acl2 ./file1 2>&1
159 echo "Expect to PASS - acl3 is not owner or in group"
160 $runas -u $acl3 -g $acl3 ./file1 2>&1
162 #-------------------------------------------------------
165 echo "=== Test Extended ACLs ==="
168 echo "--- Test adding a USER ACE ---"
169 echo "Expect to FAIL as no MASK provided"
170 chacl u::---,g::---,o::---,u:$acl2:r-x file1 2>&1 | _acl_filter_id
171 echo "Ensure that ACL has not been changed"
172 chacl -l file1 | _acl_filter_id
173 echo "Expect to PASS - USER ACE matches user"
174 chacl u::---,g::---,o::---,u:$acl2:r-x,m::rwx file1 2>&1
175 chacl -l file1 | _acl_filter_id
176 $runas -u $acl2 -g $acl2 ./file1 2>&1
177 echo "Expect to FAIL - USER ACE does not match user"
178 $runas -u $acl3 -g $acl3 ./file1 2>&1
181 echo "--- Test adding a GROUP ACE ---"
182 echo "Expect to FAIL as no MASK provided"
183 chacl u::---,g::---,o::---,g:$acl2:r-x file1 2>&1 | _acl_filter_id
184 echo "Ensure that ACL has not been changed"
185 chacl -l file1 | _acl_filter_id
186 chacl u::---,g::---,o::---,g:$acl2:r-x,m::rwx file1 2>&1
187 chacl -l file1 | _acl_filter_id
188 echo "Expect to PASS - GROUP ACE matches group"
189 $runas -u $acl2 -g $acl2 ./file1 2>&1
190 echo "Expect to PASS - GROUP ACE matches sup group"
191 $runas -u $acl2 -g $acl1 -s $acl2 ./file1 2>&1
192 echo "Expect to FAIL - GROUP ACE does not match group"
193 $runas -u $acl3 -g $acl3 ./file1 2>&1
195 #-------------------------------------------------------
198 echo "--- Test MASK ---"
201 chacl u::---,g::---,o::---,g:$acl2:r-x,m::-w- file1 2>&1
202 chacl -l file1 | _acl_filter_id
203 echo "Expect to FAIL as MASK prohibits execution"
204 $runas -u $acl2 -g $acl2 ./file1 2>&1
207 chacl u::---,g::---,o::---,u:$acl2:r-x,m::-w- file1 2>&1
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::r-x file1 2>&1
213 echo "Expect to PASS as MASK allows execution"
214 $runas -u $acl2 -g $acl2 ./file1 2>&1
216 #-------------------------------------------------------
219 echo "--- Test ACE priority ---"
221 chacl o::rwx,g::rwx,u:$acl1:rwx,u::---,m::rwx file1 2>&1
222 echo "Expect to FAIL as should match on owner"
223 $runas -u $acl1 -g $acl2 ./file1 2>&1
225 chacl o::---,g::---,u:$acl2:rwx,u::---,m::rwx file1 2>&1
226 echo "Expect to PASS as should match on user"
227 $runas -u $acl2 -g $acl2 ./file1 2>&1
229 #-------------------------------------------------------
232 echo "=== Test can read ACLs without access permissions ==="
233 # This was a bug in kernel code where syscred wasn't being used
234 # to override the capabilities
235 chacl o::---,g::---,u::--- file1 2>&1
236 chacl -l file1 | _acl_filter_id
238 #-------------------------------------------------------
241 echo "=== Test Default ACLs ==="
242 # make test clearer by testing with and without umask
246 chacl -b "u::rwx,g::rwx,o::rwx" "u::r-x,g::r--,o::---" acldir 2>&1
247 chacl -l acldir | _acl_filter_id
252 chacl -l file2 | _acl_filter_id
254 #ensure that umask is not having an effect
259 chacl -l file3 | _acl_filter_id
264 #-------------------------------------------------------
267 echo "=== Removing ACLs ==="
268 chacl -l file1 | _acl_filter_id
269 chacl -l acldir | _acl_filter_id
270 chacl -l acldir/file2 | _acl_filter_id
271 echo "Remove ACLs..."
274 chacl -R acldir/file2
275 echo "Note: Old interface would mean empty ACLs - now we show mode ACLs"
276 chacl -l file1 | _acl_filter_id
277 chacl -l acldir | _acl_filter_id
278 chacl -l acldir/file2 | _acl_filter_id
280 #-------------------------------------------------------
283 echo "=== Recursive change ACL ==="
286 pushd root >/dev/null
287 # create an arbitrary little tree
288 for i in 1 2 3 4 5 6 7 8 9 0
295 chown -R 12345.54321 root
297 $runas -u 12345 -g 54321 -- chacl -r u::rwx,g::-w-,o::--x root
298 find root -print | xargs chacl -l
300 $runas -u 12345 -g 54321 -- chacl -r u::---,g::---,o::--- root
301 find root -print | xargs chacl -l
303 #-------------------------------------------------------
306 echo "=== Test out error messages for ACL text parsing ==="
307 echo "Note: Old interface gave more informative error msgs"
313 chacl u:rumpledumpleunknownuser file1
314 chacl u:rumpledumpleunknownuser: file1
315 chacl g:rumpledumpleunknowngrp file1
316 chacl g:rumpledumpleunknowngrp: file1
317 chacl o:user1:rwx file1
318 chacl m:user1:rwx file1