From c36de46938255f1e16861981db3c59990e6f7b0c Mon Sep 17 00:00:00 2001 From: Adrian Likins Date: Fri, 28 Sep 2007 13:15:14 -0400 Subject: log the ip address of the requester to the audit.log also ditch the "INFO" blurb in the log, since we don't really log at any other level --- func/logger.py | 6 +++--- minion/server.py | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/func/logger.py b/func/logger.py index 681576e..cdfa899 100755 --- a/func/logger.py +++ b/func/logger.py @@ -61,9 +61,9 @@ class AuditLogger(Singleton): if self._no_handlers: self._setup_handlers(logfilepath=logfilepath) - def log_call(self, CN, cert_hash, method, params): + def log_call(self, ip, CN, cert_hash, method, params): # square away a good parseable format at some point -akl - self.logger.info("%s %s %s called with %s" % (CN, cert_hash, method, params)) + self.logger.info("%s %s %s %s called with %s" % (ip, CN, cert_hash, method, params)) def _setup_logging(self): @@ -72,7 +72,7 @@ class AuditLogger(Singleton): def _setup_handlers(self, logfilepath="/var/log/func/audit.log"): handler = logging.FileHandler(logfilepath, "a") self.logger.setLevel(self.loglevel) - formatter = logging.Formatter("%(asctime)s - %(levelname)s - %(message)s") + formatter = logging.Formatter("%(asctime)s - %(message)s") handler.setFormatter(formatter) self.logger.addHandler(handler) self._no_handlers = False diff --git a/minion/server.py b/minion/server.py index fcfe537..7c2c149 100755 --- a/minion/server.py +++ b/minion/server.py @@ -192,6 +192,7 @@ class FuncSSLXMLRPCServer(AuthedXMLRPCServer.AuthedSSLXMLRPCServer, if hasattr(self, '_this_request'): r,a = self._this_request p = r.get_peer_certificate() + ip = a[0] cn = p.get_subject().CN sub_hash = p.subject_name_hash() else: @@ -199,7 +200,7 @@ class FuncSSLXMLRPCServer(AuthedXMLRPCServer.AuthedSSLXMLRPCServer, # XXX FIXME - need to figure out how to dig into the server base classes # so we can get client ip, and eventually cert id info -akl - self.audit_logger.log_call(cn, sub_hash, method, params) + self.audit_logger.log_call(ip, cn, sub_hash, method, params) return self.get_dispatch_method(method)(*params) -- cgit