2009-09-07 16:26:03 +00:00
|
|
|
# Copyright (c) 2008, 2009 Edward Tomasz Napierała <trasz@FreeBSD.org>
|
|
|
|
#
|
|
|
|
# Redistribution and use in source and binary forms, with or without
|
|
|
|
# modification, are permitted provided that the following conditions
|
|
|
|
# are met:
|
|
|
|
# 1. Redistributions of source code must retain the above copyright
|
|
|
|
# notice, this list of conditions and the following disclaimer.
|
|
|
|
# 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
# notice, this list of conditions and the following disclaimer in the
|
|
|
|
# documentation and/or other materials provided with the distribution.
|
|
|
|
#
|
|
|
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
# SUCH DAMAGE.
|
|
|
|
#
|
|
|
|
# $FreeBSD$
|
|
|
|
#
|
|
|
|
|
2008-11-25 18:29:33 +00:00
|
|
|
# This is a tools-level test for POSIX.1e ACL functionality. Run it as root
|
|
|
|
# using ACL-enabled kernel:
|
|
|
|
#
|
|
|
|
# /usr/src/tools/regression/acltools/run /usr/src/tools/regression/acltools/tools-posix.test
|
|
|
|
#
|
|
|
|
# WARNING: Creates files in unsafe way.
|
|
|
|
|
|
|
|
$ whoami
|
|
|
|
> root
|
|
|
|
$ umask 022
|
|
|
|
|
|
|
|
# Smoke test for getfacl(1).
|
|
|
|
$ touch xxx
|
2009-09-07 16:26:03 +00:00
|
|
|
$ getfacl -n xxx
|
2008-11-25 18:29:33 +00:00
|
|
|
> # file: xxx
|
|
|
|
> # owner: root
|
|
|
|
> # group: wheel
|
|
|
|
> user::rw-
|
|
|
|
> group::r--
|
|
|
|
> other::r--
|
|
|
|
|
|
|
|
$ getfacl -q xxx
|
|
|
|
> user::rw-
|
|
|
|
> group::r--
|
|
|
|
> other::r--
|
|
|
|
|
|
|
|
$ setfacl -m u:42:r,g:43:w xxx
|
2009-09-07 16:26:03 +00:00
|
|
|
$ getfacl -n xxx
|
2008-11-25 18:29:33 +00:00
|
|
|
> # file: xxx
|
|
|
|
> # owner: root
|
|
|
|
> # group: wheel
|
|
|
|
> user::rw-
|
|
|
|
> user:42:r--
|
|
|
|
> group::r--
|
|
|
|
> group:43:-w-
|
|
|
|
> mask::rw-
|
|
|
|
> other::r--
|
|
|
|
|
|
|
|
# Check whether ls correctly marks files with "+".
|
|
|
|
$ ls -l xxx | cut -d' ' -f1
|
|
|
|
> -rw-rw-r--+
|
|
|
|
|
2009-04-13 13:51:53 +00:00
|
|
|
# Same as above, but for symlinks.
|
|
|
|
$ ln -s xxx lll
|
|
|
|
$ getfacl -h lll
|
|
|
|
> # file: lll
|
|
|
|
> # owner: root
|
|
|
|
> # group: wheel
|
|
|
|
> user::rwx
|
|
|
|
> group::r-x
|
|
|
|
> other::r-x
|
|
|
|
|
|
|
|
$ getfacl -qh lll
|
|
|
|
> user::rwx
|
|
|
|
> group::r-x
|
|
|
|
> other::r-x
|
|
|
|
|
|
|
|
$ getfacl -q lll
|
|
|
|
> user::rw-
|
|
|
|
> user:42:r--
|
|
|
|
> group::r--
|
|
|
|
> group:43:-w-
|
|
|
|
> mask::rw-
|
|
|
|
> other::r--
|
|
|
|
|
|
|
|
$ setfacl -hm u:44:x,g:45:w lll
|
|
|
|
$ getfacl -h lll
|
|
|
|
> # file: lll
|
|
|
|
> # owner: root
|
|
|
|
> # group: wheel
|
|
|
|
> user::rwx
|
|
|
|
> user:44:--x
|
|
|
|
> group::r-x
|
|
|
|
> group:45:-w-
|
|
|
|
> mask::rwx
|
|
|
|
> other::r-x
|
|
|
|
|
|
|
|
$ ls -l lll | cut -d' ' -f1
|
2009-09-01 15:51:36 +00:00
|
|
|
> lrwxrwxr-x+
|
2009-04-13 13:51:53 +00:00
|
|
|
|
|
|
|
# Check whether the original file is left untouched.
|
|
|
|
$ ls -l xxx | cut -d' ' -f1
|
|
|
|
> -rw-rw-r--+
|
|
|
|
|
|
|
|
$ rm lll
|
|
|
|
|
2008-11-25 18:29:33 +00:00
|
|
|
# Test removing entries.
|
|
|
|
$ setfacl -x user:42: xxx
|
|
|
|
$ getfacl xxx
|
|
|
|
> # file: xxx
|
|
|
|
> # owner: root
|
|
|
|
> # group: wheel
|
|
|
|
> user::rw-
|
|
|
|
> group::r--
|
|
|
|
> group:43:-w-
|
|
|
|
> mask::rw-
|
|
|
|
> other::r--
|
|
|
|
|
2009-09-07 16:26:03 +00:00
|
|
|
$ setfacl -m u:42:r xxx
|
|
|
|
$ getfacl -n xxx
|
|
|
|
> # file: xxx
|
|
|
|
> # owner: root
|
|
|
|
> # group: wheel
|
|
|
|
> user::rw-
|
|
|
|
> user:42:r--
|
|
|
|
> group::r--
|
|
|
|
> group:43:-w-
|
|
|
|
> mask::rw-
|
|
|
|
> other::r--
|
|
|
|
|
|
|
|
# Test removing entries by number.
|
|
|
|
$ setfacl -x 1 xxx
|
|
|
|
$ getfacl -n xxx
|
|
|
|
> # file: xxx
|
|
|
|
> # owner: root
|
|
|
|
> # group: wheel
|
|
|
|
> user::rw-
|
|
|
|
> group::r--
|
|
|
|
> group:43:-w-
|
|
|
|
> mask::rw-
|
|
|
|
> other::r--
|
|
|
|
|
2008-11-25 18:29:33 +00:00
|
|
|
$ setfacl -m g:43:r xxx
|
2009-09-07 16:26:03 +00:00
|
|
|
$ getfacl -n xxx
|
2008-11-25 18:29:33 +00:00
|
|
|
> # file: xxx
|
|
|
|
> # owner: root
|
|
|
|
> # group: wheel
|
|
|
|
> user::rw-
|
|
|
|
> group::r--
|
|
|
|
> group:43:r--
|
|
|
|
> mask::r--
|
|
|
|
> other::r--
|
|
|
|
|
|
|
|
# Make sure cp without any flags does not copy the ACL.
|
|
|
|
$ cp xxx yyy
|
|
|
|
$ ls -l yyy | cut -d' ' -f1
|
|
|
|
> -rw-r--r--
|
|
|
|
|
|
|
|
# Make sure it does with the "-p" flag.
|
|
|
|
$ rm yyy
|
|
|
|
$ cp -p xxx yyy
|
2009-09-07 16:26:03 +00:00
|
|
|
$ getfacl -n yyy
|
2008-11-25 18:29:33 +00:00
|
|
|
> # file: yyy
|
|
|
|
> # owner: root
|
|
|
|
> # group: wheel
|
|
|
|
> user::rw-
|
|
|
|
> group::r--
|
|
|
|
> group:43:r--
|
|
|
|
> mask::r--
|
|
|
|
> other::r--
|
|
|
|
|
|
|
|
$ rm yyy
|
|
|
|
|
|
|
|
# Test removing entries by... by example?
|
|
|
|
$ setfacl -m u:42:r,g:43:w xxx
|
|
|
|
$ setfacl -x u:42: xxx
|
2009-09-07 16:26:03 +00:00
|
|
|
$ getfacl -n xxx
|
2008-11-25 18:29:33 +00:00
|
|
|
> # file: xxx
|
|
|
|
> # owner: root
|
|
|
|
> # group: wheel
|
|
|
|
> user::rw-
|
|
|
|
> group::r--
|
|
|
|
> group:43:-w-
|
|
|
|
> mask::rw-
|
|
|
|
> other::r--
|
|
|
|
|
|
|
|
# Test setfacl -b.
|
|
|
|
$ setfacl -b xxx
|
2009-09-07 16:26:03 +00:00
|
|
|
$ getfacl -n xxx
|
2008-11-25 18:29:33 +00:00
|
|
|
> # file: xxx
|
|
|
|
> # owner: root
|
|
|
|
> # group: wheel
|
|
|
|
> user::rw-
|
|
|
|
> group::r--
|
|
|
|
> mask::r--
|
|
|
|
> other::r--
|
|
|
|
|
|
|
|
$ ls -l xxx | cut -d' ' -f1
|
|
|
|
> -rw-r--r--+
|
|
|
|
|
|
|
|
$ setfacl -nb xxx
|
2009-09-07 16:26:03 +00:00
|
|
|
$ getfacl -n xxx
|
2008-11-25 18:29:33 +00:00
|
|
|
> # file: xxx
|
|
|
|
> # owner: root
|
|
|
|
> # group: wheel
|
|
|
|
> user::rw-
|
|
|
|
> group::r--
|
|
|
|
> other::r--
|
|
|
|
|
|
|
|
$ ls -l xxx | cut -d' ' -f1
|
|
|
|
> -rw-r--r--
|
|
|
|
|
|
|
|
# Check setfacl(1) and getfacl(1) with multiple files.
|
|
|
|
$ touch xxx yyy zzz
|
|
|
|
|
|
|
|
$ ls -l xxx yyy zzz | cut -d' ' -f1
|
|
|
|
> -rw-r--r--
|
|
|
|
> -rw-r--r--
|
|
|
|
> -rw-r--r--
|
|
|
|
|
|
|
|
$ setfacl -m u:42:x,g:43:w nnn xxx yyy zzz
|
2018-10-26 19:03:30 +00:00
|
|
|
> setfacl: nnn: acl_get_file() failed: No such file or directory
|
2008-11-25 18:29:33 +00:00
|
|
|
|
|
|
|
$ ls -l nnn xxx yyy zzz | cut -d' ' -f1
|
|
|
|
> ls: nnn: No such file or directory
|
|
|
|
> -rw-rwxr--+
|
|
|
|
> -rw-rwxr--+
|
|
|
|
> -rw-rwxr--+
|
|
|
|
|
2009-09-07 16:26:03 +00:00
|
|
|
$ getfacl -nq nnn xxx yyy zzz
|
|
|
|
> getfacl: nnn: stat() failed: No such file or directory
|
2008-11-25 18:29:33 +00:00
|
|
|
> user::rw-
|
|
|
|
> user:42:--x
|
|
|
|
> group::r--
|
|
|
|
> group:43:-w-
|
|
|
|
> mask::rwx
|
|
|
|
> other::r--
|
|
|
|
>
|
|
|
|
> user::rw-
|
|
|
|
> user:42:--x
|
|
|
|
> group::r--
|
|
|
|
> group:43:-w-
|
|
|
|
> mask::rwx
|
|
|
|
> other::r--
|
|
|
|
>
|
|
|
|
> user::rw-
|
|
|
|
> user:42:--x
|
|
|
|
> group::r--
|
|
|
|
> group:43:-w-
|
|
|
|
> mask::rwx
|
|
|
|
> other::r--
|
|
|
|
|
|
|
|
$ setfacl -b nnn xxx yyy zzz
|
2018-10-26 19:03:30 +00:00
|
|
|
> setfacl: nnn: acl_get_file() failed: No such file or directory
|
2008-11-25 18:29:33 +00:00
|
|
|
|
|
|
|
$ ls -l nnn xxx yyy zzz | cut -d' ' -f1
|
|
|
|
> ls: nnn: No such file or directory
|
|
|
|
> -rw-r--r--+
|
|
|
|
> -rw-r--r--+
|
|
|
|
> -rw-r--r--+
|
|
|
|
|
2009-04-13 13:51:53 +00:00
|
|
|
$ setfacl -bn nnn xxx yyy zzz
|
2018-10-26 19:03:30 +00:00
|
|
|
> setfacl: nnn: acl_get_file() failed: No such file or directory
|
2009-04-13 13:51:53 +00:00
|
|
|
|
|
|
|
$ ls -l nnn xxx yyy zzz | cut -d' ' -f1
|
|
|
|
> ls: nnn: No such file or directory
|
|
|
|
> -rw-r--r--
|
|
|
|
> -rw-r--r--
|
|
|
|
> -rw-r--r--
|
|
|
|
|
2008-11-25 18:29:33 +00:00
|
|
|
$ rm xxx yyy zzz
|
|
|
|
|
|
|
|
# Check whether chmod actually does what it should do.
|
|
|
|
$ touch xxx
|
|
|
|
$ setfacl -m u:42:rwx,g:43:rwx xxx
|
|
|
|
$ chmod 600 xxx
|
2009-09-07 16:26:03 +00:00
|
|
|
$ getfacl -n xxx
|
2008-11-25 18:29:33 +00:00
|
|
|
> # file: xxx
|
|
|
|
> # owner: root
|
|
|
|
> # group: wheel
|
|
|
|
> user::rw-
|
|
|
|
> user:42:rwx # effective: ---
|
|
|
|
> group::r-- # effective: ---
|
|
|
|
> group:43:rwx # effective: ---
|
|
|
|
> mask::---
|
|
|
|
> other::---
|
|
|
|
|
|
|
|
$ chmod 060 xxx
|
2009-09-07 16:26:03 +00:00
|
|
|
$ getfacl -n xxx
|
2008-11-25 18:29:33 +00:00
|
|
|
> # file: xxx
|
|
|
|
> # owner: root
|
|
|
|
> # group: wheel
|
|
|
|
> user::---
|
|
|
|
> user:42:rwx # effective: rw-
|
|
|
|
> group::r--
|
|
|
|
> group:43:rwx # effective: rw-
|
|
|
|
> mask::rw-
|
|
|
|
> other::---
|
|
|
|
|
|
|
|
# Test default ACLs.
|
|
|
|
$ umask 022
|
|
|
|
$ mkdir ddd
|
2009-09-07 16:26:03 +00:00
|
|
|
$ getfacl -qn ddd
|
2008-11-25 18:29:33 +00:00
|
|
|
> user::rwx
|
|
|
|
> group::r-x
|
|
|
|
> other::r-x
|
|
|
|
|
2009-04-13 13:51:53 +00:00
|
|
|
$ ls -l | grep ddd | cut -d' ' -f1
|
|
|
|
> drwxr-xr-x
|
|
|
|
|
2008-11-25 18:29:33 +00:00
|
|
|
$ getfacl -dq ddd
|
2009-04-13 13:51:53 +00:00
|
|
|
$ setfacl -dm u::rwx,g::rx,o::rx,mask::rwx ddd
|
2009-09-07 16:26:03 +00:00
|
|
|
$ getfacl -dqn ddd
|
2008-11-25 18:29:33 +00:00
|
|
|
> user::rwx
|
|
|
|
> group::r-x
|
|
|
|
> mask::rwx
|
|
|
|
> other::r-x
|
|
|
|
|
2009-04-13 13:51:53 +00:00
|
|
|
# No change - ls(1) output doesn't take into account default ACLs.
|
|
|
|
$ ls -l | grep ddd | cut -d' ' -f1
|
|
|
|
> drwxr-xr-x
|
|
|
|
|
2008-11-25 18:29:33 +00:00
|
|
|
$ setfacl -dm g:42:rwx,u:42:r ddd
|
|
|
|
$ setfacl -dm g::w ddd
|
2009-09-07 16:26:03 +00:00
|
|
|
$ getfacl -dqn ddd
|
2008-11-25 18:29:33 +00:00
|
|
|
> user::rwx
|
|
|
|
> user:42:r--
|
|
|
|
> group::-w-
|
|
|
|
> group:42:rwx
|
|
|
|
> mask::rwx
|
|
|
|
> other::r-x
|
|
|
|
|
|
|
|
$ setfacl -dx group:42: ddd
|
2009-09-07 16:26:03 +00:00
|
|
|
$ getfacl -dqn ddd
|
2008-11-25 18:29:33 +00:00
|
|
|
> user::rwx
|
|
|
|
> user:42:r--
|
|
|
|
> group::-w-
|
|
|
|
> mask::rw-
|
|
|
|
> other::r-x
|
|
|
|
|
2009-04-13 13:51:53 +00:00
|
|
|
$ ls -l | grep ddd | cut -d' ' -f1
|
|
|
|
> drwxr-xr-x
|
2008-11-25 18:29:33 +00:00
|
|
|
|
|
|
|
$ rmdir ddd
|
|
|
|
$ rm xxx
|
|
|
|
|
2009-04-13 13:51:53 +00:00
|
|
|
# Test inheritance.
|
|
|
|
$ mkdir ddd
|
|
|
|
|
|
|
|
$ touch ddd/xxx
|
|
|
|
$ getfacl -q ddd/xxx
|
|
|
|
> user::rw-
|
|
|
|
> group::r--
|
|
|
|
> other::r--
|
|
|
|
|
|
|
|
$ mkdir ddd/ddd
|
|
|
|
$ getfacl -q ddd/ddd
|
|
|
|
> user::rwx
|
|
|
|
> group::r-x
|
|
|
|
> other::r-x
|
|
|
|
|
|
|
|
$ rmdir ddd/ddd
|
|
|
|
$ rm ddd/xxx
|
|
|
|
|
|
|
|
$ setfacl -dm u::rwx,g::rx,o::rx,mask::rwx ddd
|
|
|
|
$ setfacl -dm g:42:rwx,u:43:r ddd
|
|
|
|
$ getfacl -dq ddd
|
|
|
|
> user::rwx
|
|
|
|
> user:43:r--
|
|
|
|
> group::r-x
|
|
|
|
> group:42:rwx
|
|
|
|
> mask::rwx
|
|
|
|
> other::r-x
|
|
|
|
|
|
|
|
$ touch ddd/xxx
|
|
|
|
$ getfacl -q ddd/xxx
|
|
|
|
> user::rw-
|
|
|
|
> user:43:r--
|
|
|
|
> group::r-x # effective: r--
|
|
|
|
> group:42:rwx # effective: r--
|
|
|
|
> mask::r--
|
|
|
|
> other::r--
|
|
|
|
|
|
|
|
$ mkdir ddd/ddd
|
|
|
|
$ getfacl -q ddd/ddd
|
|
|
|
> user::rwx
|
|
|
|
> user:43:r--
|
|
|
|
> group::r-x
|
|
|
|
> group:42:rwx # effective: r-x
|
|
|
|
> mask::r-x
|
|
|
|
> other::r-x
|
|
|
|
|
|
|
|
$ rmdir ddd/ddd
|
|
|
|
$ rm ddd/xxx
|
|
|
|
$ rmdir ddd
|
|
|
|
|
2009-07-02 20:05:21 +00:00
|
|
|
# Test if we deal properly with fifos.
|
|
|
|
$ mkfifo fff
|
|
|
|
$ ls -l fff | cut -d' ' -f1
|
|
|
|
> prw-r--r--
|
|
|
|
|
|
|
|
$ setfacl -m u:42:r,g:43:w fff
|
|
|
|
$ getfacl fff
|
|
|
|
> # file: fff
|
|
|
|
> # owner: root
|
|
|
|
> # group: wheel
|
|
|
|
> user::rw-
|
|
|
|
> user:42:r--
|
|
|
|
> group::r--
|
|
|
|
> group:43:-w-
|
|
|
|
> mask::rw-
|
|
|
|
> other::r--
|
|
|
|
|
|
|
|
$ ls -l fff | cut -d' ' -f1
|
|
|
|
> prw-rw-r--+
|
|
|
|
|
|
|
|
$ setfacl -bn fff
|
|
|
|
$ getfacl fff
|
|
|
|
> # file: fff
|
|
|
|
> # owner: root
|
|
|
|
> # group: wheel
|
|
|
|
> user::rw-
|
|
|
|
> group::r--
|
|
|
|
> other::r--
|
|
|
|
|
|
|
|
$ ls -l fff | cut -d' ' -f1
|
|
|
|
> prw-r--r--
|
|
|
|
|
|
|
|
$ rm fff
|
|
|
|
|
2009-08-31 20:11:35 +00:00
|
|
|
# Test if we deal properly with device files.
|
|
|
|
$ mknod bbb b 1 1
|
|
|
|
$ setfacl -m u:42:r,g:43:w bbb
|
2009-09-07 16:26:03 +00:00
|
|
|
> setfacl: bbb: acl_get_file() failed: Operation not supported
|
2009-08-31 20:11:35 +00:00
|
|
|
$ ls -l bbb | cut -d' ' -f1
|
|
|
|
> brw-r--r--
|
|
|
|
|
|
|
|
$ rm bbb
|
|
|
|
|
|
|
|
$ mknod ccc c 1 1
|
|
|
|
$ setfacl -m u:42:r,g:43:w ccc
|
2009-09-07 16:26:03 +00:00
|
|
|
> setfacl: ccc: acl_get_file() failed: Operation not supported
|
2009-08-31 20:11:35 +00:00
|
|
|
$ ls -l ccc | cut -d' ' -f1
|
|
|
|
> crw-r--r--
|
|
|
|
|
|
|
|
$ rm ccc
|