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