summaryrefslogtreecommitdiffstats
path: root/isys
diff options
context:
space:
mode:
authorDavid Lehman <dlehman@redhat.com>2009-12-15 12:22:19 -0600
committerDavid Lehman <dlehman@redhat.com>2009-12-15 12:22:19 -0600
commit87ffa930ad974e0c6e4deda01900702f265f79c9 (patch)
tree3c90cde57dfb4e04c0100bb51b8e2f97269dbfba /isys
parent0c7f73efe7d3280e637a50ce3f5e29def5c39957 (diff)
downloadanaconda-87ffa930ad974e0c6e4deda01900702f265f79c9.tar.gz
anaconda-87ffa930ad974e0c6e4deda01900702f265f79c9.tar.xz
anaconda-87ffa930ad974e0c6e4deda01900702f265f79c9.zip
Catch failures to set selinux contexts so it doesn't cause a crash.
Diffstat (limited to 'isys')
-rwxr-xr-xisys/isys.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/isys/isys.py b/isys/isys.py
index 14d2a5d9d..9341c6bd4 100755
--- a/isys/isys.py
+++ b/isys/isys.py
@@ -612,9 +612,13 @@ def matchPathContext(fn):
# @param instroot An optional root filesystem to look under for fn.
def setFileContext(fn, con, instroot = '/'):
full_path = os.path.normpath("%s/%s" % (instroot, fn))
+ rc = False
if con is not None and os.access(full_path, os.F_OK):
- return (selinux.lsetfilecon(full_path, con) != 0)
- return False
+ try:
+ rc = (selinux.lsetfilecon(full_path, con) == 0)
+ except OSError:
+ log.info("failed to set SELinux context for %s" % full_path)
+ return rc
## Restore the SELinux file context of a file to its default.
# @param fn The filename to fix.