xref: /freebsd/tests/sys/acl/00.sh (revision ea82362219ee715cfbb195b2114e73fdc8599fa5)
1b3af24b4SEnji Cooper#!/bin/sh
2b3af24b4SEnji Cooper#
3b3af24b4SEnji Cooper# Copyright (c) 2008, 2009 Edward Tomasz Napierała <trasz@FreeBSD.org>
4b3af24b4SEnji Cooper#
5b3af24b4SEnji Cooper# Redistribution and use in source and binary forms, with or without
6b3af24b4SEnji Cooper# modification, are permitted provided that the following conditions
7b3af24b4SEnji Cooper# are met:
8b3af24b4SEnji Cooper# 1. Redistributions of source code must retain the above copyright
9b3af24b4SEnji Cooper#    notice, this list of conditions and the following disclaimer.
10b3af24b4SEnji Cooper# 2. Redistributions in binary form must reproduce the above copyright
11b3af24b4SEnji Cooper#    notice, this list of conditions and the following disclaimer in the
12b3af24b4SEnji Cooper#    documentation and/or other materials provided with the distribution.
13b3af24b4SEnji Cooper#
14b3af24b4SEnji Cooper# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15b3af24b4SEnji Cooper# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16b3af24b4SEnji Cooper# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17b3af24b4SEnji Cooper# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18b3af24b4SEnji Cooper# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19b3af24b4SEnji Cooper# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20b3af24b4SEnji Cooper# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21b3af24b4SEnji Cooper# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22b3af24b4SEnji Cooper# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23b3af24b4SEnji Cooper# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24b3af24b4SEnji Cooper# SUCH DAMAGE.
25b3af24b4SEnji Cooper#
26b3af24b4SEnji Cooper#
27b3af24b4SEnji Cooper
28b3af24b4SEnji Cooper# This is a wrapper script to run tools-posix.test on UFS filesystem.
29b3af24b4SEnji Cooper#
30b3af24b4SEnji Cooper# If any of the tests fails, here is how to debug it: go to
31b3af24b4SEnji Cooper# the directory with problematic filesystem mounted on it,
32b3af24b4SEnji Cooper# and do /path/to/test run /path/to/test tools-posix.test, e.g.
33b3af24b4SEnji Cooper#
34b3af24b4SEnji Cooper# /usr/src/tools/regression/acltools/run /usr/src/tools/regression/acltools/tools-posix.test
35b3af24b4SEnji Cooper#
36b3af24b4SEnji Cooper# Output should be obvious.
37b3af24b4SEnji Cooper
38b3af24b4SEnji Cooperif [ $(sysctl -n kern.features.ufs_acl 2>/dev/null || echo 0) -eq 0 ]; then
39b3af24b4SEnji Cooper	echo "1..0 # SKIP system does not have UFS ACL support"
40b3af24b4SEnji Cooper	exit 0
41b3af24b4SEnji Cooperfi
42b3af24b4SEnji Cooperif [ $(id -u) -ne 0 ]; then
43b3af24b4SEnji Cooper	echo "1..0 # SKIP you must be root"
44b3af24b4SEnji Cooper	exit 0
45b3af24b4SEnji Cooperfi
46*ea823622SWarner Loshif [ ! -c /dev/mdctl ]; then
47*ea823622SWarner Losh	echo "1..0 # SKIP no /dev/mdctl to create md devices"
48*ea823622SWarner Losh	exit 0
49*ea823622SWarner Loshfi
50b3af24b4SEnji Cooper
51b3af24b4SEnji Cooperecho "1..4"
52b3af24b4SEnji Cooper
53b3af24b4SEnji CooperTESTDIR=$(dirname $(realpath $0))
54b3af24b4SEnji Cooper
55b3af24b4SEnji Cooper# Set up the test filesystem.
56b3af24b4SEnji CooperMD=`mdconfig -at swap -s 10m`
57b3af24b4SEnji CooperMNT=`mktemp -dt acltools`
58b3af24b4SEnji Coopernewfs /dev/$MD > /dev/null
59b3af24b4SEnji Coopertrap "cd /; umount -f $MNT; rmdir $MNT; mdconfig -d -u $MD" EXIT
60b3af24b4SEnji Coopermount -o acls /dev/$MD $MNT
61b3af24b4SEnji Cooperif [ $? -ne 0 ]; then
62b3af24b4SEnji Cooper	echo "not ok 1 - mount failed."
63b3af24b4SEnji Cooper	echo 'Bail out!'
64b3af24b4SEnji Cooper	exit 1
65b3af24b4SEnji Cooperfi
66b3af24b4SEnji Cooper
67b3af24b4SEnji Cooperecho "ok 1"
68b3af24b4SEnji Cooper
69b3af24b4SEnji Coopercd $MNT
70b3af24b4SEnji Cooper
71b3af24b4SEnji Cooper# First, check whether we can crash the kernel by creating too many
72b3af24b4SEnji Cooper# entries.  For some reason this won't work in the test file.
73b3af24b4SEnji Coopertouch xxx
74b3af24b4SEnji Cooperi=0;
75b3af24b4SEnji Cooperwhile :; do i=$(($i+1)); setfacl -m u:$i:rwx xxx 2> /dev/null; if [ $? -ne 0 ]; then break; fi; done
76b3af24b4SEnji Cooperchmod 600 xxx
77b3af24b4SEnji Cooperrm xxx
78b3af24b4SEnji Cooperecho "ok 2"
79b3af24b4SEnji Cooper
80708cc995SEnji Cooperperl $TESTDIR/run $TESTDIR/tools-posix.test >&2
81b3af24b4SEnji Cooper
82b3af24b4SEnji Cooperif [ $? -eq 0 ]; then
83b3af24b4SEnji Cooper	echo "ok 3"
84b3af24b4SEnji Cooperelse
85b3af24b4SEnji Cooper	echo "not ok 3"
86b3af24b4SEnji Cooperfi
87b3af24b4SEnji Cooper
88b3af24b4SEnji Coopercd /
89b3af24b4SEnji Cooper
90b3af24b4SEnji Cooperecho "ok 4"
91