From 95bdcdecaaa0419785614c22afc57165fcbb29dc Mon Sep 17 00:00:00 2001 From: sebres Date: Fri, 10 Oct 2014 16:49:08 +0200 Subject: [PATCH] cache-config-read-v2 merged; logging normalized, set log level for loading (read or use shared) file(s) to INFO; prevent to read some files twice by read inside "_getIncludes" and by "read" self (occurred by only one file); --- fail2ban/client/configparserinc.py | 10 ++++------ fail2ban/client/configreader.py | 5 ++--- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/fail2ban/client/configparserinc.py b/fail2ban/client/configparserinc.py index 1687f87f..d819281b 100644 --- a/fail2ban/client/configparserinc.py +++ b/fail2ban/client/configparserinc.py @@ -195,7 +195,7 @@ after = 1.conf def get_sections(self): return self._sections - def read(self, filenames, get_includes=True, log_info=None): + def read(self, filenames, get_includes=True): if not isinstance(filenames, list): filenames = [ filenames ] # retrieve (and cache) includes: @@ -208,11 +208,9 @@ after = 1.conf if not fileNamesFull: return [] - if logSys.getEffectiveLevel() <= logLevel: - logSys.log(logLevel, (" Sharing files: %s" if self._cfg_share is not None else \ - " Reading files: %s"), fileNamesFull) + logSys.info(" Loading files: %s", fileNamesFull) - if len(fileNamesFull) > 1: + if get_includes or len(fileNamesFull) > 1: # read multiple configs: ret = [] alld = self.get_defaults() @@ -238,7 +236,7 @@ after = 1.conf # read one config : if logSys.getEffectiveLevel() <= logLevel: - logSys.log(logLevel, " Reading file: %s", fileNamesFull[0]) + logSys.log(logLevel, " Reading file: %s", fileNamesFull[0]) # read file(s) : if sys.version_info >= (3,2): # pragma: no cover return SafeConfigParser.read(self, fileNamesFull, encoding='utf-8') diff --git a/fail2ban/client/configreader.py b/fail2ban/client/configreader.py index bd2e5f0c..9e3bf90f 100644 --- a/fail2ban/client/configreader.py +++ b/fail2ban/client/configreader.py @@ -77,9 +77,8 @@ class ConfigReader(): if once and self._cfg.read_cfg_files is not None: return self._cfg.read_cfg_files - # read: - if self._cfg_share is not None: - logSys.info("Sharing configs for %s under %s ", name, self._cfg.getBaseDir()) + # load: + logSys.info("Loading configs for %s under %s ", name, self._cfg.getBaseDir()) ret = self._cfg.read(name) # save already read and return: