From 08c13654268e986d03341c564d7cc91db80d940d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Touceda?= Date: Wed, 6 Nov 2013 11:51:33 -0300 Subject: Reject senders if they aren't the logged in user --- src/leap/mail/smtp/__init__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/leap/mail/smtp/__init__.py') diff --git a/src/leap/mail/smtp/__init__.py b/src/leap/mail/smtp/__init__.py index b30cd20..be568b8 100644 --- a/src/leap/mail/smtp/__init__.py +++ b/src/leap/mail/smtp/__init__.py @@ -29,7 +29,7 @@ from leap.common.events import proto, signal from leap.mail.smtp.smtprelay import SMTPFactory -def setup_smtp_relay(port, keymanager, smtp_host, smtp_port, +def setup_smtp_relay(port, userid, keymanager, smtp_host, smtp_port, smtp_cert, smtp_key, encrypted_only): """ Setup SMTP relay to run with Twisted. @@ -39,6 +39,8 @@ def setup_smtp_relay(port, keymanager, smtp_host, smtp_port, :param port: The port in which to run the server. :type port: int + :param userid: The user currently logged in + :type userid: unicode :param keymanager: A Key Manager from where to get recipients' public keys. :type keymanager: leap.common.keymanager.KeyManager @@ -75,7 +77,7 @@ def setup_smtp_relay(port, keymanager, smtp_host, smtp_port, } # configure the use of this service with twistd - factory = SMTPFactory(keymanager, config) + factory = SMTPFactory(userid, keymanager, config) try: tport = reactor.listenTCP(port, factory, interface="localhost") -- cgit v1.2.3 From 4df74038a89dccff213c07795795154831330ace Mon Sep 17 00:00:00 2001 From: drebs Date: Thu, 7 Nov 2013 16:44:59 -0200 Subject: Cleanup code and fix tests. --- src/leap/mail/smtp/__init__.py | 33 +++++++-------------------------- 1 file changed, 7 insertions(+), 26 deletions(-) (limited to 'src/leap/mail/smtp/__init__.py') diff --git a/src/leap/mail/smtp/__init__.py b/src/leap/mail/smtp/__init__.py index be568b8..753ef34 100644 --- a/src/leap/mail/smtp/__init__.py +++ b/src/leap/mail/smtp/__init__.py @@ -46,7 +46,7 @@ def setup_smtp_relay(port, userid, keymanager, smtp_host, smtp_port, :type keymanager: leap.common.keymanager.KeyManager :param smtp_host: The hostname of the remote SMTP server. :type smtp_host: str - :param smtp_port: The port of the remote SMTP server. + :param smtp_port: The port of the remote SMTP server. :type smtp_port: int :param smtp_cert: The client certificate for authentication. :type smtp_cert: str @@ -58,36 +58,17 @@ def setup_smtp_relay(port, userid, keymanager, smtp_host, smtp_port, :returns: tuple of SMTPFactory, twisted.internet.tcp.Port """ - # The configuration for the SMTP relay is a dict with the following - # format: - # - # { - # 'host': '', - # 'port': , - # 'cert': '', - # 'key': '', - # 'encrypted_only': - # } - config = { - 'host': smtp_host, - 'port': smtp_port, - 'cert': smtp_cert, - 'key': smtp_key, - 'encrypted_only': encrypted_only - } - # configure the use of this service with twistd - factory = SMTPFactory(userid, keymanager, config) + factory = SMTPFactory(userid, keymanager, smtp_host, smtp_port, smtp_cert, + smtp_key, encrypted_only) try: - tport = reactor.listenTCP(port, factory, - interface="localhost") - signal(proto.SMTP_SERVICE_STARTED, str(smtp_port)) + tport = reactor.listenTCP(port, factory, interface="localhost") + signal(proto.SMTP_SERVICE_STARTED, str(port)) return factory, tport except CannotListenError: logger.error("STMP Service failed to start: " - "cannot listen in port %s" % ( - smtp_port,)) - signal(proto.SMTP_SERVICE_FAILED_TO_START, str(smtp_port)) + "cannot listen in port %s" % port) + signal(proto.SMTP_SERVICE_FAILED_TO_START, str(port)) except Exception as exc: logger.error("Unhandled error while launching smtp relay service") logger.exception(exc) -- cgit v1.2.3 From 275c435ee45463ed6011f8988d5c7f90cb42fd01 Mon Sep 17 00:00:00 2001 From: drebs Date: Thu, 7 Nov 2013 17:09:56 -0200 Subject: Change SMTP "relay" to "gateway". --- src/leap/mail/smtp/__init__.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/leap/mail/smtp/__init__.py') diff --git a/src/leap/mail/smtp/__init__.py b/src/leap/mail/smtp/__init__.py index 753ef34..d3eb9e8 100644 --- a/src/leap/mail/smtp/__init__.py +++ b/src/leap/mail/smtp/__init__.py @@ -16,7 +16,7 @@ # along with this program. If not, see . """ -SMTP relay helper function. +SMTP gateway helper function. """ import logging @@ -26,15 +26,15 @@ from twisted.internet.error import CannotListenError logger = logging.getLogger(__name__) from leap.common.events import proto, signal -from leap.mail.smtp.smtprelay import SMTPFactory +from leap.mail.smtp.gateway import SMTPFactory -def setup_smtp_relay(port, userid, keymanager, smtp_host, smtp_port, +def setup_smtp_gateway(port, userid, keymanager, smtp_host, smtp_port, smtp_cert, smtp_key, encrypted_only): """ - Setup SMTP relay to run with Twisted. + Setup SMTP gateway to run with Twisted. - This function sets up the SMTP relay configuration and the Twisted + This function sets up the SMTP gateway configuration and the Twisted reactor. :param port: The port in which to run the server. @@ -52,7 +52,7 @@ def setup_smtp_relay(port, userid, keymanager, smtp_host, smtp_port, :type smtp_cert: str :param smtp_key: The client key for authentication. :type smtp_key: str - :param encrypted_only: Whether the SMTP relay should send unencrypted mail + :param encrypted_only: Whether the SMTP gateway should send unencrypted mail or not. :type encrypted_only: bool @@ -70,5 +70,5 @@ def setup_smtp_relay(port, userid, keymanager, smtp_host, smtp_port, "cannot listen in port %s" % port) signal(proto.SMTP_SERVICE_FAILED_TO_START, str(port)) except Exception as exc: - logger.error("Unhandled error while launching smtp relay service") + logger.error("Unhandled error while launching smtp gateway service") logger.exception(exc) -- cgit v1.2.3