diff options
author | drebs <drebs@riseup.net> | 2016-09-27 22:04:41 -0300 |
---|---|---|
committer | drebs <drebs@riseup.net> | 2016-10-03 12:01:29 -0300 |
commit | 10330b390de4dfaf72853ecb4454bf4142415add (patch) | |
tree | 59c8079d983f7442897c39c14e51ac7272d79baa /src/leap/bitmask/core | |
parent | 9c4bf6adf42f0f9553ae11f24ffeb6f7cf39f374 (diff) |
[bug] stop syncing after logout (#8479)
Diffstat (limited to 'src/leap/bitmask/core')
-rw-r--r-- | src/leap/bitmask/core/mail_services.py | 20 | ||||
-rw-r--r-- | src/leap/bitmask/core/service.py | 5 |
2 files changed, 21 insertions, 4 deletions
diff --git a/src/leap/bitmask/core/mail_services.py b/src/leap/bitmask/core/mail_services.py index d2967f8..f971c1a 100644 --- a/src/leap/bitmask/core/mail_services.py +++ b/src/leap/bitmask/core/mail_services.py @@ -435,8 +435,6 @@ class StandardMailService(service.MultiService, HookableService): # TODO factor out Mail Service to inside mail package. - subscribed_to_hooks = ('on_new_keymanager_instance',) - def __init__(self, basedir): self._basedir = basedir self._soledad_sessions = {} @@ -502,12 +500,22 @@ class StandardMailService(service.MultiService, HookableService): def hook_on_bonafide_auth(self, **kw): # TODO: if it's expired we should renew it userid = kw['username'] + + # turn on incoming mail service for the user that just logged in + multiservice = self.getServiceNamed('incoming_mail') + incoming = multiservice.getServiceNamed(userid) + log.msg('looking for incoming mail service for auth: %s' % userid) + if incoming: + incoming.startService() + + # check if smtp cert exists username, provider = userid.split('@') cert_path = _get_smtp_client_cert_path(self._basedir, provider, username) if os.path.exists(cert_path): return + # fetch smtp cert and store bonafide = self.parent.getServiceNamed("bonafide") _, cert_str = yield bonafide.do_get_smtp_cert(userid) @@ -518,6 +526,14 @@ class StandardMailService(service.MultiService, HookableService): outf.write(cert_str) 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) + log.msg('looking for incoming mail service for logout: %s' % username) + if incoming: + incoming.stopService() + # commands def do_status(self): diff --git a/src/leap/bitmask/core/service.py b/src/leap/bitmask/core/service.py index de99ea5..1a544ac 100644 --- a/src/leap/bitmask/core/service.py +++ b/src/leap/bitmask/core/service.py @@ -89,6 +89,7 @@ class BitmaskBackend(configurable.ConfigurableService): bf.register_hook('on_passphrase_change', listener='soledad') bf.register_hook('on_bonafide_auth', listener='keymanager') bf.register_hook('on_bonafide_auth', listener='mail') + bf.register_hook('on_bonafide_logout', listener='mail') def _start_child_service(self, name): log.msg('starting backend child service: %s' % name) @@ -156,13 +157,13 @@ class BitmaskBackend(configurable.ConfigurableService): def _maybe_init_service(self, label, klass, *args, **kw): try: - self.getServiceNamed(label) + service = self.getServiceNamed(label) except KeyError: log.msg("initializing service: %s" % label) service = klass(*args, **kw) service.setName(label) service.setServiceParent(self) - return service + return service def do_stats(self): return self.core_commands.do_stats() |