mirror of
https://github.com/coreutils/coreutils.git
synced 2024-11-24 18:33:47 +08:00
tests: fix false failure with disabled SELinux support
This could trigger on SELinux systems where we build --qithout-selinux or where the SELinux development libraries are not installed. * init.cfg (require_selinux_enforcing_): Call require_selinux_() to determine if the current build supports SELinux. This avoids a false failure in tests/mkdir/selinux.sh where only mkdir would determine that SELinux was disabled and thus ignore invalid contexts. (require_selinux_): Refactor a little to distinguish whether it's the build or the (file) system that doesn't support SELinux.
This commit is contained in:
parent
0013de3e60
commit
37e001d209
42
init.cfg
42
init.cfg
@ -90,9 +90,31 @@ require_local_dir_()
|
||||
skip_ "This test must be run on a local file system."
|
||||
}
|
||||
|
||||
require_selinux_()
|
||||
{
|
||||
# When in a chroot of an SELinux-enabled system, but with a mock-simulated
|
||||
# SELinux-*disabled* system, recognize that SELinux is disabled system wide:
|
||||
grep 'selinuxfs$' /proc/filesystems > /dev/null \
|
||||
|| skip_ "this system lacks SELinux support"
|
||||
|
||||
# Independent of whether SELinux is enabled system-wide,
|
||||
# the current file system may lack SELinux support.
|
||||
# Also the current build may have SELinux support disabled.
|
||||
case $(ls -Zd .) in
|
||||
'? .'|'unlabeled .')
|
||||
test -z "$CONFIG_HEADER" \
|
||||
&& framework_failure_ 'CONFIG_HEADER not defined'
|
||||
grep '^#define HAVE_SELINUX_SELINUX_H 1' "$CONFIG_HEADER" > /dev/null \
|
||||
&& selinux_missing_="(file) system" || selinux_missing_="build"
|
||||
skip_ "this $selinux_missing_ lacks SELinux support"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Skip this test if we're not in SELinux "enforcing" mode.
|
||||
require_selinux_enforcing_()
|
||||
{
|
||||
require_selinux_
|
||||
test "$(getenforce)" = Enforcing \
|
||||
|| skip_ "This test is useful only with SELinux in Enforcing mode."
|
||||
}
|
||||
@ -101,8 +123,9 @@ require_openat_support_()
|
||||
{
|
||||
# Skip this test if your system has neither the openat-style functions
|
||||
# nor /proc/self/fd support with which to emulate them.
|
||||
|
||||
test -z "$CONFIG_HEADER" \
|
||||
&& skip_ 'internal error: CONFIG_HEADER not defined'
|
||||
&& framework_failure_ 'CONFIG_HEADER not defined'
|
||||
|
||||
_skip=yes
|
||||
grep '^#define HAVE_OPENAT' "$CONFIG_HEADER" > /dev/null && _skip=no
|
||||
@ -299,23 +322,6 @@ skip_if_()
|
||||
esac
|
||||
}
|
||||
|
||||
require_selinux_()
|
||||
{
|
||||
# When in a chroot of an SELinux-enabled system, but with a mock-simulated
|
||||
# SELinux-*disabled* system, recognize that SELinux is disabled system wide:
|
||||
grep 'selinuxfs$' /proc/filesystems > /dev/null \
|
||||
|| skip_ "this system lacks SELinux support"
|
||||
|
||||
# Independent of whether SELinux is enabled system-wide,
|
||||
# the current file system may lack SELinux support.
|
||||
case $(ls -Zd .) in
|
||||
'? .'|'unlabeled .')
|
||||
skip_ "this system (or maybe just" \
|
||||
"the current file system) lacks SELinux support"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
very_expensive_()
|
||||
{
|
||||
if test "$RUN_VERY_EXPENSIVE_TESTS" != yes; then
|
||||
|
Loading…
Reference in New Issue
Block a user