[anaconda][f22-blocker] Catch libblockdev's CryptoError when trying to unlock LUKS

Vratislav Podzimek vpodzime at redhat.com
Thu Apr 30 11:22:59 UTC 2015


Otherwise we get a traceback instead of warning and another chance for the user.

Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
---
 pyanaconda/rescue.py               | 5 +++--
 pyanaconda/ui/gui/spokes/custom.py | 3 ++-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/pyanaconda/rescue.py b/pyanaconda/rescue.py
index b3c96b3..6fba78d 100644
--- a/pyanaconda/rescue.py
+++ b/pyanaconda/rescue.py
@@ -42,6 +42,7 @@ from blivet.devices import LUKSDevice
 from blivet.osinstall import storageInitialize, mountExistingSystem
 
 from pykickstart.constants import KS_REBOOT, KS_SHUTDOWN
+from gi.repository import BlockDev as blockdev
 
 import meh.ui.text
 
@@ -245,8 +246,8 @@ def _unlock_devices(intf, storage):
                         unlocked = True
                         # try to use the same passhprase for other devices
                         try_passphrase = passphrase
-                    except StorageError as serr:
-                        log.error("Failed to unlock %s: %s", device.name, serr)
+                    except (StorageError, blockdev.CryptoError) as err:
+                        log.error("Failed to unlock %s: %s", device.name, err)
                         device.teardown(recursive=True)
                         device.format.passphrase = None
                         try_passphrase = None
diff --git a/pyanaconda/ui/gui/spokes/custom.py b/pyanaconda/ui/gui/spokes/custom.py
index 19b376a..95e53a0 100644
--- a/pyanaconda/ui/gui/spokes/custom.py
+++ b/pyanaconda/ui/gui/spokes/custom.py
@@ -88,6 +88,7 @@ from pyanaconda.ui.gui.utils import really_hide, really_show, timed_action
 from pyanaconda.ui.categories.system import SystemCategory
 
 from gi.repository import Gdk, Gtk
+from gi.repository import BlockDev as blockdev
 from gi.repository.AnacondaWidgets import MountpointSelector
 
 from functools import wraps
@@ -2653,7 +2654,7 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
         try:
             device.setup()
             device.format.setup()
-        except StorageError as e:
+        except (StorageError, blockdev.CryptoError) as e:
             log.error("failed to unlock %s: %s", device.name, e)
             device.teardown(recursive=True)
             self._error = e
-- 
2.1.0



More information about the anaconda-patches mailing list