summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMicah Anderson <micah@riseup.net>2013-08-13 15:49:55 -0400
committerMicah Anderson <micah@riseup.net>2013-08-13 15:49:55 -0400
commit327dac28be41ac5204a777025e212b78a268c9d4 (patch)
treedd62cac222f1311f9df26ca8f2e90133c43dd937
parent54c3fe7a1240dbd2875c21fda9949fb8e91ecdef (diff)
parent5ae019af6e29697dd43700c614e06298d719ff96 (diff)
update to 0.3.0
-rw-r--r--CHANGELOG10
-rw-r--r--VERSION.md6
-rw-r--r--debian/changelog6
-rw-r--r--pkg/requirements.pip2
-rw-r--r--setup.py2
-rw-r--r--src/leap/mx/__init__.py3
-rw-r--r--src/leap/mx/alias_resolver.py50
-rw-r--r--src/leap/mx/check_recipient_access.py9
-rw-r--r--src/leap/mx/mail_receiver.py16
9 files changed, 80 insertions, 24 deletions
diff --git a/CHANGELOG b/CHANGELOG
new file mode 100644
index 0000000..0c449c6
--- /dev/null
+++ b/CHANGELOG
@@ -0,0 +1,10 @@
+0.3.0 Aug 9:
+ o Give a return code for bare usernames too. Closes: #3405
+ o Adapt to Soledad 0.2.1 API.
+ o Fix broken pip install
+ o Fix alias lookup return codes. Closes: #3356
+ o Use the new API to import a new ascii armored public key. Fixes
+ #3352.
+ o Add "incoming" index for ease of listing new email.
+ o Add dependency for leap.keymanager.
+ o Adapt to the new keymanager API. Closes #3397.
diff --git a/VERSION.md b/VERSION.md
index 43f6976..f29cb7b 100644
--- a/VERSION.md
+++ b/VERSION.md
@@ -1,7 +1,7 @@
-[leap_mx, version 0.2.2]
+[leap_mx, version 0.3.0]
------------------------
-Authors: Isis Agora Lovecruft, <isis@leap.se> 0x2cdb8b35
+Authors: The LEAP Team
Website: https://leap.se
-Github: https://github.com/isislovecruft/leap_mx/
+Github: https://github.com/leapcode/leap_mx/
diff --git a/debian/changelog b/debian/changelog
index e4de8f8..8643897 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+leap-mx (0.3.0) unstable; urgency=low
+
+ * Update to 0.3.0
+
+ -- Micah Anderson <micah@debian.org> Tue, 13 Aug 2013 15:49:33 -0400
+
leap-mx (0.2.2.2) unstable; urgency=low
* Added status command to initscript
diff --git a/pkg/requirements.pip b/pkg/requirements.pip
index 1bdb4dc..7ec489d 100644
--- a/pkg/requirements.pip
+++ b/pkg/requirements.pip
@@ -4,7 +4,7 @@ paisley>=0.3.1
python-gnupg>=0.3.0
leap.soledad
leap.soledad_server
-leap.keymanager>=0.2.1
+leap.keymanager>=0.2.0
###############
# Development #
diff --git a/setup.py b/setup.py
index 41c29c2..6d3034b 100644
--- a/setup.py
+++ b/setup.py
@@ -48,7 +48,7 @@ else:
setup(
name='leap.mx',
- version="0.2.2",
+ version="0.3.0",
# bump also src/leap/mx/__init__
url="http://github.com/leapcode/leap_mx",
license='AGPLv3+',
diff --git a/src/leap/mx/__init__.py b/src/leap/mx/__init__.py
index 61c9a5c..9cbe2a3 100644
--- a/src/leap/mx/__init__.py
+++ b/src/leap/mx/__init__.py
@@ -17,4 +17,5 @@
"""
Module initialization file for leap.mx .
"""
-__version__ = "0.2.2"
+__version__ = "0.3.0"
+
diff --git a/src/leap/mx/alias_resolver.py b/src/leap/mx/alias_resolver.py
index 2074ee5..08ebb73 100644
--- a/src/leap/mx/alias_resolver.py
+++ b/src/leap/mx/alias_resolver.py
@@ -19,6 +19,8 @@
"""
Classes for resolving postfix aliases.
+Test this with postmap -v -q "foo" tcp:localhost:4242
+
TODO:
o Look into using twisted.protocols.postfix.policies classes for
controlling concurrent connections and throttling resource consumption.
@@ -29,39 +31,69 @@ 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."
+class LEAPPostFixTCPMapserver(postfix.PostfixTCPMapServer):
+ def _cbGot(self, value):
+ if value is None:
+ self.sendCode(500, postfix.quote("NOT FOUND SRY"))
+ else:
+ self.sendCode(200, postfix.quote(value))
+
+
class AliasResolverFactory(postfix.PostfixTCPMapDeferringDictServerFactory):
+
+ protocol = LEAPPostFixTCPMapserver
+
def __init__(self, couchdb, *args, **kwargs):
postfix.PostfixTCPMapDeferringDictServerFactory.__init__(
self, *args, **kwargs)
self._cdb = couchdb
def _to_str(self, result):
+ """
+ Properly encodes the result string if any.
+ """
if isinstance(result, unicode):
result = result.encode("utf8")
if result is None:
log.msg("Result not found")
return result
+ def spit_result(self, result):
+ """
+ Formats the return codes in a postfix friendly format.
+ """
+ if result is None:
+ return None
+ else:
+ return defer.succeed(result)
+
def get(self, key):
+ """
+ Looks up the passed key, but only up to the username id of the key.
+
+ At some point we will have to consider the domain part too.
+ """
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]
+ # No proper email address, but we need to continue processing
+ # the query so postmap is happy.
+ log.msg("Key it's not an email address")
+ else:
+ 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.addCallback(self.spit_result)
d.addErrback(log.err)
return d
- except:
- log.err()
-
- return None
+ 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..0520c7c 100644
--- a/src/leap/mx/check_recipient_access.py
+++ b/src/leap/mx/check_recipient_access.py
@@ -18,6 +18,8 @@
"""
Classes for resolving postfix recipient access
+
+Test this with postmap -v -q "foo" tcp:localhost:2244
"""
from twisted.protocols import postfix
@@ -25,13 +27,14 @@ from twisted.protocols import postfix
from leap.mx.alias_resolver import AliasResolverFactory
-class CheckRecipientAccess(postfix.PostfixTCPMapServer):
+class LEAPPostFixTCPMapserverAccess(postfix.PostfixTCPMapServer):
def _cbGot(self, value):
if value is None:
- self.sendCode(500)
+ self.sendCode(500, postfix.quote("NOT FOUND SORRY"))
else:
+ # We do not send the value in this case
self.sendCode(200)
class CheckRecipientAccessFactory(AliasResolverFactory):
- protocol = CheckRecipientAccess
+ protocol = LEAPPostFixTCPMapserverAccess
diff --git a/src/leap/mx/mail_receiver.py b/src/leap/mx/mail_receiver.py
index b4e0d18..a830fa1 100644
--- a/src/leap/mx/mail_receiver.py
+++ b/src/leap/mx/mail_receiver.py
@@ -116,21 +116,25 @@ class MailReceiver(Service):
if pubkey is None or len(pubkey) == 0:
doc.content = {
+ "incoming": True,
"_enc_scheme": EncryptionSchemes.NONE,
"_enc_json": json.dumps(data)
}
return uuid, doc
- def _ascii_to_openpgp_cb(gpg):
+ openpgp_key = None
+ with openpgp.TempGPGWrapper(gpgbinary='/usr/bin/gpg') as gpg:
+ gpg.import_keys(pubkey)
key = gpg.list_keys().pop()
- return openpgp._build_key_from_gpg(address, key, pubkey)
-
- openpgp_key = openpgp._safe_call(_ascii_to_openpgp_cb, pubkey)
+ openpgp_key = openpgp._build_key_from_gpg(address, key, pubkey)
doc.content = {
+ "incoming": True,
"_enc_scheme": EncryptionSchemes.PUBKEY,
- "_enc_json": openpgp.encrypt_asym(json.dumps(data),
- openpgp_key)
+ "_enc_json": str(gpg.encrypt(
+ json.dumps(data),
+ openpgp_key.fingerprint,
+ symmetric=False))
}
return uuid, doc