[PATCH 16/16] Move handling of /proc/bus/usb and /selinux into storage.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 pyanaconda/livecd.py             |   22 ----------------------
 pyanaconda/rescue.py             |    6 ------
 pyanaconda/storage/__init__.py   |   27 ++++++++++++++++++++++++---
 pyanaconda/storage/formats/fs.py |   15 +++++++++++++++
 pyanaconda/yuminstall.py         |   25 -------------------------
 5 files changed, 39 insertions(+), 56 deletions(-)

diff --git a/pyanaconda/livecd.py b/pyanaconda/livecd.py
index 0f6dc3e..54fb7c3 100644
--- a/pyanaconda/livecd.py
+++ b/pyanaconda/livecd.py
@@ -148,19 +148,7 @@ class LiveCDCopyBackend(backend.AnacondaBackend):
     def _getLiveSizeMB(self):
         return self._getLiveSize() / 1048576
 
-    def _unmountNonFstabDirs(self, anaconda):
-        # unmount things that aren't listed in /etc/fstab.  *sigh*
-        dirs = []
-        if flags.selinux:
-            dirs.append("/selinux")
-        for dir in dirs:
-            try:
-                isys.umount("%s/%s" %(anaconda.rootPath,dir), removeDir = False)
-            except Exception, e:
-                log.error("unable to unmount %s: %s" %(dir, e))
-
     def postAction(self, anaconda):
-        self._unmountNonFstabDirs(anaconda)
         try:
             anaconda.storage.umountFilesystems(swapoff = False)
             os.rmdir(anaconda.rootPath)
@@ -168,9 +156,6 @@ class LiveCDCopyBackend(backend.AnacondaBackend):
             log.error("Unable to unmount filesystems: %s" % e) 
 
     def doPreInstall(self, anaconda):
-        if anaconda.dir == DISPATCH_BACK:
-            self._unmountNonFstabDirs(anaconda)
-            return
         anaconda.storage.umountFilesystems(swapoff = False)
 
     def doInstall(self, anaconda):
@@ -350,13 +335,6 @@ class LiveCDCopyBackend(backend.AnacondaBackend):
             os.chown(dest, st.st_uid, st.st_gid)
             os.chmod(dest, stat.S_IMODE(st.st_mode))
 
-        # ensure that non-fstab filesystems are mounted in the chroot
-        if flags.selinux:
-            try:
-                isys.mount("/selinux", anaconda.rootPath + "/selinux", "selinuxfs")
-            except Exception, e:
-                log.error("error mounting selinuxfs: %s" %(e,))
-
         wait.pop()
 
     def _resizeRootfs(self, anaconda, win = None):
diff --git a/pyanaconda/rescue.py b/pyanaconda/rescue.py
index aea3c94..ee023a0 100644
--- a/pyanaconda/rescue.py
+++ b/pyanaconda/rescue.py
@@ -415,12 +415,6 @@ def runRescue(anaconda):
 
                 # and /selinux too
                 if flags.selinux and os.path.isdir("%s/selinux" %(anaconda.rootPath,)):
-                    try:
-                        isys.mount("/selinux", "%s/selinux" %(anaconda.rootPath,),
-                                   "selinuxfs")
-                    except Exception, e:
-                        log.error("error mounting selinuxfs: %s" %(e,))
-
                     # we have to catch the possible exception
                     # because we support read-only mounting
                     try:
diff --git a/pyanaconda/storage/__init__.py b/pyanaconda/storage/__init__.py
index ae700c8..e815c20 100644
--- a/pyanaconda/storage/__init__.py
+++ b/pyanaconda/storage/__init__.py
@@ -1542,6 +1542,8 @@ class FSSet(object):
         self._sysfs = None
         self._proc = None
         self._devshm = None
+        self._usb = None
+        self._selinux = None
         self.preserveLines = []     # lines we just ignore and preserve
 
     @property
@@ -1588,6 +1590,22 @@ class FSSet(object):
         return self._devshm
 
     @property
+    def usb(self):
+        if not self._usb:
+            self._usb = NoDevice(format=getFormat("usbfs",
+                                                  device="usbfs",
+                                                  mountpoint="/proc/bus/usb"))
+        return self._usb
+
+    @property
+    def selinux(self):
+        if not self._selinux:
+            self._selinux = NoDevice(format=getFormat("selinuxfs",
+                                                      device="selinuxfs",
+                                                      mountpoint="/selinux"))
+        return self._selinux
+
+    @property
     def devices(self):
         return sorted(self.devicetree.devices, key=lambda d: d.path)
 
