xref: /freebsd/tests/sys/acl/tools-nfs4-trivial.test (revision 7fdf597e96a02165cfe22ff357b857d5fa15ed8a)
1# Copyright (c) 2011 Edward Tomasz Napierała <trasz@FreeBSD.org>
2#
3# Redistribution and use in source and binary forms, with or without
4# modification, are permitted provided that the following conditions
5# are met:
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.
11#
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
22# SUCH DAMAGE.
23#
24#
25
26# This is a tools-level test for acl_is_trivial_np(3).  Run it as root on ZFS.
27# Note that this does not work on UFS with NFSv4 ACLs enabled - UFS recognizes
28# both kind of trivial ACLs and replaces it by the default one.
29#
30# WARNING: Creates files in unsafe way.
31
32$ whoami
33> root
34$ umask 022
35
36# Check whether ls(1) correctly recognizes PSARC/2010/029-style trivial ACLs.
37$ touch xxx
38
39$ ls -l xxx | cut -d' ' -f1
40> -rw-r--r--
41
42$ getfacl -q xxx
43>             owner@:rw-p--aARWcCos:-------:allow
44>             group@:r-----a-R-c--s:-------:allow
45>          everyone@:r-----a-R-c--s:-------:allow
46
47# Check whether ls(1) correctly recognizes draft-style trivial ACLs.
48$ rm xxx
49$ touch xxx
50$ setfacl -a0 owner@:x:deny,owner@:rwpAWCo:allow,group@:wxp:deny,group@:r:allow,everyone@:wxpAWCo:deny,everyone@:raRcs:allow xxx
51$ setfacl -x5 xxx
52$ setfacl -x5 xxx
53$ setfacl -x5 xxx
54
55$ ls -l xxx | cut -d' ' -f1
56> -rw-r--r--
57
58$ getfacl -q xxx
59>             owner@:--x-----------:-------:deny
60>             owner@:rw-p---A-W-Co-:-------:allow
61>             group@:-wxp----------:-------:deny
62>             group@:r-------------:-------:allow
63>          everyone@:-wxp---A-W-Co-:-------:deny
64>          everyone@:r-----a-R-c--s:-------:allow
65
66# Make sure ls(1) actually can recognize something as non-trivial.
67$ setfacl -x0 xxx
68
69$ ls -l xxx | cut -d' ' -f1
70> -rw-r--r--+
71
72$ getfacl -q xxx
73>             owner@:rw-p---A-W-Co-:-------:allow
74>             group@:-wxp----------:-------:deny
75>             group@:r-------------:-------:allow
76>          everyone@:-wxp---A-W-Co-:-------:deny
77>          everyone@:r-----a-R-c--s:-------:allow
78
79$ rm xxx
80
81