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 /storage/formats/fs.py | |
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 'storage/formats/fs.py')
-rw-r--r-- | storage/formats/fs.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/storage/formats/fs.py b/storage/formats/fs.py index 2ca436a70..587edecc7 100644 --- a/storage/formats/fs.py +++ b/storage/formats/fs.py @@ -30,6 +30,7 @@ import math import os import tempfile +import selinux import isys from ..errors import * @@ -45,6 +46,10 @@ log = logging.getLogger("storage") import gettext _ = lambda x: gettext.ldgettext("anaconda", x) +try: + lost_and_found_context = selinux.matchpathcon("/lost+found", 0)[1] +except OSError: + lost_and_found_context = None fs_configs = {} @@ -119,7 +124,6 @@ class FS(DeviceFormat): _defaultInfoOptions = [] _migrationTarget = None _existingSizeFields = [] - lostAndFoundContext = None def __init__(self, *args, **kwargs): """ Create a FS instance. @@ -602,10 +606,8 @@ class FS(DeviceFormat): ret = isys.resetFileContext(mountpoint, chroot) log.info("set SELinux context for newly mounted filesystem " "root at %s to %s" %(mountpoint, ret)) - if self.lostAndFoundContext is None: - self.lostAndFoundContext = isys.matchPathContext("/lost+found") isys.setFileContext("%s/lost+found" % mountpoint, - self.lostAndFoundContext, chroot) + lost_and_found_context, chroot) self._mountpoint = chrootedMountpoint |