[Piuparts-commits] [piuparts] 03/07: p: use Chroot.mount() for selinux

Holger Levsen holger at moszumanska.debian.org
Mon Nov 2 17:19:00 UTC 2015


This is an automated email from the git hooks/post-receive script.

holger pushed a commit to branch develop
in repository piuparts.

commit 7134699ffc93ebd5514ec198b2e59e1520fc24c6
Author: Andreas Beckmann <anbe at debian.org>
Date:   Mon Nov 2 17:34:48 2015 +0100

    p: use Chroot.mount() for selinux
    
    Signed-off-by: Andreas Beckmann <anbe at debian.org>
---
 piuparts.py | 23 +++++------------------
 1 file changed, 5 insertions(+), 18 deletions(-)

diff --git a/piuparts.py b/piuparts.py
index 0b850ab..8f5fa0a 100644
--- a/piuparts.py
+++ b/piuparts.py
@@ -730,7 +730,6 @@ class Chroot:
 
         if not settings.schroot:
             self.mount_proc()
-            self.mount_selinux()
         self.configure_chroot()
 
         # Copy scripts dirs into the chroot, merging all dirs together,
@@ -767,8 +766,6 @@ class Chroot:
         if not settings.keep_tmpdir and os.path.exists(self.name):
             self.terminate_running_processes()
             self.unmount_all()
-            if not settings.schroot:
-                self.unmount_selinux()
             if settings.lvm_volume:
                 logging.debug('Unmounting and removing LVM snapshot %s' % self.lvm_snapshot_name)
                 run(['umount', self.name])
@@ -1527,26 +1524,14 @@ class Chroot:
 
             time.sleep(5)
 
-    def mount_selinux(self):
-        if selinux_enabled():
-            run(["mkdir", "-p", self.selinuxfs_relative_path()])
-            run(["mount", "--bind", "/sys/fs/selinux", self.selinuxfs_relative_path()])
-            run(["mount", "-o", "remount,ro,bind", self.selinuxfs_relative_path()])
-            logging.info("SElinux mounted into chroot")
-
-    def unmount_selinux(self):
-        if selinux_enabled():
-            run(["umount", self.selinuxfs_relative_path()])
-            logging.info("SElinux unmounted from chroot")
-
     # If /selinux is present, assume that this is the only supported
     # location by libselinux. Otherwise use the new location.
     # /selinux was shipped by the libselinux package until wheezy.
-    def selinuxfs_relative_path(self):
+    def selinuxfs_path(self):
         if os.path.isdir(self.relative('/selinux')):
-            return self.relative('/selinux')
+            return '/selinux'
         else:
-            return self.relative('/sys/fs/selinux')
+            return '/sys/fs/selinux'
 
     def mount(self, source, path, fstype=None, opts=None):
         """Mount something into the chroot and remember it for unmount_all()."""
@@ -1573,6 +1558,8 @@ class Chroot:
         if not os.path.lexists(etcmtab):
             os.symlink("../proc/mounts", etcmtab)
         self.mount("devpts", "/dev/pts", fstype="devpts")
+        if selinux_enabled():
+            self.mount("/sys/fs/selinux", self.selinuxfs_path(), opts="bind,ro")
 
     def is_ignored(self, pathname):
         """Is a file (or dir or whatever) to be ignored?"""

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/piuparts/piuparts.git



More information about the Piuparts-commits mailing list