2005-04-21 16:53:53 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
2013-04-18 15:41:01 +02:00
|
|
|
# Are we running as root?
|
|
|
|
unset ROOT
|
|
|
|
if [ "`id -u`" = 0 ]
|
|
|
|
then ROOT=yes
|
|
|
|
fi
|
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
# Initialization
|
2014-08-25 00:19:25 +02:00
|
|
|
PATH=:/bin:/usr/bin:/sbin
|
2005-04-21 16:53:53 +02:00
|
|
|
export PATH
|
|
|
|
|
|
|
|
rm -rf DIR* # remove any old junk lying around
|
|
|
|
passed=`expr 0` # count number of tests run correctly
|
|
|
|
failed=`expr 0` # count number of tests that failed
|
2009-12-09 20:01:38 +01:00
|
|
|
skipped=`expr 0` # count number of tests that were skipped
|
2005-04-21 16:53:53 +02:00
|
|
|
total=`expr 0` # total number of tests tried
|
|
|
|
badones= # list of tests that failed
|
|
|
|
|
2013-11-28 10:52:15 +01:00
|
|
|
# In the lists below, shell scripts should be listed without ".sh" suffix
|
|
|
|
|
|
|
|
# Programs that require setuid
|
2013-04-07 00:46:56 +02:00
|
|
|
setuids="test11 test33 test43 test44 test46 test56 test60 test61 test65 \
|
Add PTYFS, Unix98 pseudo terminal support
This patch adds support for Unix98 pseudo terminals, that is,
posix_openpt(3), grantpt(3), unlockpt(3), /dev/ptmx, and /dev/pts/.
The latter is implemented with a new pseudo file system, PTYFS.
In effect, this patch adds secure support for unprivileged pseudo
terminal allocation, allowing programs such as tmux(1) to be used by
non-root users as well. Test77 has been extended with new tests, and
no longer needs to run as root.
The new functionality is optional. To revert to the old behavior,
remove the "ptyfs" entry from /etc/fstab.
Technical nodes:
o The reason for not implementing the NetBSD /dev/ptm approach is that
implementing the corresponding ioctl (TIOCPTMGET) would require
adding a number of extremely hairy exceptions to VFS, including the
PTY driver having to create new file descriptors for its own device
nodes.
o PTYFS is required for Unix98 PTYs in order to avoid that the PTY
driver has to be aware of old-style PTY naming schemes and even has
to call chmod(2) on a disk-backed file system. PTY cannot be its
own PTYFS since a character driver may currently not also be a file
system. However, PTYFS may be subsumed into a DEVFS in the future.
o The Unix98 PTY behavior differs somewhat from NetBSD's, in that
slave nodes are created on ptyfs only upon the first call to
grantpt(3). This approach obviates the need to revoke access as
part of the grantpt(3) call.
o Shutting down PTY may leave slave nodes on PTYFS, but once PTY is
restarted, these leftover slave nodes will be removed before they
create a security risk. Unmounting PTYFS will make existing PTY
slaves permanently unavailable, and absence of PTYFS will block
allocation of new Unix98 PTYs until PTYFS is (re)mounted.
Change-Id: I822b43ba32707c8815fd0f7d5bb7a438f51421c1
2015-06-22 19:14:34 +02:00
|
|
|
test69 test73 test74 test78"
|
2013-11-28 10:52:15 +01:00
|
|
|
# Scripts that require to be run as root
|
2014-12-08 11:32:14 +01:00
|
|
|
rootscripts="testisofs testvnd testrelpol"
|
2013-03-08 17:02:27 +01:00
|
|
|
|
2013-11-28 10:52:15 +01:00
|
|
|
alltests="1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 \
|
2010-05-03 17:12:39 +02:00
|
|
|
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 \
|
2012-02-17 17:12:44 +01:00
|
|
|
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 \
|
2013-11-22 16:38:29 +01:00
|
|
|
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 \
|
2013-09-18 14:09:47 +02:00
|
|
|
sh1 sh2 interp mfs isofs vnd"
|
2010-05-03 17:12:39 +02:00
|
|
|
tests_no=`expr 0`
|
|
|
|
|
2013-03-08 17:02:27 +01:00
|
|
|
# If root, make sure the setuid tests have the correct permissions
|
2013-04-19 12:24:50 +02:00
|
|
|
# and make the dir bin-owned.
|
|
|
|
if [ "$ROOT" ]
|
2014-03-26 18:35:18 +01:00
|
|
|
then /usr/sbin/chown bin .
|
|
|
|
/usr/sbin/chown root ${setuids}
|
2013-04-19 12:24:50 +02:00
|
|
|
chmod 4755 ${setuids}
|
|
|
|
fi
|
2013-04-18 15:41:01 +02:00
|
|
|
|
|
|
|
tests=$alltests
|
|
|
|
|
|
|
|
# Are we given any args? If so, we might have to give
|
|
|
|
# or change our testlist
|
2013-06-16 19:53:18 +02:00
|
|
|
while getopts 'lt:T' opt
|
2013-04-18 15:41:01 +02:00
|
|
|
do
|
|
|
|
case $opt in
|
|
|
|
l) echo "$alltests"
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
t) tests="$OPTARG"
|
|
|
|
;;
|
2013-06-16 19:53:18 +02:00
|
|
|
T) tapmode=yes
|
|
|
|
diagprefix="# "
|
|
|
|
;;
|
|
|
|
?) echo "Usage: run [-l] [-t testlist] [-T]" >&2
|
|
|
|
echo " -l: list tests, exit" >&2
|
|
|
|
echo " -t: execute given set of tests, default: all" >&2
|
|
|
|
echo " -T: produce TAP-format output" >&2
|
|
|
|
exit 1
|
2013-04-18 15:41:01 +02:00
|
|
|
esac
|
|
|
|
done
|
2013-03-08 17:02:27 +01:00
|
|
|
|
2010-08-06 14:33:32 +02:00
|
|
|
# Count tests
|
2010-05-03 17:12:39 +02:00
|
|
|
for i in `echo $tests`; do
|
2013-11-28 10:52:15 +01:00
|
|
|
if [ -x ./test$i -o -x ./test${i}.sh ]; then
|
2010-05-03 17:12:39 +02:00
|
|
|
tests_no=`expr $tests_no + 1`
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2013-04-20 09:26:18 +02:00
|
|
|
if [ $tests_no -eq 0 ]
|
|
|
|
then
|
|
|
|
echo "No test binaries found. did you compile?"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2013-06-16 19:53:18 +02:00
|
|
|
# Print tests list whenever user asks for TAP mode. It is up
|
|
|
|
# to the caller to make sure it makes sense, i.e. he knows what it
|
|
|
|
# represents.
|
|
|
|
if [ "$tapmode" ]
|
|
|
|
then echo "1..$tests_no"
|
|
|
|
fi
|
|
|
|
|
2013-04-18 15:41:01 +02:00
|
|
|
if [ "$tests" = "$alltests" ]
|
|
|
|
then # Print test welcome message
|
2013-06-16 19:53:18 +02:00
|
|
|
if [ ! "$tapmode" ]; then clear; fi
|
|
|
|
echo -n "${diagprefix}Running POSIX compliance test suite. "
|
2013-04-18 15:41:01 +02:00
|
|
|
echo "There are $tests_no tests in total."
|
2013-06-16 19:53:18 +02:00
|
|
|
echo "${diagprefix}"
|
2013-04-18 15:41:01 +02:00
|
|
|
fi
|
2005-06-07 13:52:35 +02:00
|
|
|
|
2012-04-08 19:22:02 +02:00
|
|
|
# Provide an argument for test63
|
|
|
|
ARGS_63=`pwd`/mod
|
|
|
|
|
2013-06-16 19:53:18 +02:00
|
|
|
runtest() {
|
|
|
|
i=$1
|
|
|
|
ARG=$2
|
2013-11-28 10:52:15 +01:00
|
|
|
# setuid doesn't work with scripts, so we can only run those as root
|
|
|
|
if echo "$rootscripts" | tr ' ' '\n' | grep "^test${i}\$" >/dev/null
|
|
|
|
then needroot=1
|
|
|
|
else needroot=0
|
|
|
|
fi
|
|
|
|
# depending on where we are, scripts might have a .sh suffix or not
|
|
|
|
if [ -x test${i}.sh ]
|
|
|
|
then NAME=./test${i}.sh
|
|
|
|
else NAME=./test$i
|
|
|
|
fi
|
2013-06-16 19:53:18 +02:00
|
|
|
if [ "$ROOT" ]
|
2013-11-28 10:52:15 +01:00
|
|
|
then
|
|
|
|
if [ $needroot -eq 1 ]
|
|
|
|
then $NAME $ARG || return 1
|
2014-08-07 13:37:43 +02:00
|
|
|
else su bin -c "$NAME $ARG" || return 1
|
2013-11-28 10:52:15 +01:00
|
|
|
fi
|
|
|
|
else
|
|
|
|
if [ $needroot -eq 1 ]
|
2013-09-18 11:46:08 +02:00
|
|
|
then echo "skipping test$i, not root." >&2 && return 0
|
2013-11-28 10:52:15 +01:00
|
|
|
else $NAME $ARG || return 1
|
|
|
|
fi
|
2013-06-16 19:53:18 +02:00
|
|
|
fi
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2005-06-07 13:52:35 +02:00
|
|
|
# Run all the tests, keeping track of who failed.
|
2010-05-03 17:12:39 +02:00
|
|
|
for i in `echo $tests`
|
2009-12-09 20:01:38 +01:00
|
|
|
do
|
2013-11-28 10:52:15 +01:00
|
|
|
if [ -x ./test$i -o -x ./test${i}.sh ]
|
2009-12-09 20:01:38 +01:00
|
|
|
then
|
|
|
|
total=`expr $total + 1`
|
|
|
|
FAIL=0
|
2013-11-28 10:52:15 +01:00
|
|
|
ARG=`eval echo "\\${ARGS_$i}"`
|
2013-06-16 19:53:18 +02:00
|
|
|
|
2013-06-17 11:12:17 +02:00
|
|
|
if [ "$tapmode" ]
|
|
|
|
then out=out.$$
|
|
|
|
rm -f $out
|
|
|
|
runtest $i $ARG >$out 2>&1
|
|
|
|
else runtest $i $ARG
|
|
|
|
fi
|
|
|
|
|
2013-06-16 19:53:18 +02:00
|
|
|
FAIL=$?
|
|
|
|
|
2009-12-09 20:01:38 +01:00
|
|
|
if [ $FAIL -eq 0 ]
|
2013-06-16 19:53:18 +02:00
|
|
|
then if [ "$tapmode" ]
|
|
|
|
then echo "ok test $i"
|
|
|
|
fi
|
|
|
|
passed=`expr $passed + 1`
|
|
|
|
else if [ "$tapmode" ]
|
|
|
|
then echo "not ok test $i"
|
|
|
|
fi
|
|
|
|
failed=`expr $failed + 1`
|
|
|
|
badones=`echo $badones " " $i`
|
2009-12-09 20:01:38 +01:00
|
|
|
fi
|
2013-06-17 11:12:17 +02:00
|
|
|
|
|
|
|
if [ "$tapmode" ]
|
|
|
|
then cat $out | sed "s/^/$diagprefix/"
|
|
|
|
rm -f $out
|
|
|
|
fi
|
2009-12-09 20:01:38 +01:00
|
|
|
else
|
2013-11-19 17:01:23 +01:00
|
|
|
echo "${diagprefix}warning: skipping test$i"
|
2009-12-09 20:01:38 +01:00
|
|
|
skipped=`expr $skipped + 1`
|
2005-04-21 16:53:53 +02:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
# Print results of the tests.
|
2013-04-18 15:41:01 +02:00
|
|
|
if [ "$tests" = "$alltests" ]
|
2013-06-16 19:53:18 +02:00
|
|
|
then echo "${diagprefix}"
|
2013-04-18 15:41:01 +02:00
|
|
|
if test $total = $passed
|
2013-06-16 19:53:18 +02:00
|
|
|
then echo "${diagprefix}All $passed tests completed without error ($skipped skipped)."
|
|
|
|
else echo "${diagprefix}Testing completed. Score: $passed passed, $failed failed, skipped $skipped"
|
|
|
|
echo "${diagprefix}The following tests failed: $badones"
|
2013-04-18 15:41:01 +02:00
|
|
|
fi
|
2005-04-21 16:53:53 +02:00
|
|
|
fi
|
|
|
|
|
2013-04-20 09:26:18 +02:00
|
|
|
# if any test failed return an error
|
|
|
|
if [ $failed -gt 0 ]
|
|
|
|
then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
# echo " "
|