From 82da70ad92f82dc2bedf26cbbd057a758e94960e Mon Sep 17 00:00:00 2001 From: bnewbold Date: Thu, 12 Jul 2012 20:26:24 -0400 Subject: pidfile not pid_file; no auth ok --- exmachina.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'exmachina.py') 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) -- cgit v1.2.3