summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRob Crittenden <rcritten@redhat.com>2012-02-22 23:01:17 -0500
committerMartin Kosek <mkosek@redhat.com>2012-02-27 17:37:08 +0100
commite9ed7f7ca1948c1eded115f215b914987b79cea7 (patch)
treeb3f7a8188dc9c2b3343382a60a57754ca7ec73b0
parent306bdccfa4ef02d72bbd4103ad413bd4ed024177 (diff)
Don't run restorecon if SELinux is disabled or not present.
Also check for the existence of restorecon. This may be overkill but it will prevent a client installation from failing for no good reason. https://fedorahosted.org/freeipa/ticket/2368
-rw-r--r--ipapython/platform/redhat.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/ipapython/platform/redhat.py b/ipapython/platform/redhat.py
index aee8bcc3d..bd79a5312 100644
--- a/ipapython/platform/redhat.py
+++ b/ipapython/platform/redhat.py
@@ -140,7 +140,18 @@ def restore_context(filepath):
ipautil.run() will do the logging.
"""
- ipautil.run(["/sbin/restorecon", filepath], raiseonerr=False)
+ try:
+ if (os.path.exists('/usr/sbin/selinuxenabled')):
+ ipautil.run(["/usr/sbin/selinuxenabled"])
+ else:
+ # No selinuxenabled, no SELinux
+ return
+ except ipautil.CalledProcessError:
+ # selinuxenabled returns 1 if not enabled
+ return
+
+ if (os.path.exists('/sbin/restorecon')):
+ ipautil.run(["/sbin/restorecon", filepath], raiseonerr=False)
def backup_and_replace_hostname(fstore, statestore, hostname):
old_hostname = socket.gethostname()