diff options
author | David Lehman <dlehman@redhat.com> | 2009-12-06 17:22:00 -0500 |
---|---|---|
committer | David Lehman <dlehman@redhat.com> | 2009-12-08 08:28:17 -0600 |
commit | 23389d0c7679ae5200823ca72c64143763ad874e (patch) | |
tree | a14e1707664afd992104aead40bb325d3bf9512c /isys | |
parent | 383ffbbb871470d403585289c20ad902b2137e8d (diff) | |
download | anaconda-23389d0c7679ae5200823ca72c64143763ad874e.tar.gz anaconda-23389d0c7679ae5200823ca72c64143763ad874e.tar.xz anaconda-23389d0c7679ae5200823ca72c64143763ad874e.zip |
Use selinux python module for file context operations.
Diffstat (limited to 'isys')
-rwxr-xr-x | isys/isys.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/isys/isys.py b/isys/isys.py index 44c380baf..8d8f85d55 100755 --- a/isys/isys.py +++ b/isys/isys.py @@ -37,6 +37,7 @@ import re import struct import block import dbus +import selinux import logging log = logging.getLogger("anaconda") @@ -605,15 +606,21 @@ def getIPAddress(dev): ## Get the correct context for a file from loaded policy. # @param fn The filename to query. def matchPathContext(fn): - return _isys.matchPathContext(fn) + con = None + try: + con = selinux.matchpathcon(os.path.normpath(fn), 0)[1] + except OSError: + log.info("failed to get default SELinux context for %s" % f) + return con ## Set the SELinux file context of a file # @param fn The filename to fix. # @param con The context to use. # @param instroot An optional root filesystem to look under for fn. def setFileContext(fn, con, instroot = '/'): - if con is not None and os.access("%s/%s" % (instroot, fn), os.F_OK): - return (_isys.setFileContext(fn, con, instroot) != 0) + full_path = os.path.normpath("%s/%s" % (instroot, fn)) + if con is not None and os.access(full_path, os.F_OK): + return (selinux.lsetfilecon(full_path, con) != 0) return False ## Restore the SELinux file context of a file to its default. |