From 61f7a66a5846d65387f885c6fe5f8c1ab2f7deda Mon Sep 17 00:00:00 2001 From: Rob Crittenden Date: Feb 27 2012 16:37:41 +0000 Subject: 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 --- diff --git a/ipapython/platform/redhat.py b/ipapython/platform/redhat.py index aee8bcc..bd79a53 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()