diff options
Diffstat (limited to 'tests/misc/chcon-fail')
-rwxr-xr-x | tests/misc/chcon-fail | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/misc/chcon-fail b/tests/misc/chcon-fail new file mode 100755 index 000000000..d639e86b5 --- /dev/null +++ b/tests/misc/chcon-fail @@ -0,0 +1,41 @@ +#!/bin/sh +# Ensure that chcon fails when it should. +# These tests don't use any actual SE Linux syscalls. + +if test "$VERBOSE" = yes; then + set -x + chcon --version +fi + +. $srcdir/../lang-default + +pwd=`pwd` +t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$ +trap 'status=$?; cd $pwd; chmod -R u+rwx $t0; rm -rf $t0 && exit $status' 0 +trap '(exit $?); exit $?' 1 2 13 15 + +framework_failure=0 +mkdir -p $tmp || framework_failure=1 +cd $tmp || framework_failure=1 + +if test $framework_failure = 1; then + echo "$0: failure in testing framework" 1>&2 + (exit 1); exit 1 +fi + +fail=0 + +# neither context nor file +chcon 2> /dev/null && fail=1 + +# No file +chcon CON 2> /dev/null && fail=1 + +# No file +touch f +chcon --reference=f 2> /dev/null && fail=1 + +# No file +chcon -u anyone 2> /dev/null && fail=1 + +(exit $fail); exit $fail |