GNU bug report logs -
#8359
[PATCH] Unit tests: Properly detect whether SELinux is enabled or not.
Previous Next
Full log
View this message in rfc822 format
The unit tests would run ls to see if the files had an SELinux
context, and would assume SELinux is enabled if they did.
This is not ideal, and can cause test failures in some environments:
https://bugzilla.redhat.com/show_bug.cgi?id=573111#c26
The problem in the case of the above bug report is that the host has
SELinux enabled (and thus files have a context) but the chroot (mock)
fakes SELinux being disabled. Unfortunately, it can't remove the
context, which makes ls thinks that SELinux is enabled.
Later on, when running certain unit tests (e.g id-context), they fail
as they use the libselinux which (correctly) thinks SELinux is disabled
(and in the case of id-context, id will not return the context of the
user).
A better way to test if SELinux is enabled is to search for the SELinux
filesystem (see the above bug report). This is what this commit does.
---
tests/init.cfg | 9 +++------
1 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/tests/init.cfg b/tests/init.cfg
index f74d50c..ca92297 100644
--- a/tests/init.cfg
+++ b/tests/init.cfg
@@ -216,12 +216,9 @@ skip_if_()
require_selinux_()
{
- case `ls -Zd .` in
- '? .'|'unlabeled .')
- skip_test_ "this system (or maybe just" \
- "the current file system) lacks SELinux support"
- ;;
- esac
+ grep selinux /proc/filesystems > /dev/null || \
+ skip_test_ "this system (or maybe just" \
+ "the current file system) lacks SELinux support"
}
very_expensive_()
--
1.7.4
This bug report was last modified 14 years and 64 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.