From 141a25801ca5396aa14e008f3066c8c07799def7 Mon Sep 17 00:00:00 2001 From: Martin Gracik Date: Tue, 29 May 2012 11:01:18 +0200 Subject: [PATCH] Check if selinux is not in Enforcing mode (#824835) Selinux causes problems for rpm scriptlets in the installroot. --- src/pylorax/__init__.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/pylorax/__init__.py b/src/pylorax/__init__.py index ac00857d..147fdbda 100644 --- a/src/pylorax/__init__.py +++ b/src/pylorax/__init__.py @@ -35,6 +35,7 @@ import os import ConfigParser import tempfile import locale +import subprocess from base import BaseLoraxClass, DataHolder import output @@ -167,6 +168,17 @@ class Lorax(BaseLoraxClass): logger.critical("no root privileges") sys.exit(1) + # 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) + # do we have a proper yum base object? logger.info("checking yum base object") if not isinstance(ybo, yum.YumBase):