commit 4811b51af8a5bf5c97dd1053e89c091a07916f4a Author: Ximin Luo infinity0@gmx.com Date: Tue Sep 24 20:11:41 2013 +0100
source the email address from a defaults file, don't hard code it --- facilitator/INSTALL | 6 ++++-- facilitator/Makefile.am | 2 ++ facilitator/default/facilitator-email-poller | 6 ++++++ facilitator/facilitator-email-poller | 13 ++++++++----- facilitator/init.d/facilitator-email-poller.in | 13 ++++++++++++- 5 files changed, 32 insertions(+), 8 deletions(-)
diff --git a/facilitator/INSTALL b/facilitator/INSTALL index a7ed1dc..bd47adf 100644 --- a/facilitator/INSTALL +++ b/facilitator/INSTALL @@ -21,8 +21,10 @@ You should securely distribute the public key to anyone that wants to use your facilitator; they will need to pass it as the --facilitator-pubkey option to flashproxy-reg-email.
-You should also edit /usr/local/etc/flashproxy/reg-email.pass to contain your -app-specific Gmail password; see doc/gmail-howto.txt for instructions. +You should also edit /usr/local/etc/default/facilitator-email-poller to +contain your Gmail address and /usr/local/etc/flashproxy/reg-email.pass +to contain your app-specific password; see doc/gmail-howto.txt for +instructions.
Uninstall.
diff --git a/facilitator/Makefile.am b/facilitator/Makefile.am index b8dff41..740ac3f 100644 --- a/facilitator/Makefile.am +++ b/facilitator/Makefile.am @@ -7,6 +7,7 @@ initscriptdir = /etc/init.d exampledir = $(docdir)/examples appenginedir = $(pkgdatadir)/appengine pkgconfdir = $(sysconfdir)/flashproxy +initdefaultdir = $(sysconfdir)/default appengineconfdir = $(pkgconfdir)/reg-appengine
# automake PLVs @@ -14,6 +15,7 @@ appengineconfdir = $(pkgconfdir)/reg-appengine dist_bin_SCRIPTS = facilitator facilitator-email-poller facilitator-reg-daemon facilitator-reg facilitator.cgi fac.py if DO_INITSCRIPTS initscript_SCRIPTS = init.d/facilitator init.d/facilitator-email-poller init.d/facilitator-reg-daemon +initdefault_DATA = default/facilitator-email-poller endif
dist_doc_DATA = doc/appengine-howto.txt doc/facilitator-howto.txt doc/gmail-howto.txt README diff --git a/facilitator/default/facilitator-email-poller b/facilitator/default/facilitator-email-poller new file mode 100644 index 0000000..af2f8ca --- /dev/null +++ b/facilitator/default/facilitator-email-poller @@ -0,0 +1,6 @@ +# Change to "yes" to run the email poller. +RUN_DAEMON="no" + +# Replace this with the email address for your facilitator. +# You should also edit the reg-email.pass file as needed. +FACILITATOR_EMAIL_ADDR="invalid" diff --git a/facilitator/facilitator-email-poller b/facilitator/facilitator-email-poller index 3504c51..32dc2d4 100755 --- a/facilitator/facilitator-email-poller +++ b/facilitator/facilitator-email-poller @@ -23,7 +23,6 @@ from M2Crypto import SSL, X509
DEFAULT_IMAP_HOST = "imap.gmail.com" DEFAULT_IMAP_PORT = 993 -DEFAULT_EMAIL_ADDRESS = "flashproxyreg.a@gmail.com" DEFAULT_LOG_FILENAME = "facilitator-email-poller.log"
POLL_INTERVAL = 60 @@ -126,14 +125,14 @@ class IMAP4_SSL_REQUIRED(imaplib.IMAP4_SSL):
def usage(f = sys.stdout): print >> f, """\ -Usage: %(progname)s --pass=PASSFILE +Usage: %(progname)s --email=ADDRESS --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.
-d, --debug don't daemonize, log to stdout. --disable-pin don't check server public key against a known pin. - -e, --email=ADDRESS log in as ADDRESS (default "%(email_addr)s"). + -e, --email=ADDRESS log in as ADDRESS -h, --help show this help. -i, --imap=HOST[:PORT] use the given IMAP server (default "%(imap_addr)s"). --imaplib-debug show raw IMAP messages (will include email password). @@ -144,7 +143,6 @@ them, and forwards the registrations to the facilitator. --unsafe-logging don't scrub email password and IP addresses from logs.\ """ % { "progname": sys.argv[0], - "email_addr": DEFAULT_EMAIL_ADDRESS, "imap_addr": fac.format_addr((DEFAULT_IMAP_HOST, DEFAULT_IMAP_PORT)), "log": DEFAULT_LOG_FILENAME, } @@ -160,7 +158,7 @@ def log(msg): print >> options.log_file, (u"%s %s" % (time.strftime(LOG_DATE_FORMAT), msg)).encode("UTF-8") options.log_file.flush()
-options.email_addr = DEFAULT_EMAIL_ADDRESS +options.email_addr = None options.imap_addr = (DEFAULT_IMAP_HOST, DEFAULT_IMAP_PORT)
opts, args = getopt.gnu_getopt(sys.argv[1:], "de:hi:l:p:", [ @@ -206,6 +204,11 @@ if len(args) != 0: usage(sys.stderr) sys.exit(1)
+# Check the email +if not options.email_addr or '@' not in options.email_addr: + print >> sys.stderr, "The --email option is required and must be an email address." + sys.exit(1) + # Load the email password. if options.password_filename is None: print >> sys.stderr, "The --pass option is required." diff --git a/facilitator/init.d/facilitator-email-poller.in b/facilitator/init.d/facilitator-email-poller.in index ef90794..44cc527 100755 --- a/facilitator/init.d/facilitator-email-poller.in +++ b/facilitator/init.d/facilitator-email-poller.in @@ -24,8 +24,15 @@ PIDFILE=@localstatedir@/run/$NAME.pid LOGFILE=@localstatedir@/log/$NAME.log CONFDIR=@sysconfdir@/flashproxy PRIVDROP_USER=@fpfacilitatoruser@ +DEFAULTSFILE=@sysconfdir@/default/$NAME + +# Include defaults if available +if [ -f $DEFAULTSFILE ] ; then + . $DEFAULTSFILE +fi + DAEMON=@bindir@/$NAME -DAEMON_ARGS="--pass $CONFDIR/reg-email.pass --log $LOGFILE --pidfile $PIDFILE --privdrop-user $PRIVDROP_USER" +DAEMON_ARGS="--email $FACILITATOR_EMAIL_ADDR --pass $CONFDIR/reg-email.pass --log $LOGFILE --pidfile $PIDFILE --privdrop-user $PRIVDROP_USER"
# Exit if the package is not installed [ -x "$DAEMON" ] || exit 0 @@ -76,6 +83,10 @@ do_stop()
case "$1" in start) + if [ "$RUN_DAEMON" != "yes" ]; then + log_action_msg "Not starting $DESC (Disabled in $DEFAULTSFILE)." + exit 0 + fi [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" do_start case "$?" in
tor-commits@lists.torproject.org