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