When selinux is completely disabled functions like restorecon raise

exceptions, causing nasty things to happen on instances that boot with
selinux=0.  The fix is easy: simply consult is_selinux_enabled() first.
This commit is contained in:
Garrett Holmstrom
2013-09-20 16:34:41 -07:00
parent d44df6fd27
commit f93d20fe54

View File

@@ -161,13 +161,13 @@ class SeLinuxGuard(object):
self.recursive = recursive
def __enter__(self):
if self.selinux:
if self.selinux and self.selinux.is_selinux_enabled():
return True
else:
return False
def __exit__(self, excp_type, excp_value, excp_traceback):
if self.selinux:
if self.selinux and self.selinux.is_selinux_enabled():
path = os.path.realpath(os.path.expanduser(self.path))
do_restore = False
try: