1 # Copyright (c) 2008, 2009 Edward Tomasz NapieraĆa <trasz@FreeBSD.org>
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions
7 # 1. Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer.
9 # 2. Redistributions in binary form must reproduce the above copyright
10 # notice, this list of conditions and the following disclaimer in the
11 # documentation and/or other materials provided with the distribution.
13 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 # This is a tools-level test for POSIX.1e ACL functionality. Run it as root
29 # using ACL-enabled kernel:
31 # /usr/src/tools/regression/acltools/run /usr/src/tools/regression/acltools/tools-posix.test
33 # WARNING: Creates files in unsafe way.
39 # Smoke test for getfacl(1).
54 $ setfacl -m u:42:r,g:43:w xxx
66 # Check whether ls correctly marks files with "+".
67 $ ls -l xxx | cut -d' ' -f1
70 # Same as above, but for symlinks.
93 $ setfacl -hm u:44:x,g:45:w lll
105 $ ls -l lll | cut -d' ' -f1
108 # Check whether the original file is left untouched.
109 $ ls -l xxx | cut -d' ' -f1
114 # Test removing entries.
115 $ setfacl -x user:42: xxx
126 $ setfacl -m u:42:r xxx
138 # Test removing entries by number.
150 $ setfacl -m g:43:r xxx
161 # Make sure cp without any flags does not copy the ACL.
163 $ ls -l yyy | cut -d' ' -f1
166 # Make sure it does with the "-p" flag.
181 # Test removing entries by... by example?
182 $ setfacl -m u:42:r,g:43:w xxx
183 $ setfacl -x u:42: xxx
205 $ ls -l xxx | cut -d' ' -f1
217 $ ls -l xxx | cut -d' ' -f1
220 # Check setfacl(1) and getfacl(1) with multiple files.
223 $ ls -l xxx yyy zzz | cut -d' ' -f1
228 $ setfacl -m u:42:x,g:43:w nnn xxx yyy zzz
229 > setfacl: nnn: stat() failed: No such file or directory
231 $ ls -l nnn xxx yyy zzz | cut -d' ' -f1
232 > ls: nnn: No such file or directory
237 $ getfacl -nq nnn xxx yyy zzz
238 > getfacl: nnn: stat() failed: No such file or directory
260 $ setfacl -b nnn xxx yyy zzz
261 > setfacl: nnn: stat() failed: No such file or directory
263 $ ls -l nnn xxx yyy zzz | cut -d' ' -f1
264 > ls: nnn: No such file or directory
269 $ setfacl -bn nnn xxx yyy zzz
270 > setfacl: nnn: stat() failed: No such file or directory
272 $ ls -l nnn xxx yyy zzz | cut -d' ' -f1
273 > ls: nnn: No such file or directory
280 # Check whether chmod actually does what it should do.
282 $ setfacl -m u:42:rwx,g:43:rwx xxx
289 > user:42:rwx # effective: ---
290 > group::r-- # effective: ---
291 > group:43:rwx # effective: ---
301 > user:42:rwx # effective: rw-
303 > group:43:rwx # effective: rw-
315 $ ls -l | grep ddd | cut -d' ' -f1
319 $ setfacl -dm u::rwx,g::rx,o::rx,mask::rwx ddd
326 # No change - ls(1) output doesn't take into account default ACLs.
327 $ ls -l | grep ddd | cut -d' ' -f1
330 $ setfacl -dm g:42:rwx,u:42:r ddd
331 $ setfacl -dm g::w ddd
340 $ setfacl -dx group:42: ddd
348 $ ls -l | grep ddd | cut -d' ' -f1
372 $ setfacl -dm u::rwx,g::rx,o::rx,mask::rwx ddd
373 $ setfacl -dm g:42:rwx,u:43:r ddd
386 > group::r-x # effective: r--
387 > group:42:rwx # effective: r--
396 > group:42:rwx # effective: r-x
404 # Test if we deal properly with fifos.
406 $ ls -l fff | cut -d' ' -f1
409 $ setfacl -m u:42:r,g:43:w fff
421 $ ls -l fff | cut -d' ' -f1
433 $ ls -l fff | cut -d' ' -f1
438 # Test if we deal properly with device files.
440 $ setfacl -m u:42:r,g:43:w bbb
441 > setfacl: bbb: acl_get_file() failed: Operation not supported
442 $ ls -l bbb | cut -d' ' -f1
448 $ setfacl -m u:42:r,g:43:w ccc
449 > setfacl: ccc: acl_get_file() failed: Operation not supported
450 $ ls -l ccc | cut -d' ' -f1