[PATCH 3/3] Add cleanup-only mode to DeviceTree.populate.

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

 



Cleanup-only mode doesn't need passphrases for active LUKS devices
since it is only going to deactivate them.
---
 pyanaconda/storage/devicetree.py |   23 +++++++++++++++++++----
 scripts/anaconda-image-cleanup   |    2 +-
 2 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/pyanaconda/storage/devicetree.py b/pyanaconda/storage/devicetree.py
index 6b6b3e1..214f577 100644
--- a/pyanaconda/storage/devicetree.py
+++ b/pyanaconda/storage/devicetree.py
@@ -197,6 +197,8 @@ class DeviceTree(object):
             self.addIgnoredDisk(disk)
         devicelibs.lvm.lvm_cc_resetFilter()
 
+        self._cleanup = False
+
     def addIgnoredDisk(self, disk):
         self._ignoredDisks.append(disk)
         devicelibs.lvm.lvm_cc_addFilterRejectRegexp(disk)
@@ -1073,11 +1075,21 @@ class DeviceTree(object):
             if passphrase:
                 device.format.passphrase = passphrase
             else:
-                (passphrase, isglobal) = getLUKSPassphrase(self.intf,
+                try:
+                    (passphrase, isglobal) = getLUKSPassphrase(self.intf,
                                                     device,
                                                     self.__passphrase)
-                if isglobal and device.format.status:
-                    self.__passphrase = passphrase
+                except RuntimeError as e:
+                    # if we're only building the devicetree so that we can
+                    # tear down all of the devices we don't need a passphrase
+                    if device.format.status and self._cleanup:
+                        # this makes device.configured return True
+                        device.format.passphrase = 'yabbadabbadoo'
+                    else:
+                        raise
+                else:
+                    if isglobal and device.format.status:
+                        self.__passphrase = passphrase
 
             luks_device = LUKSDevice(device.format.mapName,
                                      parents=[device],
@@ -1643,9 +1655,12 @@ class DeviceTree(object):
     def restoreConfigs(self):
         self.backupConfigs(restore=True)
 
-    def populate(self):
+    def populate(self, cleanupOnly=False):
         """ Locate all storage devices. """
         self.backupConfigs()
+        if cleanupOnly:
+            self._cleanup = True
+
         try:
             self._populate()
         except Exception:
diff --git a/scripts/anaconda-image-cleanup b/scripts/anaconda-image-cleanup
index 00f2c82..366d8d2 100755
--- a/scripts/anaconda-image-cleanup
+++ b/scripts/anaconda-image-cleanup
@@ -48,7 +48,7 @@ os.system("udevadm control --env=ANACONDA=1")
 os.system("udevadm trigger --subsystem-match block")
 os.system("udevadm settle")
 devicetree = DeviceTree(intf=intf, conf=storage_config)
-devicetree.populate()
+devicetree.populate(cleanupOnly=True)
 devicetree.teardownAll()
 for name in devicetree.diskImages.keys():
     device = devicetree.getDeviceByName(name)
-- 
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