[rhel7-branch][PATCH] Unlock encrypted partitions before finding installations (#1043783)

David Lehman dlehman at redhat.com
Mon Jan 20 17:50:43 UTC 2014


On Mon, 2014-01-20 at 13:55 +0100, Vratislav Podzimek wrote:
> On Fri, 2014-01-17 at 10:28 -0600, David Lehman wrote:
> > On Fri, 2014-01-17 at 15:33 +0100, Vratislav Podzimek wrote:
> > > Before trying to find existing installations, we should prompt user for
> > > passphrase to unlock encrypted paritions and try to unlock them.
> > > 
> > > (port of 4f7b135ade6ad4df40541050ddc9d3379d343f09 from master)
> > > 
> > > Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
> > > ---
> > >  pyanaconda/constants_text.py |  4 ++++
> > >  pyanaconda/rescue.py         | 53 +++++++++++++++++++++++++++++++++++++++++++-
> > >  2 files changed, 56 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/pyanaconda/constants_text.py b/pyanaconda/constants_text.py
> > > index b4b4861..cad7216 100644
> > > --- a/pyanaconda/constants_text.py
> > > +++ b/pyanaconda/constants_text.py
> > > @@ -40,6 +40,10 @@ TEXT_OK_STR = N_("OK")
> > >  TEXT_OK_CHECK  = "ok"
> > >  TEXT_OK_BUTTON = Translator(TEXT_OK_STR, TEXT_OK_CHECK)
> > >  
> > > +TEXT_CANCEL_STR = N_("Cancel")
> > > +TEXT_CANCEL_CHECK = "cancel"
> > > +TEXT_CANCEL_BUTTON = Translator(TEXT_CANCEL_STR, TEXT_CANCEL_CHECK)
> > > +
> > >  TEXT_YES_STR = N_("Yes")
> > >  TEXT_YES_CHECK = "yes"
> > >  TEXT_YES_BUTTON = Translator(TEXT_YES_STR, TEXT_YES_CHECK)
> > > diff --git a/pyanaconda/rescue.py b/pyanaconda/rescue.py
> > > index 788eb25..ff74f6b 100644
> > > --- a/pyanaconda/rescue.py
> > > +++ b/pyanaconda/rescue.py
> > > @@ -37,7 +37,23 @@ import time
> > >  import re
> > >  import network
> > >  import subprocess
> > > -from pykickstart.constants import *
> > > +
> > > +from snack import ButtonChoiceWindow, ListboxChoiceWindow,SnackScreen
> > > +
> > > +from constants import ANACONDA_CLEANUP, ROOT_PATH
> > > +from constants_text import TEXT_OK_BUTTON, TEXT_NO_BUTTON, TEXT_YES_BUTTON
> > > +from text import WaitWindow, OkCancelWindow, ProgressWindow, PassphraseEntryWindow
> > > +from flags import flags
> > > +from installinterfacebase import InstallInterfaceBase
> > > +from i18n import _
> > > +from kickstart import runPostScripts
> > > +
> > > +from blivet import mountExistingSystem
> > > +from blivet.errors import StorageError
> > > +from blivet.devices import LUKSDevice
> > > +
> > > +from pykickstart.constants import KS_REBOOT, KS_SHUTDOWN
> > > +
> > >  import meh.ui.text
> > >  from pyanaconda.i18n import _
> > >  
> > > @@ -214,6 +230,40 @@ def _exception_handler_wrapper(orig_except_handler, screen, *args):
> > >      screen.finish()
> > >      return orig_except_handler(*args)
> > >  
> > > +def _unlock_devices(intf, storage):
> > > +    try_passphrase = None
> > > +    for device in storage.devices:
> > > +        if device.format.type == "luks":
> > > +            skip = False
> > > +            unlocked = False
> > > +            while not (skip or unlocked):
> > > +                if try_passphrase is None:
> > > +                    passphrase = intf.passphraseEntryWindow(device.name)
> > > +                else:
> > > +                    passphrase = try_passphrase
> > > +
> > > +                if passphrase is None:
> > > +                    # canceled
> > > +                    skip = True
> > > +                else:
> > > +                    device.format.passphrase = passphrase
> > > +                    try:
> > > +                        device.setup()
> > 
> > It should be possible to go straight to devicetree.populate from here.
> > That's pretty much what we do from the custom storage spoke IIRC.
> Well, I'm not sure. I've just ported a patch from master and looking at
> the pyanaconda/ui/gui/spokes/custom.py the code for unlocking LUKSDevice
> looks pretty much the same as this one.

You're right. ACK.



More information about the anaconda-patches mailing list