Hi,

Any objections to the attached mock patch?
From 093819bc048ec14f47be4cd4c2311305733a593a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ville=20Skytt=C3=A4?= <[email protected]>
Date: Sun, 25 Apr 2010 21:59:13 +0300
Subject: [PATCH] Check SELinux state from /selinux/enforce instead of /usr/sbin/getenforce.

Cleans up an error message when getenforce is not installed, and fixes wrong
outcome from selinuxEnabled() when SELinux is additionally disabled.
---
 py/mock/util.py |   11 ++++-------
 1 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/py/mock/util.py b/py/mock/util.py
index 3322cd5..c4f5850 100644
--- a/py/mock/util.py
+++ b/py/mock/util.py
@@ -263,14 +263,11 @@ def logOutput(fds, logger, returnOutput=1, start=0, timeout=0):
 
 decorate(traceLog())
 def selinuxEnabled():
-    p = subprocess.Popen(["/usr/sbin/getenforce"], 
-                         shell=True, 
-                         stdout=subprocess.PIPE, 
-                         close_fds=True)
-    p.wait()
-    if p.stdout.read().strip() == "Disabled":
+    """Check if SELinux is enabled (enforcing or permissive)."""
+    try:
+        return open("/selinux/enforce").read().strip() in ("1", "0")
+    except:
         return False
-    return True
 
 # logger =
 # output = [1|0]
-- 
1.7.0.1

--
buildsys mailing list
[email protected]
https://admin.fedoraproject.org/mailman/listinfo/buildsys

Reply via email to