From 4e8e1d4d907bd597e5783a0aca7a9799e3ea03ec Mon Sep 17 00:00:00 2001 From: Luke Macken Date: Fri, 5 Jun 2015 10:19:39 -0400 Subject: [PATCH] Use libselinux-python instead of subprocess --- bin/pungi | 15 +++++---------- pungi.spec | 1 + 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/bin/pungi b/bin/pungi index e2c4a94d..09af658b 100755 --- a/bin/pungi +++ b/bin/pungi @@ -16,7 +16,7 @@ import os import pungi.gather import pungi.config import pungi.ks -import subprocess +import selinux def main(): @@ -30,15 +30,10 @@ def main(): return 1 if opts.do_all or opts.do_buildinstall: - try: - selinux = subprocess.Popen('/usr/sbin/getenforce', - stdout=subprocess.PIPE, - stderr=open('/dev/null', 'w')).communicate()[0].strip('\n') - if selinux == 'Enforcing': - print >> sys.stdout, "WARNING: SELinux is enforcing. This may lead to a compose with selinux disabled." - print >> sys.stdout, "Consider running with setenforce 0." - except: - pass + enforcing = selinux.security_getenforce() + if enforcing: + print >> sys.stdout, "WARNING: SELinux is enforcing. This may lead to a compose with selinux disabled." + print >> sys.stdout, "Consider running with setenforce 0." # Set up the kickstart parser and pass in the kickstart file we were handed ksparser = pungi.ks.get_ksparser(ks_path=opts.config) diff --git a/pungi.spec b/pungi.spec index f38b7c56..c108ebea 100644 --- a/pungi.spec +++ b/pungi.spec @@ -15,6 +15,7 @@ Requires: python-lockfile Requires: kobo Requires: python-productmd Requires: python-kickstart +Requires: libselinux-python BuildArch: noarch