diff options
author | Steven Hiscocks <steven@hiscocks.me.uk> | 2013-06-29 20:31:26 +0100 |
---|---|---|
committer | Steven Hiscocks <steven@hiscocks.me.uk> | 2013-06-29 20:31:26 +0100 |
commit | 1dbba35cd963e7ee4000392f1c1d3cf7095df885 (patch) | |
tree | 8a109726a9860125d88c62e7377282b5322979b5 /bin/fail2ban-client | |
parent | 88bee24edb87e2c468ed53726c459ffcb8f831e2 (diff) | |
parent | b670b5c792bcdd6d49e25a84b52799a86b2abcfe (diff) | |
download | fail2ban-1dbba35cd963e7ee4000392f1c1d3cf7095df885.tar.gz |
Merge branch 'master' into 0.9
Conflicts:
fail2ban/client/jailreader.py
fail2ban/tests/clientreadertestcase.py
fail2ban/tests/files/logs/sshd
Diffstat (limited to 'bin/fail2ban-client')
-rwxr-xr-x | bin/fail2ban-client | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/bin/fail2ban-client b/bin/fail2ban-client index 26dadff8..0f84a15c 100755 --- a/bin/fail2ban-client +++ b/bin/fail2ban-client @@ -221,7 +221,7 @@ class Fail2banClient: elif len(cmd) == 2 and cmd[0] == "reload": if self.__ping(): jail = cmd[1] - ret = self.__readJailConfig(jail) + ret = self.__readConfig(jail) # Do not continue if configuration is not 100% valid if not ret: return False @@ -328,13 +328,13 @@ class Fail2banClient: logSys.setLevel(logging.INFO) else: logSys.setLevel(logging.DEBUG) - # Add the default logging handler - stdout = logging.StreamHandler(sys.stdout) + # Add the default logging handler to dump to stderr + logout = logging.StreamHandler(sys.stderr) # set a format which is simpler for console use formatter = logging.Formatter('%(levelname)-6s %(message)s') # tell the handler to use this format - stdout.setFormatter(formatter) - logSys.addHandler(stdout) + logout.setFormatter(formatter) + logSys.addHandler(logout) # Set the configuration path self.__configurator.setBaseDir(self.__conf["conf"]) @@ -386,19 +386,18 @@ class Fail2banClient: return False return self.__processCommand(args) - def __readConfig(self): + def __readConfig(self, jail=None): # Read the configuration - self.__configurator.readAll() - ret = self.__configurator.getOptions() - self.__configurator.convertToProtocol() - self.__stream = self.__configurator.getConfigStream() - return ret - - def __readJailConfig(self, jail): - self.__configurator.readAll() - ret = self.__configurator.getOptions(jail) - self.__configurator.convertToProtocol() - self.__stream = self.__configurator.getConfigStream() + # TODO: get away from stew of return codes and exception + # handling -- handle via exceptions + try: + self.__configurator.readAll() + ret = self.__configurator.getOptions(jail) + self.__configurator.convertToProtocol() + self.__stream = self.__configurator.getConfigStream() + except Exception, e: + logSys.error("Failed during configuration: %s" % e) + ret = False return ret #@staticmethod |