commit 2cec8e015c7be24a7c5919ab4ddc9b40a7d8745a Author: David Fifield david@bamsoftware.com Date: Thu Mar 7 01:25:39 2013 -0800
Remove facilitator-reg-url, replaced by facilitator-reg-daemon. --- facilitator/facilitator-reg-url | 157 -------------------------------- facilitator/init.d/facilitator-reg-url | 118 ------------------------ 2 files changed, 0 insertions(+), 275 deletions(-)
diff --git a/facilitator/facilitator-reg-url b/facilitator/facilitator-reg-url deleted file mode 100755 index 591c0f1..0000000 --- a/facilitator/facilitator-reg-url +++ /dev/null @@ -1,157 +0,0 @@ -#!/usr/bin/env python - -import sys -import base64 -import getopt -import traceback -import socket -import time -import os - -from M2Crypto import RSA - -import fac - -DEFAULT_FACILITATOR_ADDR = ("127.0.0.1", 9002) -DEFAULT_RSA_KEY_FILE = "/etc/flashproxy/reg-url.key" -DEFAULT_PORT = 9003 -DEFAULT_LOG_FILE = "/var/log/facilitator-reg-url.log" - -LOG_DATE_FORMAT = "%Y-%m-%d %H:%M:%S" - -# M2Crypto RSA object -rsa = None - -class options(object): - log_filename = DEFAULT_LOG_FILE - log_file = sys.stdout - port = DEFAULT_PORT - debug = False - daemonize = True - key_file = DEFAULT_RSA_KEY_FILE - facilitator = DEFAULT_FACILITATOR_ADDR - safe_logging = True - pid_filename = None - -def usage(): - print """ -Usage: %(progname)s - -Helper daemon for registration by indirect URL. Receives -client addresses from facilitator.cgi, decrypts them and -registers them with the facilitator. - - -h, --help print this help message and exit. - -d, --debug don't daemonize, log to stdout. - -k, --key=KEYFILE read the RSA private key from KEYFILE. - -f, --facilitator=ADDR register with facilitator listening at ADDR. - -p, --port=PORT listen for registrations on this port (default %(port)s). - -l, --log FILE write log to FILE (default "%(log)s"). - --pidfile FILE write pid to file after daemonizing. - --unsafe-logging don't scrub IP addresses from logs. -""" % { - "progname": sys.argv[0], - "port": DEFAULT_PORT, - "log": DEFAULT_LOG_FILE, -} - -def safe_str(s): - """Return s if options.safe_logging is true, and "[scrubbed]" otherwise.""" - if options.safe_logging: - return "[scrubbed]" - else: - return s - -def log(msg): - print >> options.log_file, (u"%s %s" % (time.strftime(LOG_DATE_FORMAT), msg)).encode("UTF-8") - options.log_file.flush() - -def register(reg): - try: - ciphertext = base64.urlsafe_b64decode(reg) - client_spec = str(rsa.private_decrypt(ciphertext, RSA.pkcs1_oaep_padding).decode('UTF-8')) - except: - log(u"Error occurred while decoding and decrypting registration:") - traceback.print_exc(file=options.log_file) - return False - try: - client_addr = fac.parse_addr_spec(client_spec) - except ValueError: - log(u"Registration of %s failed because of parsing error:" % safe_str(client_spec)) - traceback.print_exc(file=options.log_file) - return False - if not fac.put_reg(options.facilitator, client_addr): - log(u"Regstration of %s failed at the facilitator." % safe_str(client_spec)) - return False - log(u"Registered %s" % safe_str(client_spec)) - return True - -def loop(): - sock = socket.socket() - sock.bind(('', options.port)) - sock.listen(5) - - while True: - client, _ = sock.accept() - reg, buf = "", "" - while True: - buf = client.recv(4096) - if buf == "": - break - reg += buf - if register(reg): - client.send("\x00") - else: - client.send("\x01") - client.shutdown(socket.SHUT_RDWR) - client.close() - -def main(): - opts, args = getopt.gnu_getopt(sys.argv[1:], "hdl:p:k:f:", ["help", "debug", "log=", "port=", "key=", "facilitator=", "pidfile=", "unsafe-logging"]) - for o, a in opts: - if o == "-h" or o == "--help": - usage() - sys.exit(0) - if o == "-d" or o == "--debug": - options.daemonize = False - options.log_filename = False - if o == "-l" or o == "--log": - options.log_filename = a - if o == "-p" or o == "--port": - options.port = int(a) - if o == "-k" or o == "--key": - options.key_file = a - if o == "-f" or o == "--facilitator": - options.facilitator = fac.parse_addr_spec(a, resolve=True) - if o == "--pidfile": - options.pid_filename = a - if o == "--unsafe-logging": - options.safe_logging = False - - if options.daemonize: - log(u"daemonizing") - pid = os.fork() - if pid != 0: - if options.pid_filename: - f = open(options.pid_filename, "w") - print >> f, pid - f.close() - sys.exit(0) - - if options.log_filename: - options.log_file = open(options.log_filename, "a") - log(u"Starting on port %s" % options.port) - - # Load RSA key. - try: - global rsa - rsa = RSA.load_key(options.key_file) - except: - log(u"Failed to load RSA private key:") - traceback.print_exc(file=options.log_file) - sys.exit(1) - - loop() - -if __name__ == "__main__": - main() diff --git a/facilitator/init.d/facilitator-reg-url b/facilitator/init.d/facilitator-reg-url deleted file mode 100755 index c6c129a..0000000 --- a/facilitator/init.d/facilitator-reg-url +++ /dev/null @@ -1,118 +0,0 @@ -#! /bin/sh -### BEGIN INIT INFO -# Provides: facilitator-reg-url -# Required-Start: $remote_fs $syslog -# Required-Stop: $remote_fs $syslog -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Short-Description: Flash proxy URL registration helper. -# Description: Debian init script for the flash proxy URL registration daemon. -### END INIT INFO -# -# Author: Alexandre Allaire alexandre.allaire@mail.mcgill.ca -# - -# Based on /etc/init.d/skeleton from Debian 6. - -PATH=/sbin:/usr/sbin:/bin:/usr/bin -DESC="Flash proxy URL registration daemon." -NAME=facilitator-reg-url -PIDFILE=/var/run/$NAME.pid -LOGFILE=/var/log/$NAME.log -CONFDIR=/etc/flashproxy -DAEMON=/usr/local/bin/$NAME -DAEMON_ARGS="--key $CONFDIR/reg-url.key --log $LOGFILE --pidfile $PIDFILE" -SCRIPTNAME=/etc/init.d/$NAME - -# Exit if the package is not installed -[ -x "$DAEMON" ] || exit 0 - -. /lib/init/vars.sh -. /lib/lsb/init-functions - -# -# Function that starts the daemon/service -# -do_start() -{ - # Return - # 0 if daemon has been started - # 1 if daemon was already running - # 2 if daemon could not be started - start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \ - || return 1 - start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \ - $DAEMON_ARGS \ - || return 2 -} - -# -# Function that stops the daemon/service -# -do_stop() -{ - # Return - # 0 if daemon has been stopped - # 1 if daemon was already stopped - # 2 if daemon could not be stopped - # other if a failure occurred - start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE - RETVAL="$?" - [ "$RETVAL" = 2 ] && return 2 - # Wait for children to finish too if this is a daemon that forks - # and if the daemon is only ever run from this initscript. - # If the above conditions are not satisfied then add some other code - # that waits for the process to drop all resources that could be - # needed by services started subsequently. A last resort is to - # sleep for some time. - start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON - [ "$?" = 2 ] && return 2 - rm -f $PIDFILE - return "$RETVAL" -} - -case "$1" in - start) - [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" - do_start - case "$?" in - 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; - 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; - esac - ;; - stop) - [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" - do_stop - case "$?" in - 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; - 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; - esac - ;; - status) - status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $? - ;; - restart|force-reload) - log_daemon_msg "Restarting $DESC" "$NAME" - do_stop - case "$?" in - 0|1) - do_start - case "$?" in - 0) log_end_msg 0 ;; - 1) log_end_msg 1 ;; # Old process is still running - *) log_end_msg 1 ;; # Failed to start - esac - ;; - *) - # Failed to stop - log_end_msg 1 - ;; - esac - ;; - *) - echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 - exit 3 - ;; -esac - -:
tor-commits@lists.torproject.org