summaryrefslogtreecommitdiff
path: root/src/leap/bitmask
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap/bitmask')
-rw-r--r--src/leap/bitmask/cli/keys.py11
-rw-r--r--src/leap/bitmask/core/dispatcher.py10
-rw-r--r--src/leap/bitmask/core/mail_services.py4
3 files changed, 18 insertions, 7 deletions
diff --git a/src/leap/bitmask/cli/keys.py b/src/leap/bitmask/cli/keys.py
index 0412efe3..12191a5d 100644
--- a/src/leap/bitmask/cli/keys.py
+++ b/src/leap/bitmask/cli/keys.py
@@ -70,6 +70,9 @@ SUBCOMMANDS:
help='Select the userid of the keyring')
parser.add_argument('--private', action='store_true',
help='Use private keys (by default uses public)')
+ parser.add_argument('--fetch', action='store_true',
+ help='Try to fetch remotely the key if it is not '
+ 'in the local storage')
parser.add_argument('address', nargs=1,
help='email address of the key')
subargs = parser.parse_args(raw_args)
@@ -78,10 +81,14 @@ SUBCOMMANDS:
if not userid:
userid = self.cfg.get('bonafide', 'active', default='')
self.data += ['export', userid, subargs.address[0]]
+
+ if subargs.private and subargs.fetch:
+ print('Cannot fetch private keys')
+ return
if subargs.private:
self.data += ['private']
- else:
- self.data += ['public']
+ if subargs.fetch:
+ self.data += ['fetch']
return self._send(self._print_key)
diff --git a/src/leap/bitmask/core/dispatcher.py b/src/leap/bitmask/core/dispatcher.py
index e0cc1297..3d6f6704 100644
--- a/src/leap/bitmask/core/dispatcher.py
+++ b/src/leap/bitmask/core/dispatcher.py
@@ -315,10 +315,14 @@ class KeysCmd(SubCommand):
address = parts[3]
private = False
- if parts[-1] == 'private':
- private = True
+ fetch_remote = False
+ if len(parts) > 4:
+ if parts[4] == 'private':
+ private = True
+ elif parts[4] == 'fetch':
+ fetch_remote = True
- return service.do_export(uid, address, private)
+ return service.do_export(uid, address, private, fetch_remote)
@register_method('dict')
def do_INSERT(self, service, *parts, **kw):
diff --git a/src/leap/bitmask/core/mail_services.py b/src/leap/bitmask/core/mail_services.py
index a0238279..48528d8d 100644
--- a/src/leap/bitmask/core/mail_services.py
+++ b/src/leap/bitmask/core/mail_services.py
@@ -397,13 +397,13 @@ class KeymanagerService(HookableService):
d.addCallback(lambda keys: [dict(key) for key in keys])
return d
- def do_export(self, userid, address, private=False):
+ def do_export(self, userid, address, private=False, fetch_remote=False):
km = self._container.get_instance(userid)
if km is None:
return defer.fail(ValueError("User " + userid + " has no active "
"keymanager"))
- d = km.get_key(address, private=private, fetch_remote=False)
+ d = km.get_key(address, private=private, fetch_remote=fetch_remote)
d.addCallback(lambda key: dict(key))
return d