1219877Strasz# Copyright (c) 2011 Edward Tomasz Napiera��a <trasz@FreeBSD.org>
2219877Strasz# All rights reserved.
3219877Strasz#
4219877Strasz# Redistribution and use in source and binary forms, with or without
5219877Strasz# modification, are permitted provided that the following conditions
6219877Strasz# are met:
7219877Strasz# 1. Redistributions of source code must retain the above copyright
8219877Strasz#    notice, this list of conditions and the following disclaimer.
9219877Strasz# 2. Redistributions in binary form must reproduce the above copyright
10219877Strasz#    notice, this list of conditions and the following disclaimer in the
11219877Strasz#    documentation and/or other materials provided with the distribution.
12219877Strasz#
13219877Strasz# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14219877Strasz# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15219877Strasz# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16219877Strasz# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17219877Strasz# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18219877Strasz# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19219877Strasz# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20219877Strasz# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21219877Strasz# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22219877Strasz# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23219877Strasz# SUCH DAMAGE.
24219877Strasz#
25219877Strasz# $FreeBSD: releng/11.0/tests/sys/acl/tools-nfs4-trivial.test 288314 2015-09-27 23:33:54Z ngie $
26219877Strasz#
27219877Strasz
28219877Strasz# This is a tools-level test for acl_is_trivial_np(3).  Run it as root on ZFS.
29219877Strasz# Note that this does not work on UFS with NFSv4 ACLs enabled - UFS recognizes
30219877Strasz# both kind of trivial ACLs and replaces it by the default one.
31219877Strasz#
32219877Strasz# WARNING: Creates files in unsafe way.
33219877Strasz
34219877Strasz$ whoami
35219877Strasz> root
36219877Strasz$ umask 022
37219877Strasz
38219877Strasz# Check whether ls(1) correctly recognizes PSARC/2010/029-style trivial ACLs.
39219877Strasz$ touch xxx
40219877Strasz
41219877Strasz$ ls -l xxx | cut -d' ' -f1
42219877Strasz> -rw-r--r--
43219877Strasz
44219877Strasz$ getfacl -q xxx
45288314Sngie>             owner@:rw-p--aARWcCos:-------:allow
46288314Sngie>             group@:r-----a-R-c--s:-------:allow
47288314Sngie>          everyone@:r-----a-R-c--s:-------:allow
48219877Strasz
49219877Strasz# Check whether ls(1) correctly recognizes draft-style trivial ACLs.
50219877Strasz$ rm xxx
51219877Strasz$ touch xxx
52219877Strasz$ setfacl -a0 owner@:x:deny,owner@:rwpAWCo:allow,group@:wxp:deny,group@:r:allow,everyone@:wxpAWCo:deny,everyone@:raRcs:allow xxx
53219877Strasz$ setfacl -x5 xxx
54219877Strasz$ setfacl -x5 xxx
55219877Strasz$ setfacl -x5 xxx
56219877Strasz
57219877Strasz$ ls -l xxx | cut -d' ' -f1
58219877Strasz> -rw-r--r--
59219877Strasz
60219877Strasz$ getfacl -q xxx
61288314Sngie>             owner@:--x-----------:-------:deny
62288314Sngie>             owner@:rw-p---A-W-Co-:-------:allow
63288314Sngie>             group@:-wxp----------:-------:deny
64288314Sngie>             group@:r-------------:-------:allow
65288314Sngie>          everyone@:-wxp---A-W-Co-:-------:deny
66288314Sngie>          everyone@:r-----a-R-c--s:-------:allow
67219877Strasz
68219877Strasz# Make sure ls(1) actually can recognize something as non-trivial.
69219877Strasz$ setfacl -x0 xxx
70219877Strasz
71219877Strasz$ ls -l xxx | cut -d' ' -f1
72219877Strasz> -rw-r--r--+
73219877Strasz
74219877Strasz$ getfacl -q xxx
75288314Sngie>             owner@:rw-p---A-W-Co-:-------:allow
76288314Sngie>             group@:-wxp----------:-------:deny
77288314Sngie>             group@:r-------------:-------:allow
78288314Sngie>          everyone@:-wxp---A-W-Co-:-------:deny
79288314Sngie>          everyone@:r-----a-R-c--s:-------:allow
80219877Strasz
81219877Strasz$ rm xxx
82219877Strasz
83