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 2012-02-22 23:01:17 -05:00 committed by Martin Kosek
parent 306bdccfa4
commit e9ed7f7ca1

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()