monkeysphere: Fix handling of multiple domains and keys

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa 2019-02-07 13:54:29 -08:00 committed by James Valleroy
parent 722fa39c2a
commit 49640fdfce
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808
2 changed files with 6 additions and 6 deletions

View File

@ -21,6 +21,7 @@ Configuration helper for monkeysphere.
import argparse
import contextlib
import copy
import json
import os
import re
@ -138,7 +139,7 @@ def get_monkeysphere_keys(key_id=None):
# parse output
default_dict = {'imported_domains': [], 'available_domains': []}
keys = [default_dict.copy()]
keys = [copy.deepcopy(default_dict)]
lines = output.decode().strip().split('\n')
for line in lines:
if line.startswith('pub'):
@ -163,7 +164,7 @@ def get_monkeysphere_keys(key_id=None):
keys[-1]['ssh_fingerprint'] = data[1]
keys[-1]['ssh_key_type'] = data[2].strip('()')
elif line == '':
keys.append(default_dict.copy())
keys.append(copy.deepcopy(default_dict))
return {key['ssh_fingerprint']: key for key in keys}

View File

@ -50,13 +50,12 @@ def index(request):
@require_POST
def import_key(request, ssh_fingerprint):
"""Import a key into monkeysphere."""
available_domains = [
domain for domains in names.domains.values() for domain in domains
]
keys = get_keys()
available_domains = keys[ssh_fingerprint]['available_domains']
try:
actions.superuser_run(
'monkeysphere',
['host-import-key', ssh_fingerprint] + available_domains)
['host-import-key', ssh_fingerprint] + list(available_domains))
messages.success(request, _('Imported key.'))
except actions.ActionError as exception:
messages.error(request, str(exception))