@@ -1637,7 +1655,8 @@ class FSSet(object):
             device.format = getFormat("bind",
                                       device=device.path,
                                       exists=True)
-        elif mountpoint in ("/proc", "/sys", "/dev/shm", "/dev/pts"):
+        elif mountpoint in ("/proc", "/sys", "/dev/shm", "/dev/pts",
+                            "/selinux", "/proc/bus/usb"):
             # drop these now -- we'll recreate later
             return None
         else:
@@ -1889,7 +1908,8 @@ class FSSet(object):
                          skipRoot=False):
         intf = anaconda.intf
         devices = self.mountpoints.values() + self.swapDevices
-        devices.extend([self.dev, self.devshm, self.devpts, self.sysfs, self.proc])
+        devices.extend([self.dev, self.devshm, self.devpts, self.sysfs,
+                        self.proc, self.selinux, self.usb])
         devices.sort(key=lambda d: getattr(d.format, "mountpoint", None))
 
         for device in devices:
@@ -2004,7 +2024,8 @@ class FSSet(object):
 
     def umountFilesystems(self, ignoreErrors=True, swapoff=True):
         devices = self.mountpoints.values() + self.swapDevices
-        devices.extend([self.dev, self.devshm, self.devpts, self.sysfs, self.proc])
+        devices.extend([self.dev, self.devshm, self.devpts, self.sysfs,
+                        self.proc, self.usb, self.selinux])
         devices.sort(key=lambda d: getattr(d.format, "mountpoint", None))
         devices.reverse()
         for device in devices:
diff --git a/pyanaconda/storage/formats/fs.py b/pyanaconda/storage/formats/fs.py
index 7887bd2..f055ce2 100644
--- a/pyanaconda/storage/formats/fs.py
+++ b/pyanaconda/storage/formats/fs.py
@@ -1480,3 +1480,18 @@ class BindFS(FS):
 register_device_format(BindFS)
 
 
+class SELinuxFS(NoDevFS):
+    _type = "selinuxfs"
+
+    @property
+    def mountable(self):
+        return flags.selinux and super(FS, self).mountable
+
+register_device_format(SELinuxFS)
+
+
+class USBFS(NoDevFS):
+    _type = "usbfs"
+
+register_device_format(USBFS)
+
diff --git a/pyanaconda/yuminstall.py b/pyanaconda/yuminstall.py
index 47a5762..5438d66 100644
--- a/pyanaconda/yuminstall.py
+++ b/pyanaconda/yuminstall.py
@@ -1535,14 +1535,6 @@ reposdir=/etc/anaconda.repos.d,/tmp/updates/anaconda.repos.d,/tmp/product/anacon
         self.ayum.dsCallback = None
 
     def doPreInstall(self, anaconda):
-        if anaconda.dir == DISPATCH_BACK:
-            for d in ("/selinux", "/dev", "/proc/bus/usb"):
-                try:
-                    isys.umount(anaconda.rootPath + d, removeDir = False)
-                except Exception, e:
-                    log.error("unable to unmount %s: %s" %(d, e))
-            return
-
         if anaconda.upgrade:
             # An old mtab can cause confusion (esp if loop devices are
             # in it).  Be extra special careful and delete any mtab first,
@@ -1574,23 +1566,6 @@ reposdir=/etc/anaconda.repos.d,/tmp/updates/anaconda.repos.d,/tmp/product/anacon
 
         self.initLog(anaconda.rootPath)
 
-        # SELinux hackery (#121369)
-        if flags.selinux:
-            try:
-                os.mkdir(anaconda.rootPath + "/selinux")
-            except Exception, e:
-                pass
-            try:
-                isys.mount("/selinux", anaconda.rootPath + "/selinux", "selinuxfs")
-            except Exception, e:
-                log.error("error mounting selinuxfs: %s" %(e,))
-
-        # For usbfs
-        try:
-            isys.mount("/proc/bus/usb", anaconda.rootPath + "/proc/bus/usb", "usbfs")
-        except Exception, e:
-            log.error("error mounting usbfs: %s" %(e,))
-
         # write out the fstab
         if not anaconda.upgrade:
             anaconda.storage.fsset.write(anaconda.rootPath)
-- 
1.7.3.2

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux