storage: fix crash when editing encrypted VG created in guided storage
When editing an encrypted VG that was created in the guided storage screen, the VG information is originating from the server. However, the server does not send the LUKS key over the wire. Instead it sends the path to a keyfile which contains the key. The client may or may not have read access to this keyfile so it does not have a reliable way to determine the key. This causes problem when editing the VG because the GUI expects to receive a key when encryption is enabled. If the VG object only contains a keyfile, the passphrase is set to None and this result in the GUI crashing. This patch fixes the crash by passing an empty passphrase instead of a None value when the VG object only contains a keyfile. This means the user gets forced to supply a passphrase again when editing an encrypted VG that was created in the guided partition screen. Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
This commit is contained in:
parent
9563b543ce
commit
dcc66fa346
|
@ -157,15 +157,27 @@ class VolGroupStretchy(Stretchy):
|
|||
label = _('Save')
|
||||
devices = {}
|
||||
key = ""
|
||||
encrypt = False
|
||||
for d in existing.devices:
|
||||
if d.type == "dm_crypt":
|
||||
key = d.key
|
||||
encrypt = True
|
||||
# If the DM_Crypt object was created using information
|
||||
# sent by the server (this happens when the passphrase was
|
||||
# provided in the Guided Storage screen), it will not
|
||||
# contain a key but a path to a keyfile (d.keyfile). The
|
||||
# client may not have permission to read the keyfile so it
|
||||
# seems simpler to just present an empty passphrase field
|
||||
# and ask the user to fill the passphrase again if they
|
||||
# want to make adjustments to the VG.
|
||||
# TODO make this more user friendly.
|
||||
if d.key is not None:
|
||||
key = d.key
|
||||
d = d.volume
|
||||
devices[d] = 'active'
|
||||
initial = {
|
||||
'devices': devices,
|
||||
'name': existing.name,
|
||||
'encrypt': bool(key),
|
||||
'encrypt': encrypt,
|
||||
'passphrase': key,
|
||||
'confirm_passphrase': key,
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue