diff options
-rw-r--r-- | changes/bug_fix_return_codes | 1 | ||||
-rw-r--r-- | src/leap/mx/alias_resolver.py | 17 | ||||
-rw-r--r-- | src/leap/mx/check_recipient_access.py | 6 |
3 files changed, 14 insertions, 10 deletions
diff --git a/changes/bug_fix_return_codes b/changes/bug_fix_return_codes new file mode 100644 index 0000000..9debe44 --- /dev/null +++ b/changes/bug_fix_return_codes @@ -0,0 +1 @@ + o Fix alias lookup return codes. Closes: #3356 diff --git a/src/leap/mx/alias_resolver.py b/src/leap/mx/alias_resolver.py index 2074ee5..1d478c7 100644 --- a/src/leap/mx/alias_resolver.py +++ b/src/leap/mx/alias_resolver.py @@ -29,6 +29,7 @@ try: # from twisted.mail import alias from twisted.protocols import postfix from twisted.python import log + from twisted.internet import defer except ImportError: print "This software requires Twisted. Please see the README file" print "for instructions on getting required dependencies." @@ -47,21 +48,27 @@ class AliasResolverFactory(postfix.PostfixTCPMapDeferringDictServerFactory): log.msg("Result not found") return result + def spit_result(self, result): + if result is None: + return defer.succeed("500 NO RESULT") + else: + return defer.succeed("200") + def get(self, key): try: log.msg("Processing key: %s" % (key,)) if key.find("@") == -1: log.msg("Ignoring key since it's not an email address") return None - key = key.split("@")[0] key = key.split("+")[0] log.msg("Final key to query: %s" % (key,)) d = self._cdb.queryByLoginOrAlias(key) d.addCallback(self._to_str) d.addErrback(log.err) - return d - except: - log.err() - return None + d.addCallback(self.spit_result) + d.addErrback(log.err) + return d + except Exception as e: + log.err('exception in get: %r' % e) diff --git a/src/leap/mx/check_recipient_access.py b/src/leap/mx/check_recipient_access.py index 1b44504..b75d1eb 100644 --- a/src/leap/mx/check_recipient_access.py +++ b/src/leap/mx/check_recipient_access.py @@ -26,11 +26,7 @@ from leap.mx.alias_resolver import AliasResolverFactory class CheckRecipientAccess(postfix.PostfixTCPMapServer): - def _cbGot(self, value): - if value is None: - self.sendCode(500) - else: - self.sendCode(200) + pass class CheckRecipientAccessFactory(AliasResolverFactory): |