From: Adrian Likins Date: Mon, 17 Mar 2008 22:16:19 +0000 (-0400) Subject: certmaster logging cleanups X-Git-Tag: v0.20~10 X-Git-Url: https://pwan.org/git/?a=commitdiff_plain;h=c3e4dd36b5723f95202d0446e96a9d0b00246eac;p=certmaster.git certmaster logging cleanups - use unique name for the certmaster logs - some not quite working code for passing down client info so we can log --- diff --git a/certmaster.spec b/certmaster.spec index 3a04a72..bb252cc 100644 --- a/certmaster.spec +++ b/certmaster.spec @@ -99,7 +99,7 @@ fi %changelog -* Mon March 17 2008 Adrian Likins - 0.1-2 +* Mon Mar 17 2008 Adrian Likins - 0.1-2 - removed unused minion/ and overlord/ dirs * Mon Feb 25 2008 Adrian Likins - 0.1-1 diff --git a/certmaster/certmaster.py b/certmaster/certmaster.py index 88ea265..18c02d4 100755 --- a/certmaster/certmaster.py +++ b/certmaster/certmaster.py @@ -48,7 +48,7 @@ class CertMaster(object): self.ca_cert_file = '%s/certmaster.crt' % self.cfg.cadir self.logger = logger.Logger().logger - self.audit_logger = logger.AuditLogger().logger + self.audit_logger = logger.AuditLogger() try: if not os.path.exists(self.cfg.cadir): @@ -77,7 +77,7 @@ class CertMaster(object): if method == 'trait_names' or method == '_getAttributeNames': return self.handlers.keys() -# ip = self.client_address +# ip = self._this_request # print ip # self.audit_logger.log_call(ip, method, params) @@ -229,10 +229,22 @@ class CertMaster(object): return certfile +# not used yet, trying to figure out a way to get the client ip addr to log -akl +class CertmasterXMLRPCRequestHandler(SimpleXMLRPCServer.SimpleXMLRPCRequestHandler): + def do_POST(self): + self.server._this_request = (self.request, self.client_address) + try: + SimpleXMLRPCServer.SimpleXMLRPCRequestHandler.do_POST(self) + except socket.timeout: + pass + except (socket.error, OpenSSL.SSL.SysCallError), e: + print "Error (%s): socket error - '%s'" % (self.client_address, e) + + class CertmasterXMLRPCServer(SimpleXMLRPCServer.SimpleXMLRPCServer): - def __init__(self, args): + def __init__(self, addr): self.allow_reuse_address = True - SimpleXMLRPCServer.SimpleXMLRPCServer.__init__(self, args) + SimpleXMLRPCServer.SimpleXMLRPCServer.__init__(self, addr) def serve(xmlrpcinstance): @@ -241,11 +253,12 @@ def serve(xmlrpcinstance): Code for starting the XMLRPC service. """ + server = CertmasterXMLRPCServer((xmlrpcinstance.cfg.listen_addr, CERTMASTER_LISTEN_PORT)) server.logRequests = 0 # don't print stuff to console server.register_instance(xmlrpcinstance) xmlrpcinstance.logger.info("certmaster started") - xmlrpcinstance.audit_logger.info("certmaster started") + xmlrpcinstance.audit_logger.logger.info("certmaster started") server.serve_forever() diff --git a/certmaster/logger.py b/certmaster/logger.py index 3a7e0ad..3ff9d42 100755 --- a/certmaster/logger.py +++ b/certmaster/logger.py @@ -40,7 +40,7 @@ class Logger(Singleton): self._setup_handlers(logfilepath=logfilepath) def _setup_logging(self): - self.logger = logging.getLogger("svc") + self.logger = logging.getLogger("certmaster") def _setup_handlers(self, logfilepath="/var/log/certmaster/certmaster.log"): handler = logging.FileHandler(logfilepath, "a") @@ -54,6 +54,7 @@ class Logger(Singleton): class AuditLogger(Singleton): _no_handlers = True def __init__(self, logfilepath = "/var/log/certmaster/audit.log"): + self.logfilepath = logfilepath self.loglevel = logging.INFO self._setup_logging() if self._no_handlers: @@ -65,7 +66,7 @@ class AuditLogger(Singleton): def _setup_logging(self): - self.logger = logging.getLogger("audit") + self.logger = logging.getLogger("certmaster-audit") def _setup_handlers(self, logfilepath="/var/log/certmaster/audit.log"): handler = logging.FileHandler(logfilepath, "a")