diff --git a/fail2ban/client/actionreader.py b/fail2ban/client/actionreader.py index b11deaba..6b0334ac 100644 --- a/fail2ban/client/actionreader.py +++ b/fail2ban/client/actionreader.py @@ -34,11 +34,11 @@ logSys = logging.getLogger(__name__) class ActionReader(DefinitionInitConfigReader): _configOpts = [ - ["string", "actionstart", ""], - ["string", "actionstop", ""], - ["string", "actioncheck", ""], - ["string", "actionban", ""], - ["string", "actionunban", ""], + ["string", "actionstart", None], + ["string", "actionstop", None], + ["string", "actioncheck", None], + ["string", "actionban", None], + ["string", "actionunban", None], ] def __init__(self, file_, jailName, initOpts, **kwargs): diff --git a/fail2ban/client/configreader.py b/fail2ban/client/configreader.py index dacf3e57..51ca6948 100644 --- a/fail2ban/client/configreader.py +++ b/fail2ban/client/configreader.py @@ -120,6 +120,10 @@ class ConfigReader(SafeConfigParserWithIncludes): logSys.warning("'%s' not defined in '%s'. Using default one: %r" % (option[1], sec, option[2])) values[option[1]] = option[2] + else: + logSys.debug( + "Non essential option '%s' not defined in '%s'.", + option[1], sec) except ValueError: logSys.warning("Wrong value for '" + option[1] + "' in '" + sec + "'. Using default one: '" + `option[2]` + "'") diff --git a/fail2ban/client/filterreader.py b/fail2ban/client/filterreader.py index 612fd350..5a11dc41 100644 --- a/fail2ban/client/filterreader.py +++ b/fail2ban/client/filterreader.py @@ -35,7 +35,7 @@ logSys = logging.getLogger(__name__) class FilterReader(DefinitionInitConfigReader): _configOpts = [ - ["string", "ignoreregex", ""], + ["string", "ignoreregex", None], ["string", "failregex", ""], ] diff --git a/fail2ban/client/jailreader.py b/fail2ban/client/jailreader.py index 42c04ffb..5735b021 100644 --- a/fail2ban/client/jailreader.py +++ b/fail2ban/client/jailreader.py @@ -68,7 +68,8 @@ class JailReader(ConfigReader): return out def isEnabled(self): - return self.__force_enable or ( self.__opts and self.__opts["enabled"] ) + return self.__force_enable or ( + self.__opts and self.__opts.get("enabled", False)) @staticmethod def _glob(path): @@ -85,14 +86,14 @@ class JailReader(ConfigReader): return pathList def getOptions(self): - opts = [["bool", "enabled", "false"], - ["string", "logpath", "/var/log/messages"], - ["string", "logencoding", "auto"], + opts = [["bool", "enabled", False], + ["string", "logpath", None], + ["string", "logencoding", None], ["string", "backend", "auto"], - ["int", "maxretry", 3], - ["int", "findtime", 600], - ["int", "bantime", 600], - ["string", "usedns", "warn"], + ["int", "maxretry", None], + ["int", "findtime", None], + ["int", "bantime", None], + ["string", "usedns", None], ["string", "failregex", None], ["string", "ignoreregex", None], ["string", "ignorecommand", None], diff --git a/fail2ban/server/filter.py b/fail2ban/server/filter.py index c82395ea..fb5aeb3d 100644 --- a/fail2ban/server/filter.py +++ b/fail2ban/server/filter.py @@ -63,7 +63,7 @@ class Filter(JailThread): ## Use DNS setting self.setUseDns(useDns) ## The amount of time to look back. - self.__findTime = 6000 + self.__findTime = 600 ## The ignore IP list. self.__ignoreIpList = [] ## Size of line buffer diff --git a/fail2ban/tests/clientreadertestcase.py b/fail2ban/tests/clientreadertestcase.py index fd65b014..ce19a50e 100644 --- a/fail2ban/tests/clientreadertestcase.py +++ b/fail2ban/tests/clientreadertestcase.py @@ -349,31 +349,9 @@ class JailsReaderTest(LogCaptureTestCase): self.maxDiff = None self.assertEqual(sorted(comm_commands), sorted([['add', 'emptyaction', 'auto'], - ['set', 'emptyaction', 'usedns', 'warn'], - ['set', 'emptyaction', 'maxretry', 3], - ['set', 'emptyaction', 'findtime', 600], - ['set', 'emptyaction', 'logencoding', 'auto'], - ['set', 'emptyaction', 'bantime', 600], - ['add', 'special', 'auto'], - ['set', 'special', 'usedns', 'warn'], - ['set', 'special', 'maxretry', 3], - ['set', 'special', 'addfailregex', ''], - ['set', 'special', 'findtime', 600], - ['set', 'special', 'logencoding', 'auto'], - ['set', 'special', 'bantime', 600], ['add', 'missinglogfiles', 'auto'], - ['set', 'missinglogfiles', 'usedns', 'warn'], - ['set', 'missinglogfiles', 'maxretry', 3], - ['set', 'missinglogfiles', 'findtime', 600], - ['set', 'missinglogfiles', 'logencoding', 'auto'], - ['set', 'missinglogfiles', 'bantime', 600], ['set', 'missinglogfiles', 'addfailregex', ''], ['add', 'brokenaction', 'auto'], - ['set', 'brokenaction', 'usedns', 'warn'], - ['set', 'brokenaction', 'maxretry', 3], - ['set', 'brokenaction', 'findtime', 600], - ['set', 'brokenaction', 'logencoding', 'auto'], - ['set', 'brokenaction', 'bantime', 600], ['set', 'brokenaction', 'addfailregex', ''], ['set', 'brokenaction', 'addaction', 'brokenaction'], ['set', @@ -382,23 +360,9 @@ class JailsReaderTest(LogCaptureTestCase): 'brokenaction', 'actionban', 'hit with big stick '], - ['set', 'brokenaction', 'action', 'brokenaction', - 'actionstop', ''], - ['set', 'brokenaction', 'action', 'brokenaction', - 'actionstart', ''], - ['set', 'brokenaction', 'action', 'brokenaction', - 'actionunban', ''], - ['set', 'brokenaction', 'action', 'brokenaction', - 'actioncheck', ''], ['add', 'parse_to_end_of_jail.conf', 'auto'], - ['set', 'parse_to_end_of_jail.conf', 'usedns', 'warn'], - ['set', 'parse_to_end_of_jail.conf', 'maxretry', 3], - ['set', 'parse_to_end_of_jail.conf', 'findtime', 600], - ['set', 'parse_to_end_of_jail.conf', 'logencoding', 'auto'], - ['set', 'parse_to_end_of_jail.conf', 'bantime', 600], ['set', 'parse_to_end_of_jail.conf', 'addfailregex', ''], ['start', 'emptyaction'], - ['start', 'special'], ['start', 'missinglogfiles'], ['start', 'brokenaction'], ['start', 'parse_to_end_of_jail.conf'],])) @@ -572,6 +536,7 @@ class JailsReaderTest(LogCaptureTestCase): jailfd = open(os.path.join(basedir, "jail.conf"), 'w') jailfd.write(""" [testjail1] +enabled = true action = testaction1[actname=test1] testaction1[actname=test2] testaction.py diff --git a/fail2ban/tests/config/jail.conf b/fail2ban/tests/config/jail.conf index 525308e3..0f6a28f0 100644 --- a/fail2ban/tests/config/jail.conf +++ b/fail2ban/tests/config/jail.conf @@ -14,6 +14,7 @@ ignoreregex = ignoreip = [missinglogfiles] +enabled = true logpath = /weapons/of/mass/destruction [brokenactiondef] @@ -25,6 +26,7 @@ enabled = true action = brokenaction [missingbitsjail] +enabled = true filter = catchallthebadies action = thefunkychickendance