[tor-commits] [flashproxy/master] reg-email fixes:

infinity0 at torproject.org infinity0 at torproject.org
Thu Nov 21 13:18:46 UTC 2013


commit 8b7cd1bcdf9ce49608521c26f0fb27d744f4c5d4
Author: Ximin Luo <infinity0 at gmx.com>
Date:   Mon Nov 18 14:06:56 2013 +0000

    reg-email fixes:
    - output line number instead of sensitive info in error message
    - set default_imap_host back to gmail for simplicity, with a TODO for future enhancements
    - rm obsolete email options from help text and initscript
---
 facilitator/facilitator-email-poller           |   12 +++++++-----
 facilitator/init.d/facilitator-email-poller.in |    2 --
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/facilitator/facilitator-email-poller b/facilitator/facilitator-email-poller
index be1ab58..f087507 100755
--- a/facilitator/facilitator-email-poller
+++ b/facilitator/facilitator-email-poller
@@ -21,6 +21,9 @@ import fac
 from hashlib import sha1
 from M2Crypto import SSL
 
+# TODO(infinity0): we only support gmail so this is OK for now. in the future,
+# could maybe do an MX lookup and try to guess the imap server from that.
+DEFAULT_IMAP_HOST = "imap.gmail.com"
 DEFAULT_IMAP_PORT = 993
 DEFAULT_LOG_FILENAME = "facilitator-email-poller.log"
 
@@ -122,7 +125,7 @@ class IMAP4_SSL_REQUIRED(imaplib.IMAP4_SSL):
 
 def usage(f = sys.stdout):
     print >> f, """\
-Usage: %(progname)s --email=ADDRESS --pass=PASSFILE
+Usage: %(progname)s --pass=PASSFILE
 Facilitator-side helper for the facilitator-reg-email rendezvous. Polls
 an IMAP server for email messages with client registrations, deletes
 them, and forwards the registrations to the facilitator.
@@ -210,17 +213,16 @@ try:
         print >> sys.stderr, "Refusing to run with group- or world-readable password file. Try"
         print >> sys.stderr, "\tchmod 600 %s" % options.password_filename
         sys.exit(1)
-    for line in password_file.readlines():
+    for (lineno0, line) in enumerate(password_file.readlines()):
         line = line.strip("\n")
         if not line or line.startswith('#'): continue
         # we do this stricter regex match because passwords might have spaces in
         res = re.match(r"(?:(\S+)\s)?(\S+@\S+)\s(.+)", line)
         if not res:
-            raise ValueError("could not find email or password: %s" % line)
+            raise ValueError("could not find email or password on line %s" % (lineno0+1))
         (imap_addr_spec, email_addr, email_password) = res.groups()
-        default_imap_host = "imap.%s" % (email_addr.split('@', 1)[1])
         imap_addr = fac.parse_addr_spec(
-            imap_addr_spec or "", default_imap_host, DEFAULT_IMAP_PORT, nameOk=True)
+            imap_addr_spec or "", DEFAULT_IMAP_HOST, DEFAULT_IMAP_PORT, nameOk=True)
         break
     else:
         raise ValueError("no email line found")
diff --git a/facilitator/init.d/facilitator-email-poller.in b/facilitator/init.d/facilitator-email-poller.in
index e39fb56..02edd08 100755
--- a/facilitator/init.d/facilitator-email-poller.in
+++ b/facilitator/init.d/facilitator-email-poller.in
@@ -38,8 +38,6 @@ DEFAULTSFILE=@sysconfdir@/default/$NAME
 . /lib/lsb/init-functions
 
 [ "$UNSAFE_LOGGING" = "yes" ] && DAEMON_ARGS="$DAEMON_ARGS --unsafe-logging"
-[ -n "$IMAPADDR" ] && DAEMON_ARGS="$DAEMON_ARGS --imap $IMAPADDR"
-DAEMON_ARGS="$DAEMON_ARGS --email $FACILITATOR_EMAIL_ADDR"
 
 #
 # Function that starts the daemon/service





More information about the tor-commits mailing list