FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Fedora User

 
 
LinkBack Thread Tools
 
Old 06-01-2012, 06:43 AM
Martin Gracik
 
Default Use selinux python module to get enforcing mode

No need to call getenforce via subprocess.
---
lorax.spec | 26 ++++++++++++++------------
src/pylorax/__init__.py | 12 ++++--------
2 files changed, 18 insertions(+), 20 deletions(-)

diff --git a/lorax.spec b/lorax.spec
index 02bdec4..e2c4c53 100644
--- a/lorax.spec
+++ b/lorax.spec
@@ -11,24 +11,26 @@ URL: http://git.fedorahosted.org/git/?p=lorax.git
Source0: https://fedorahosted.org/releases/l/o/%{name}/%{name}-%{version}.tar.gz

BuildRequires: python2-devel
-Requires: python-mako
-Requires: gawk
-Requires: glibc-common
+
+Requires: GConf2
Requires: cpio
-Requires: module-init-tools
Requires: device-mapper
-Requires: findutils
-Requires: GConf2
-Requires: isomd5sum
-Requires: glibc
-Requires: util-linux
Requires: dosfstools
+Requires: e2fsprogs
+Requires: findutils
+Requires: gawk
Requires: genisoimage
-Requires: parted
+Requires: glibc
+Requires: glibc-common
Requires: gzip
-Requires: xz
+Requires: isomd5sum
+Requires: libselinux-python
+Requires: module-init-tools
+Requires: parted
+Requires: python-mako
Requires: squashfs-tools >= 4.2
-Requires: e2fsprogs
+Requires: util-linux
+Requires: xz
Requires: yum

%ifarch %{ix86} x86_64
diff --git a/src/pylorax/__init__.py b/src/pylorax/__init__.py
index 147fdbd..9f0131b 100644
--- a/src/pylorax/__init__.py
+++ b/src/pylorax/__init__.py
@@ -36,6 +36,7 @@ import ConfigParser
import tempfile
import locale
import subprocess
+import selinux

from base import BaseLoraxClass, DataHolder
import output
@@ -170,14 +171,9 @@ class Lorax(BaseLoraxClass):

# is selinux disabled?
logger.info("checking the selinux mode")
- try:
- seoutput = subprocess.check_output("/sbin/getenforce").strip()
- except subprocess.CalledProcessError:
- logger.error("could not get the selinux mode")
- else:
- if seoutput == "Enforcing":
- logger.critical("selinux must be disabled or in Permissive mode")
- sys.exit(1)
+ if selinux.security_getenforce():
+ logger.critical("selinux must be disabled or in Permissive mode")
+ sys.exit(1)

# do we have a proper yum base object?
logger.info("checking yum base object")
--
1.7.9.5

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 

Thread Tools




All times are GMT. The time now is 02:30 PM.

VBulletin, Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2007 - 2008, www.linux-archive.org