summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKali Kaneko <kali@leap.se>2013-08-06 16:40:07 +0200
committerKali Kaneko <kali@leap.se>2013-08-06 16:40:07 +0200
commit0308d1d026a6a66f60519a2b753a3f6ea12c9ba1 (patch)
tree5a73f2d298a8cd2e1d8409f4877eabb9a8145ed5 /src
parent30b1f13e23d7b56a1169dedc594a2be039d9e14c (diff)
Fix alias lookup return codes. Closes #3356
Diffstat (limited to 'src')
-rw-r--r--src/leap/mx/alias_resolver.py17
-rw-r--r--src/leap/mx/check_recipient_access.py6
2 files changed, 13 insertions, 10 deletions
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):