From c6d5c0050b3cbefe79e9d1e2e770defc734dcec7 Mon Sep 17 00:00:00 2001 From: drebs Date: Thu, 19 Dec 2013 22:57:07 -0200 Subject: Stop providing hostname for helo in smtp gateway (#4335). --- mail/changes/feature_4335_stop-providing-hostname-for-helo | 1 + mail/src/leap/mail/smtp/gateway.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 mail/changes/feature_4335_stop-providing-hostname-for-helo (limited to 'mail') diff --git a/mail/changes/feature_4335_stop-providing-hostname-for-helo b/mail/changes/feature_4335_stop-providing-hostname-for-helo new file mode 100644 index 0000000..f4b6c29 --- /dev/null +++ b/mail/changes/feature_4335_stop-providing-hostname-for-helo @@ -0,0 +1 @@ + o Stop providing hostname for helo in smtp gateway (#4335). diff --git a/mail/src/leap/mail/smtp/gateway.py b/mail/src/leap/mail/smtp/gateway.py index a24115b..bef5c6d 100644 --- a/mail/src/leap/mail/smtp/gateway.py +++ b/mail/src/leap/mail/smtp/gateway.py @@ -52,6 +52,7 @@ from leap.common.events import proto, signal from leap.keymanager import KeyManager from leap.keymanager.openpgp import OpenPGPKey from leap.keymanager.errors import KeyNotFound +from leap.mail import __version__ from leap.mail.smtp.rfc3156 import ( MultipartSigned, MultipartEncrypted, @@ -492,7 +493,7 @@ class EncryptedMessage(object): heloFallback=True, requireAuthentication=False, requireTransportSecurity=True) - factory.domain = LOCAL_FQDN + factory.domain = __version__ signal(proto.SMTP_SEND_MESSAGE_START, self._user.dest.addrstr) reactor.connectSSL( self._host, self._port, factory, -- cgit v1.2.3 From 178c356fc3b330e92bb582fee75dfd345339c267 Mon Sep 17 00:00:00 2001 From: drebs Date: Thu, 19 Dec 2013 23:13:43 -0200 Subject: Only try to fetch keys for multipart signed or encrypted messages when fetching mail (#4671). --- ...ture_4671_only-try-to-fetch-keys-for-multipart-signed-or-encrypted | 1 + mail/src/leap/mail/imap/fetch.py | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 mail/changes/feature_4671_only-try-to-fetch-keys-for-multipart-signed-or-encrypted (limited to 'mail') diff --git a/mail/changes/feature_4671_only-try-to-fetch-keys-for-multipart-signed-or-encrypted b/mail/changes/feature_4671_only-try-to-fetch-keys-for-multipart-signed-or-encrypted new file mode 100644 index 0000000..de3bb86 --- /dev/null +++ b/mail/changes/feature_4671_only-try-to-fetch-keys-for-multipart-signed-or-encrypted @@ -0,0 +1 @@ + o Only try to fetch keys for multipart signed or encrypted emails (#4671). diff --git a/mail/src/leap/mail/imap/fetch.py b/mail/src/leap/mail/imap/fetch.py index f69681a..b1c34ba 100644 --- a/mail/src/leap/mail/imap/fetch.py +++ b/mail/src/leap/mail/imap/fetch.py @@ -389,7 +389,9 @@ class LeapIncomingMail(object): # try to obtain sender public key senderPubkey = None fromHeader = msg.get('from', None) - if fromHeader is not None: + if fromHeader is not None \ + and (msg.get_content_type() == 'multipart/encrypted' \ + or msg.get_content_type() == 'multipart/signed'): _, senderAddress = parseaddr(fromHeader) try: senderPubkey = self._keymanager.get_key_from_cache( -- cgit v1.2.3 From aa69b820df0db9a277833a74927e315c083ccbaf Mon Sep 17 00:00:00 2001 From: drebs Date: Thu, 19 Dec 2013 23:45:39 -0200 Subject: Fix tests and bug introduced in 541bd8aec1f67834c42bc2e5df14c1f73c569082. --- mail/src/leap/mail/smtp/rfc3156.py | 2 +- mail/src/leap/mail/smtp/tests/test_gateway.py | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) (limited to 'mail') diff --git a/mail/src/leap/mail/smtp/rfc3156.py b/mail/src/leap/mail/smtp/rfc3156.py index b0288b4..9739531 100644 --- a/mail/src/leap/mail/smtp/rfc3156.py +++ b/mail/src/leap/mail/smtp/rfc3156.py @@ -361,7 +361,7 @@ class PGPSignature(MIMEApplication): """ def __init__(self, _data, name='signature.asc'): MIMEApplication.__init__(self, _data, 'pgp-signature', - encoder=lambda x: x, name=name) + _encoder=lambda x: x, name=name) self.add_header('Content-Description', 'OpenPGP Digital Signature') diff --git a/mail/src/leap/mail/smtp/tests/test_gateway.py b/mail/src/leap/mail/smtp/tests/test_gateway.py index 5b15b5b..88ee5f7 100644 --- a/mail/src/leap/mail/smtp/tests/test_gateway.py +++ b/mail/src/leap/mail/smtp/tests/test_gateway.py @@ -137,7 +137,8 @@ class TestSmtpGateway(TestCaseWithKeyManager): self._config['port'], self._config['cert'], self._config['key']) for line in self.EMAIL_DATA[4:12]: m.lineReceived(line) - m.eomReceived() + #m.eomReceived() # this includes a defer, so we avoid calling it here + m.lines.append('') # add a trailing newline # we need to call the following explicitelly because it was deferred # inside the previous method m._maybe_encrypt_and_sign() @@ -157,7 +158,7 @@ class TestSmtpGateway(TestCaseWithKeyManager): m._msg.get_payload(1).get_payload(), privkey) self.assertEqual( '\n' + '\r\n'.join(self.EMAIL_DATA[9:12]) + '\r\n\r\n--\r\n' + - 'I prefer encrypted email - https://leap.se/key/anotheruser.\r\n', + 'I prefer encrypted email - https://leap.se/key/anotheruser\r\n', decrypted, 'Decrypted text differs from plaintext.') @@ -180,7 +181,8 @@ class TestSmtpGateway(TestCaseWithKeyManager): for line in self.EMAIL_DATA[4:12]: m.lineReceived(line) # trigger encryption and signing - m.eomReceived() + #m.eomReceived() # this includes a defer, so we avoid calling it here + m.lines.append('') # add a trailing newline # we need to call the following explicitelly because it was deferred # inside the previous method m._maybe_encrypt_and_sign() @@ -202,7 +204,7 @@ class TestSmtpGateway(TestCaseWithKeyManager): m._msg.get_payload(1).get_payload(), privkey, verify=pubkey) self.assertEqual( '\n' + '\r\n'.join(self.EMAIL_DATA[9:12]) + '\r\n\r\n--\r\n' + - 'I prefer encrypted email - https://leap.se/key/anotheruser.\r\n', + 'I prefer encrypted email - https://leap.se/key/anotheruser\r\n', decrypted, 'Decrypted text differs from plaintext.') @@ -227,7 +229,8 @@ class TestSmtpGateway(TestCaseWithKeyManager): for line in self.EMAIL_DATA[4:12]: m.lineReceived(line) # trigger signing - m.eomReceived() + #m.eomReceived() # this includes a defer, so we avoid calling it here + m.lines.append('') # add a trailing newline # we need to call the following explicitelly because it was deferred # inside the previous method m._maybe_encrypt_and_sign() @@ -240,7 +243,7 @@ class TestSmtpGateway(TestCaseWithKeyManager): # assert content of message self.assertEqual( '\r\n'.join(self.EMAIL_DATA[9:13]) + '\r\n--\r\n' + - 'I prefer encrypted email - https://leap.se/key/anotheruser.\r\n', + 'I prefer encrypted email - https://leap.se/key/anotheruser\r\n', m._msg.get_payload(0).get_payload(decode=True)) # assert content of signature self.assertTrue( -- cgit v1.2.3