[PATCH 1/2] getLUKSPassphrase is no longer used, so kill it.
Chris Lumens
clumens at redhat.com
Wed Jan 9 22:02:10 UTC 2013
---
pyanaconda/cmdline.py | 5 ---
pyanaconda/storage/devicetree.py | 80 -----------------------------------
tests/pyanaconda_test/cmdline_test.py | 7 ---
3 files changed, 92 deletions(-)
diff --git a/pyanaconda/cmdline.py b/pyanaconda/cmdline.py
index 7c11ccf..310ec38 100644
--- a/pyanaconda/cmdline.py
+++ b/pyanaconda/cmdline.py
@@ -127,11 +127,6 @@ class InstallInterface(InstallInterfaceBase):
errtxt += "\n(passphraseEntryWindow: '%s')" % (device,)
raise RuntimeError(errtxt)
- def getLUKSPassphrase(self, passphrase = "", isglobal = False):
- errtxt = _("Can't have a question in command line mode!")
- errtxt += "\n(getLUKSPassphrase)"
- raise RuntimeError(errtxt)
-
def enableNetwork(self):
errtxt = "(enableNetwork)\n"
errtxt += _("Can't have a question in command line mode!")
diff --git a/pyanaconda/storage/devicetree.py b/pyanaconda/storage/devicetree.py
index 9d902aa..e1ff351 100644
--- a/pyanaconda/storage/devicetree.py
+++ b/pyanaconda/storage/devicetree.py
@@ -54,86 +54,6 @@ _ = lambda x: gettext.ldgettext("anaconda", x)
import logging
log = logging.getLogger("storage")
-def getLUKSPassphrase(intf, device, passphrases):
- """ Obtain a passphrase for a LUKS encrypted block device.
-
- The format's mapping name must already be set and the backing
- device must already be set up before calling this function.
-
- If successful, this function leaves the device mapped.
-
- Return value is the passphrase string, if obtained
-
- Either or both can be None, depending on the outcome.
- """
- if device.format.type != "luks":
- # this function only works on luks devices
- raise ValueError("not a luks device")
-
- if not device.status:
- # the device should have already been set up
- raise RuntimeError("device is not set up")
-
- if device.format.status:
- # the device is already mapped
- raise RuntimeError("device is already mapped")
-
- if not device.format.configured and passphrases:
- for passphrase in passphrases:
- device.format.passphrase = passphrase
-
- try:
- device.format.setup()
- except CryptoError as e:
- device.format.passphrase = None
- else:
- # we've opened the device so we're done.
- return passphrase
-
- if not intf:
- return None
-
- buttons = [_("Back"), _("Continue")]
- passphrase_incorrect = False
- while True:
- if passphrase_incorrect:
- # TODO: add a flag to passphraseEntryWindow to say the last
- # passphrase was incorrect so try again
- passphrase_incorrect = False
- passphrase = intf.passphraseEntryWindow(device.name)
- if not passphrase:
- rc = intf.messageWindow(_("Confirm"),
- _("Are you sure you want to skip "
- "entering a passphrase for device "
- "%s?\n\n"
- "If you skip this step the "
- "device's contents will not "
- "be available during "
- "installation.") % device.name,
- type = "custom",
- default = 0,
- custom_buttons = buttons)
- if rc == 0:
- continue
- else:
- passphrase = None
- log.info("skipping passphrase for %s" % (device.name,))
- break
-
- device.format.passphrase = passphrase
-
- try:
- device.format.setup()
- except CryptoError as e:
- device.format.passphrase = None
- passphrase_incorrect = True
- else:
- # we've opened the device so we're done.
- break
-
- return passphrase
-
-
class DeviceTree(object):
""" A quasi-tree that represents the devices in the system.
diff --git a/tests/pyanaconda_test/cmdline_test.py b/tests/pyanaconda_test/cmdline_test.py
index e6a0a33..17cb16a 100644
--- a/tests/pyanaconda_test/cmdline_test.py
+++ b/tests/pyanaconda_test/cmdline_test.py
@@ -134,13 +134,6 @@ class CmdLineTest(mock.TestCase):
self.assertRaises(Exception, intf.passphraseEntryWindow, DEVICE)
sys.stdout.close()
self.assertTrue(DEVICE in self.fs[self.TMP_STDOUT])
-
- def installinterface_getlukspassphrase_test(self):
- import pyanaconda.cmdline
- pyanaconda.cmdline.time.sleep = mock.Mock(side_effect=Exception)
-
- intf = pyanaconda.cmdline.InstallInterface()
- self.assertRaises(Exception, intf.getLUKSPassphrase, 'foo')
def installinterface_enablenetwork_test(self):
import pyanaconda.cmdline
--
1.7.11.2
More information about the anaconda-patches
mailing list