aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbnewbold <bnewbold@robocracy.org>2012-07-12 20:26:24 -0400
committerbnewbold <bnewbold@robocracy.org>2012-07-12 20:26:24 -0400
commit82da70ad92f82dc2bedf26cbbd057a758e94960e (patch)
treeb291576c552e233c6aa56d81aaff2859984cb01c
parent47543de6fa707b8f82d9b7c9c8af0fda02971f0e (diff)
downloadexmachina-82da70ad92f82dc2bedf26cbbd057a758e94960e.tar.gz
exmachina-82da70ad92f82dc2bedf26cbbd057a758e94960e.zip
pidfile not pid_file; no auth ok
-rwxr-xr-xexmachina.py13
-rwxr-xr-xinit_test.sh2
2 files changed, 9 insertions, 6 deletions
diff --git a/exmachina.py b/exmachina.py
index 35559da..fc04beb 100755
--- a/exmachina.py
+++ b/exmachina.py
@@ -88,6 +88,9 @@ class ExMachinaHandler(bjsonrpc.handlers.BaseHandler):
self.augeas = augeas.Augeas()
def authenticate(self, secret_key):
+ if not self.secret_key:
+ log.warn("Unecessary authentication attempt")
+ return
if not secret_key.strip() == self.secret_key.strip():
# fail hard
log.error("Authentication failed!")
@@ -300,7 +303,7 @@ def main():
default="/tmp/exmachina.sock",
help="UNIX Domain socket file path to listen on",
metavar="FILE")
- parser.add_option("--pid-file",
+ parser.add_option("--pidfile",
default=None,
help="Daemonize and write pid to this file",
metavar="FILE")
@@ -333,14 +336,14 @@ def main():
secret_key = sys.stdin.readline().strip()
log.debug("Got it!")
- if options.pid_file:
- with open(options.pid_file, 'w') as pfile:
+ if options.pidfile:
+ with open(options.pidfile, 'w') as pfile:
# ensure file is available/writable
pass
- os.unlink(options.pid_file)
+ os.unlink(options.pidfile)
daemonize()
pid = os.getpid()
- with open(options.pid_file, 'w') as pfile:
+ with open(options.pidfile, 'w') as pfile:
pfile.write("%s" % pid)
log.info("Daemonized, pid is %s" % pid)
diff --git a/init_test.sh b/init_test.sh
index 4a00734..ab4e717 100755
--- a/init_test.sh
+++ b/init_test.sh
@@ -6,7 +6,7 @@ export key=`./exmachina.py --random-key`
echo $key | ./exmachina.py -vk --pid-file /tmp/exmachina_test.pid
sleep 1
-echo $key | sudo -u www-data ./test_exmachina.py -k
+echo $key | sudo -u www-data -g www-data ./test_exmachina.py -k
kill `cat /tmp/exmachina_test.pid` && rm /tmp/exmachina_test.pid
sleep 1