From e763ad3451eecfb2c6c6724ac31e0a2f93d4b266 Mon Sep 17 00:00:00 2001 From: "Kali Kaneko (leap communications)" Date: Tue, 13 Dec 2016 03:31:56 +0100 Subject: [bug] fix the logout call if user attempts to logout before the incoming multiservice has an entry, there will be a KeyError raised on the MultiService.getServiceNamed() call, which is improperly reported as a confusing error message in the api return call. by catching the KeyError, we make sure that the logout call can terminate properly. --- src/leap/bitmask/core/mail_services.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/leap/bitmask/core/mail_services.py b/src/leap/bitmask/core/mail_services.py index ef333cc..bc85889 100644 --- a/src/leap/bitmask/core/mail_services.py +++ b/src/leap/bitmask/core/mail_services.py @@ -545,14 +545,18 @@ class StandardMailService(service.MultiService, HookableService): check_and_fix_urw_only(cert_path) def hook_on_bonafide_logout(self, **kw): - username = kw['username'] - multiservice = self.getServiceNamed('incoming_mail') - incoming = multiservice.getServiceNamed(username) - logger.debug( - 'looking for incoming mail service ' - 'for logout: %s' % username) - if incoming: - incoming.stopService() + username = kw.get('username', None) + if username: + multiservice = self.getServiceNamed('incoming_mail') + try: + incoming = multiservice.getServiceNamed(username) + except KeyError: + incoming = None + if incoming: + logger.debug( + 'looking for incoming mail service ' + 'for logout: %s' % username) + incoming.stopService() # commands @@ -709,6 +713,7 @@ class IncomingMailService(service.MultiService): # config utilities. should be moved to bonafide # + SERVICES = ('soledad', 'smtp', 'eip') -- cgit v1.2.3