summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Lehman <dlehman@redhat.com>2010-11-24 17:04:50 -0600
committerDavid Lehman <dlehman@redhat.com>2010-12-02 12:29:56 -0600
commitae30136b9a1b8657d724e5abf56736ef201ecaf4 (patch)
tree7d5b009adf6aa02012301a594825001248b1e403
parent25d00dcb02166121432c771cb3fd904f49076e4b (diff)
downloadanaconda-ae30136b9a1b8657d724e5abf56736ef201ecaf4.tar.gz
anaconda-ae30136b9a1b8657d724e5abf56736ef201ecaf4.tar.xz
anaconda-ae30136b9a1b8657d724e5abf56736ef201ecaf4.zip
Move handling of /proc/bus/usb and /selinux into storage.
-rw-r--r--pyanaconda/livecd.py22
-rw-r--r--pyanaconda/rescue.py6
-rw-r--r--pyanaconda/storage/__init__.py27
-rw-r--r--pyanaconda/storage/formats/fs.py15
-rw-r--r--pyanaconda/yuminstall.py25
5 files changed, 39 insertions, 56 deletions
diff --git a/pyanaconda/livecd.py b/pyanaconda/livecd.py
index 0f6dc3ecc..54fb7c3ed 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 aea3c94c6..ee023a03a 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 ae700c8c2..e815c2026 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 7887bd207..f055ce2b3 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 e0107e342..5b5ca0394 100644
--- a/pyanaconda/yuminstall.py
+++ b/pyanaconda/yuminstall.py
@@ -1541,14 +1541,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,
@@ -1580,23 +1572,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)