1 # Copyright (c) 2008, 2009 Edward Tomasz NapieraĆa <trasz@FreeBSD.org>
3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions
6 # 1. Redistributions of source code must retain the above copyright
7 # notice, this list of conditions and the following disclaimer.
8 # 2. Redistributions in binary form must reproduce the above copyright
9 # notice, this list of conditions and the following disclaimer in the
10 # documentation and/or other materials provided with the distribution.
12 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
13 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
14 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
15 # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
16 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
17 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
18 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
19 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
20 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
21 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 # This is a tools-level test for POSIX.1e ACL functionality. Run it as root
28 # using ACL-enabled kernel:
30 # /usr/src/tools/regression/acltools/run /usr/src/tools/regression/acltools/tools-posix.test
32 # WARNING: Creates files in unsafe way.
38 # Smoke test for getfacl(1).
53 $ setfacl -m u:42:r,g:43:w xxx
65 # Check whether ls correctly marks files with "+".
66 $ ls -l xxx | cut -d' ' -f1
69 # Same as above, but for symlinks.
92 $ setfacl -hm u:44:x,g:45:w lll
104 $ ls -l lll | cut -d' ' -f1
107 # Check whether the original file is left untouched.
108 $ ls -l xxx | cut -d' ' -f1
113 # Test removing entries.
114 $ setfacl -x user:42: xxx
125 $ setfacl -m u:42:r xxx
137 # Test removing entries by number.
149 $ setfacl -m g:43:r xxx
160 # Make sure cp without any flags does not copy the ACL.
162 $ ls -l yyy | cut -d' ' -f1
165 # Make sure it does with the "-p" flag.
180 # Test removing entries by... by example?
181 $ setfacl -m u:42:r,g:43:w xxx
182 $ setfacl -x u:42: xxx
204 $ ls -l xxx | cut -d' ' -f1
216 $ ls -l xxx | cut -d' ' -f1
219 # Check setfacl(1) and getfacl(1) with multiple files.
222 $ ls -l xxx yyy zzz | cut -d' ' -f1
227 $ setfacl -m u:42:x,g:43:w nnn xxx yyy zzz
228 > setfacl: nnn: acl_get_file() failed: No such file or directory
230 $ ls -l nnn xxx yyy zzz | cut -d' ' -f1
231 > ls: nnn: No such file or directory
236 $ getfacl -nq nnn xxx yyy zzz
237 > getfacl: nnn: stat() failed: No such file or directory
259 $ setfacl -b nnn xxx yyy zzz
260 > setfacl: nnn: acl_get_file() failed: No such file or directory
262 $ ls -l nnn xxx yyy zzz | cut -d' ' -f1
263 > ls: nnn: No such file or directory
268 $ setfacl -bn nnn xxx yyy zzz
269 > setfacl: nnn: acl_get_file() failed: No such file or directory
271 $ ls -l nnn xxx yyy zzz | cut -d' ' -f1
272 > ls: nnn: No such file or directory
279 # Check whether chmod actually does what it should do.
281 $ setfacl -m u:42:rwx,g:43:rwx xxx
288 > user:42:rwx # effective: ---
289 > group::r-- # effective: ---
290 > group:43:rwx # effective: ---
300 > user:42:rwx # effective: rw-
302 > group:43:rwx # effective: rw-
314 $ ls -l | grep ddd | cut -d' ' -f1
318 $ setfacl -dm u::rwx,g::rx,o::rx,mask::rwx ddd
325 # No change - ls(1) output doesn't take into account default ACLs.
326 $ ls -l | grep ddd | cut -d' ' -f1
329 $ setfacl -dm g:42:rwx,u:42:r ddd
330 $ setfacl -dm g::w ddd
339 $ setfacl -dx group:42: ddd
347 $ ls -l | grep ddd | cut -d' ' -f1
371 $ setfacl -dm u::rwx,g::rx,o::rx,mask::rwx ddd
372 $ setfacl -dm g:42:rwx,u:43:r ddd
385 > group::r-x # effective: r--
386 > group:42:rwx # effective: r--
395 > group:42:rwx # effective: r-x
403 # Test if we deal properly with fifos.
405 $ ls -l fff | cut -d' ' -f1
408 $ setfacl -m u:42:r,g:43:w fff
420 $ ls -l fff | cut -d' ' -f1
432 $ ls -l fff | cut -d' ' -f1
437 # Test if we deal properly with device files.
439 $ setfacl -m u:42:r,g:43:w bbb
440 > setfacl: bbb: acl_get_file() failed: Operation not supported
441 $ ls -l bbb | cut -d' ' -f1
447 $ setfacl -m u:42:r,g:43:w ccc
448 > setfacl: ccc: acl_get_file() failed: Operation not supported
449 $ ls -l ccc | cut -d' ' -f1