1185304Strasz#!/bin/sh
2185304Strasz#
3196938Strasz# Copyright (c) 2008, 2009 Edward Tomasz Napiera��a <trasz@FreeBSD.org>
4196938Strasz# All rights reserved.
5196938Strasz#
6196938Strasz# Redistribution and use in source and binary forms, with or without
7196938Strasz# modification, are permitted provided that the following conditions
8196938Strasz# are met:
9196938Strasz# 1. Redistributions of source code must retain the above copyright
10196938Strasz#    notice, this list of conditions and the following disclaimer.
11196938Strasz# 2. Redistributions in binary form must reproduce the above copyright
12196938Strasz#    notice, this list of conditions and the following disclaimer in the
13196938Strasz#    documentation and/or other materials provided with the distribution.
14196938Strasz#
15196938Strasz# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16196938Strasz# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17196938Strasz# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18196938Strasz# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19196938Strasz# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20196938Strasz# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21196938Strasz# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22196938Strasz# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23196938Strasz# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24196938Strasz# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25196938Strasz# SUCH DAMAGE.
26196938Strasz#
27196938Strasz# $FreeBSD: releng/11.0/tests/sys/acl/00.sh 288680 2015-10-05 00:55:16Z ngie $
28196938Strasz#
29196938Strasz
30197436Strasz# This is a wrapper script to run tools-posix.test on UFS filesystem.
31185304Strasz#
32185304Strasz# If any of the tests fails, here is how to debug it: go to
33185304Strasz# the directory with problematic filesystem mounted on it,
34185304Strasz# and do /path/to/test run /path/to/test tools-posix.test, e.g.
35185304Strasz#
36185304Strasz# /usr/src/tools/regression/acltools/run /usr/src/tools/regression/acltools/tools-posix.test
37185304Strasz#
38185304Strasz# Output should be obvious.
39185304Strasz
40288680Sngieif [ $(sysctl -n kern.features.ufs_acl 2>/dev/null || echo 0) -eq 0 ]; then
41288680Sngie	echo "1..0 # SKIP system does not have UFS ACL support"
42288680Sngie	exit 0
43288680Sngiefi
44288680Sngieif [ $(id -u) -ne 0 ]; then
45288680Sngie	echo "1..0 # SKIP you must be root"
46288680Sngie	exit 0
47288680Sngiefi
48288680Sngie
49185304Straszecho "1..4"
50185304Strasz
51219266StraszTESTDIR=$(dirname $(realpath $0))
52185304Strasz
53185304Strasz# Set up the test filesystem.
54185304StraszMD=`mdconfig -at swap -s 10m`
55185304StraszMNT=`mktemp -dt acltools`
56185304Strasznewfs /dev/$MD > /dev/null
57288680Sngietrap "cd /; umount -f $MNT; rmdir $MNT; mdconfig -d -u $MD" EXIT
58185304Straszmount -o acls /dev/$MD $MNT
59185304Straszif [ $? -ne 0 ]; then
60185304Strasz	echo "not ok 1 - mount failed."
61288680Sngie	echo 'Bail out!'
62185304Strasz	exit 1
63185304Straszfi
64185304Strasz
65185304Straszecho "ok 1"
66185304Strasz
67185304Straszcd $MNT
68185304Strasz
69185304Strasz# First, check whether we can crash the kernel by creating too many
70185304Strasz# entries.  For some reason this won't work in the test file.
71185304Strasztouch xxx
72185304Straszi=0;
73185304Straszwhile :; do i=$(($i+1)); setfacl -m u:$i:rwx xxx 2> /dev/null; if [ $? -ne 0 ]; then break; fi; done
74185304Straszchmod 600 xxx
75185304Straszrm xxx
76185304Straszecho "ok 2"
77185304Strasz
78185304Straszperl $TESTDIR/run $TESTDIR/tools-posix.test > /dev/null
79185304Strasz
80185304Straszif [ $? -eq 0 ]; then
81185304Strasz	echo "ok 3"
82185304Straszelse
83185304Strasz	echo "not ok 3"
84185304Straszfi
85185304Strasz
86185304Straszcd /
87185304Strasz
88185304Straszecho "ok 4"
89