[blivet:rhel7/master 3/3] Look up SELinux context for lost+found where it is needed (#1038146)
mulhern
amulhern at redhat.com
Mon Jan 20 18:16:27 UTC 2014
Resolves: rhbz#1038146
Previously the context for lost and found was set at module import as a module
level file, but it was only used when mounting a filesystem. Now, it is set
where it is used and the lookup uses a little method in util.py instead of the
raw selinux method.
Signed-off-by: mulhern <amulhern at redhat.com>
---
blivet/formats/fs.py | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/blivet/formats/fs.py b/blivet/formats/fs.py
index 43a1548..3b30440 100644
--- a/blivet/formats/fs.py
+++ b/blivet/formats/fs.py
@@ -44,11 +44,6 @@ log = logging.getLogger("blivet")
import gettext
_ = lambda x: gettext.ldgettext("blivet", x)
-try:
- lost_and_found_context = selinux.matchpathcon("/lost+found", 0)[1]
-except OSError:
- lost_and_found_context = None
-
# these are for converting to/from SI for ntfsresize
mb = 1000 * 1000.0
mib = 1024 * 1024.0
@@ -573,10 +568,12 @@ class FS(DeviceFormat):
if flags.selinux and "ro" not in options.split(","):
ret = util.reset_file_context(mountpoint, chroot)
- log.info("set SELinux context for newly mounted filesystem "
- "root at %s to %s" %(mountpoint, ret))
- util.set_file_context("%s/lost+found" % mountpoint,
- lost_and_found_context, chroot)
+ log.info("set SELinux context for newly mounted filesystem root at %s to %s", mountpoint, ret)
+ lost_and_found_context = util.match_path_context("/lost+found")
+ lost_and_found_path = os.path.join(mountpoint, "lost+found")
+ ret = util.set_file_context(lost_and_found_path,
+ lost_and_found_context, chroot)
+ log.info("set SELinux context for newly mounted filesystem lost+found directory at %s to %s", lost_and_found_path, lost_and_found_context)
self._mountpoint = chrootedMountpoint
--
1.8.3.1
More information about the anaconda-patches
mailing list