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
This commit is contained in:
Rob Crittenden authored and Martin Kosek committed 2012-02-27 17:37:08 +01:00
1 parent 306bdccfa4
commit e9ed7f7ca1
1 file changed
+12 -1
+12 -1
View File
@@ -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()