bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#8359: [PATCH] Unit tests: Properly detect whether SELinux is enabled


From: Mathieu Bridon
Subject: bug#8359: [PATCH] Unit tests: Properly detect whether SELinux is enabled or not.
Date: Mon, 28 Mar 2011 11:45:43 +0800

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







reply via email to

[Prev in Thread] Current Thread [Next in Thread]