diff options
author | Ivan Alejandro <ivanalejandro0@gmail.com> | 2015-09-23 15:36:32 -0300 |
---|---|---|
committer | Kali Kaneko <kali@leap.se> | 2015-09-23 15:21:19 -0400 |
commit | 6852b6df432ecd6ea08ecbd0c48385e94b16d2de (patch) | |
tree | 2935f31aad61c91f0a7be34b3b38a9101722f8dc /mail | |
parent | fb762c6dd23b781a23bce25d81b7ff34dd832bcc (diff) |
[feat] disable local-only bind on docker container
- Related: #7471
Diffstat (limited to 'mail')
-rw-r--r-- | mail/changes/feature-7471_disable-local-bind-for-docker | 1 | ||||
-rw-r--r-- | mail/src/leap/mail/imap/service/imap.py | 8 | ||||
-rw-r--r-- | mail/src/leap/mail/smtp/__init__.py | 9 |
3 files changed, 16 insertions, 2 deletions
diff --git a/mail/changes/feature-7471_disable-local-bind-for-docker b/mail/changes/feature-7471_disable-local-bind-for-docker new file mode 100644 index 00000000..a1ccb673 --- /dev/null +++ b/mail/changes/feature-7471_disable-local-bind-for-docker @@ -0,0 +1 @@ +- disable local only tcp bind on docker containers to allow access to IMAP and SMTP. Related to #7471. diff --git a/mail/src/leap/mail/imap/service/imap.py b/mail/src/leap/mail/imap/service/imap.py index cd31edf5..a50611b9 100644 --- a/mail/src/leap/mail/imap/service/imap.py +++ b/mail/src/leap/mail/imap/service/imap.py @@ -158,8 +158,14 @@ def run_service(store, **kwargs): factory = LeapIMAPFactory(uuid, userid, store) try: + interface = "localhost" + # don't bind just to localhost if we are running on docker since we + # won't be able to access imap from the host + if os.environ.get("LEAP_DOCKERIZED"): + interface = '' + tport = reactor.listenTCP(port, factory, - interface="localhost") + interface=interface) except CannotListenError: logger.error("IMAP Service failed to start: " "cannot listen in port %s" % (port,)) diff --git a/mail/src/leap/mail/smtp/__init__.py b/mail/src/leap/mail/smtp/__init__.py index a77a4140..7b62808e 100644 --- a/mail/src/leap/mail/smtp/__init__.py +++ b/mail/src/leap/mail/smtp/__init__.py @@ -19,6 +19,7 @@ SMTP gateway helper function. """ import logging +import os from twisted.internet import reactor from twisted.internet.error import CannotListenError @@ -64,7 +65,13 @@ def setup_smtp_gateway(port, userid, keymanager, smtp_host, smtp_port, userid, keymanager, smtp_cert, smtp_key, smtp_host, smtp_port) factory = SMTPFactory(userid, keymanager, encrypted_only, outgoing_mail) try: - tport = reactor.listenTCP(port, factory, interface="localhost") + interface = "localhost" + # don't bind just to localhost if we are running on docker since we + # won't be able to access smtp from the host + if os.environ.get("LEAP_DOCKERIZED"): + interface = '' + + tport = reactor.listenTCP(port, factory, interface=interface) emit_async(catalog.SMTP_SERVICE_STARTED, str(port)) return factory, tport except CannotListenError: |