cp/special-bits \
ls/nameless-uid \
misc/chcon \
+ misc/selinux \
mkdir/writable-under-readonly \
mv/sticky-to-xpart \
rm/fail-2eperm \
. $top_srcdir/tests/test-lib.sh
require_root_
require_selinux_
-
-# When mcstransd is running, you'll see only the 3-component
-# version of file-system context strings. Detect that,
-# and if it's running, skip this test.
-ctx=$(stat --printf='%C\n' .) || framework_failure
-case $ctx in
- *:*:*:*) ;; # four components is ok
- *) # anything else probably means mcstransd is running
- skip_test_ "unexpected context '$ctx'; turn off mcstransd" ;;
-esac
+skip_if_mcstransd_is_running_
mkdir -p d/sub/s2 || framework_failure
touch f g d/sub/1 d/sub/2 || framework_failure
fi
. $top_srcdir/tests/test-lib.sh
-skip_if_root_
+require_root_
require_selinux_
+skip_if_mcstransd_is_running_
# Create a regular file, dir, fifo.
touch f || framework_failure
fail=0
-ctx=root:object_r:tmp_t
-# FIXME, what if $ctx is no different from the default. Not likely.
-# give each a different context, via chcon
-chcon $ctx f d p 2>/dev/null ||
+# special context that works both with and without mcstransd
+ctx=root:object_r:tmp_t:s0
+
+chcon $ctx f d p ||
skip_test_ '"chcon '$ctx' ..." failed'
# inspect that context with both ls -Z and stat.
fi
}
+skip_if_mcstransd_is_running_()
+{
+ test $# = 0 || framework_failure
+
+ # When mcstransd is running, you'll see only the 3-component
+ # version of file-system context strings. Detect that,
+ # and if it's running, skip this test.
+ local ctx=$(stat --printf='%C\n' .) || framework_failure
+ case $ctx in
+ *:*:*:*) ;; # four components is ok
+ *) # anything else probably means mcstransd is running
+ skip_test_ "unexpected context '$ctx'; turn off mcstransd" ;;
+ esac
+}
+
# Skip the current test if umask doesn't work as usual.
# This test should be run in the temporary directory that ends
# up being removed via the trap commands.