summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomás Touceda <chiiph@leap.se>2013-08-06 12:26:40 -0300
committerTomás Touceda <chiiph@leap.se>2013-08-06 12:26:40 -0300
commit92e1115f6aa76ec656972820021f24387bac117d (patch)
tree5a73f2d298a8cd2e1d8409f4877eabb9a8145ed5
parent30b1f13e23d7b56a1169dedc594a2be039d9e14c (diff)
parent0308d1d026a6a66f60519a2b753a3f6ea12c9ba1 (diff)
Merge remote-tracking branch 'kali/bug/fix_return_codes' into develop
-rw-r--r--changes/bug_fix_return_codes1
-rw-r--r--src/leap/mx/alias_resolver.py17
-rw-r--r--src/leap/mx/check_recipient_access.py6
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):