[tor-commits] [bridgedb/master] Remove local hostaddr domain pass for SMTP checks.

isis at torproject.org isis at torproject.org
Fri Jun 6 23:39:14 UTC 2014


commit aca6dcdc0ab926d6ad353c781962a19fa392c890
Author: Isis Lovecruft <isis at torproject.org>
Date:   Mon Jun 2 20:54:59 2014 +0000

    Remove local hostaddr domain pass for SMTP checks.
    
     * CHANGE b.e.server.MailDelivery class to check incoming DNS names,
       never addresses.
---
 lib/bridgedb/email/server.py |   15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/lib/bridgedb/email/server.py b/lib/bridgedb/email/server.py
index d27b525..249b7c7 100644
--- a/lib/bridgedb/email/server.py
+++ b/lib/bridgedb/email/server.py
@@ -87,7 +87,6 @@ class MailServerContext(object):
 
         self.username = (config.EMAIL_USERNAME or "bridges")
         self.hostname = socket.gethostname()
-        self.hostaddr = socket.gethostbyname(self.hostname)
         self.fromAddr = (config.EMAIL_FROM_ADDR or "bridges at torproject.org")
         self.smtpFromAddr = (config.EMAIL_SMTP_FROM_ADDR or self.fromAddr)
         self.smtpServerPort = (config.EMAIL_SMTP_PORT or 25)
@@ -242,20 +241,22 @@ class MailDelivery(object):
         """
         try:
             if ((origin.domain == self.context.hostname) or
-                (origin.domain == self.context.hostaddr)):
-                return origin
+                (origin.domain == smtp.DNSNAME)):
+                self.fromCanonicalSMTP = origin.domain
             else:
-                logging.debug("ORIGIN DOMAIN: %r" % origin.domain)
+                logging.debug("Canonicalizing client SMTP domain...")
                 canonical = canonicalizeEmailDomain(origin.domain,
                                                     self.context.canon)
-                logging.debug("Got canonical domain: %r" % canonical)
-                self.fromCanonical = canonical
+                logging.debug("Canonical SMTP domain: %r" % canonical)
+                self.fromCanonicalSMTP = canonical
         except UnsupportedDomain as error:
             logging.info(error)
             raise smtp.SMTPBadSender(origin.domain)
         except Exception as error:
             logging.exception(error)
-        return origin  # This method *cannot* return None, or it'll cause a 503.
+
+        # This method **cannot** return None, or it'll cause a 503 error.
+        return origin
 
     def validateTo(self, user):
         """Validate the SMTP ``RCPT TO:`` address for the incoming connection.





More information about the tor-commits mailing list