mirror of https://github.com/fail2ban/fail2ban
ENH: Suppress configuration warnings if non-critical options are not set
parent
096702bfac
commit
638c013557
|
@ -34,11 +34,11 @@ logSys = logging.getLogger(__name__)
|
||||||
class ActionReader(DefinitionInitConfigReader):
|
class ActionReader(DefinitionInitConfigReader):
|
||||||
|
|
||||||
_configOpts = [
|
_configOpts = [
|
||||||
["string", "actionstart", ""],
|
["string", "actionstart", None],
|
||||||
["string", "actionstop", ""],
|
["string", "actionstop", None],
|
||||||
["string", "actioncheck", ""],
|
["string", "actioncheck", None],
|
||||||
["string", "actionban", ""],
|
["string", "actionban", None],
|
||||||
["string", "actionunban", ""],
|
["string", "actionunban", None],
|
||||||
]
|
]
|
||||||
|
|
||||||
def __init__(self, file_, jailName, initOpts, **kwargs):
|
def __init__(self, file_, jailName, initOpts, **kwargs):
|
||||||
|
|
|
@ -120,6 +120,10 @@ class ConfigReader(SafeConfigParserWithIncludes):
|
||||||
logSys.warning("'%s' not defined in '%s'. Using default one: %r"
|
logSys.warning("'%s' not defined in '%s'. Using default one: %r"
|
||||||
% (option[1], sec, option[2]))
|
% (option[1], sec, option[2]))
|
||||||
values[option[1]] = option[2]
|
values[option[1]] = option[2]
|
||||||
|
else:
|
||||||
|
logSys.debug(
|
||||||
|
"Non essential option '%s' not defined in '%s'.",
|
||||||
|
option[1], sec)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
logSys.warning("Wrong value for '" + option[1] + "' in '" + sec +
|
logSys.warning("Wrong value for '" + option[1] + "' in '" + sec +
|
||||||
"'. Using default one: '" + `option[2]` + "'")
|
"'. Using default one: '" + `option[2]` + "'")
|
||||||
|
|
|
@ -35,7 +35,7 @@ logSys = logging.getLogger(__name__)
|
||||||
class FilterReader(DefinitionInitConfigReader):
|
class FilterReader(DefinitionInitConfigReader):
|
||||||
|
|
||||||
_configOpts = [
|
_configOpts = [
|
||||||
["string", "ignoreregex", ""],
|
["string", "ignoreregex", None],
|
||||||
["string", "failregex", ""],
|
["string", "failregex", ""],
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,8 @@ class JailReader(ConfigReader):
|
||||||
return out
|
return out
|
||||||
|
|
||||||
def isEnabled(self):
|
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
|
@staticmethod
|
||||||
def _glob(path):
|
def _glob(path):
|
||||||
|
@ -85,14 +86,14 @@ class JailReader(ConfigReader):
|
||||||
return pathList
|
return pathList
|
||||||
|
|
||||||
def getOptions(self):
|
def getOptions(self):
|
||||||
opts = [["bool", "enabled", "false"],
|
opts = [["bool", "enabled", False],
|
||||||
["string", "logpath", "/var/log/messages"],
|
["string", "logpath", None],
|
||||||
["string", "logencoding", "auto"],
|
["string", "logencoding", None],
|
||||||
["string", "backend", "auto"],
|
["string", "backend", "auto"],
|
||||||
["int", "maxretry", 3],
|
["int", "maxretry", None],
|
||||||
["int", "findtime", 600],
|
["int", "findtime", None],
|
||||||
["int", "bantime", 600],
|
["int", "bantime", None],
|
||||||
["string", "usedns", "warn"],
|
["string", "usedns", None],
|
||||||
["string", "failregex", None],
|
["string", "failregex", None],
|
||||||
["string", "ignoreregex", None],
|
["string", "ignoreregex", None],
|
||||||
["string", "ignorecommand", None],
|
["string", "ignorecommand", None],
|
||||||
|
|
|
@ -63,7 +63,7 @@ class Filter(JailThread):
|
||||||
## Use DNS setting
|
## Use DNS setting
|
||||||
self.setUseDns(useDns)
|
self.setUseDns(useDns)
|
||||||
## The amount of time to look back.
|
## The amount of time to look back.
|
||||||
self.__findTime = 6000
|
self.__findTime = 600
|
||||||
## The ignore IP list.
|
## The ignore IP list.
|
||||||
self.__ignoreIpList = []
|
self.__ignoreIpList = []
|
||||||
## Size of line buffer
|
## Size of line buffer
|
||||||
|
|
|
@ -349,31 +349,9 @@ class JailsReaderTest(LogCaptureTestCase):
|
||||||
self.maxDiff = None
|
self.maxDiff = None
|
||||||
self.assertEqual(sorted(comm_commands),
|
self.assertEqual(sorted(comm_commands),
|
||||||
sorted([['add', 'emptyaction', 'auto'],
|
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', '<IP>'],
|
|
||||||
['set', 'special', 'findtime', 600],
|
|
||||||
['set', 'special', 'logencoding', 'auto'],
|
|
||||||
['set', 'special', 'bantime', 600],
|
|
||||||
['add', 'missinglogfiles', 'auto'],
|
['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', '<IP>'],
|
['set', 'missinglogfiles', 'addfailregex', '<IP>'],
|
||||||
['add', 'brokenaction', 'auto'],
|
['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', '<IP>'],
|
['set', 'brokenaction', 'addfailregex', '<IP>'],
|
||||||
['set', 'brokenaction', 'addaction', 'brokenaction'],
|
['set', 'brokenaction', 'addaction', 'brokenaction'],
|
||||||
['set',
|
['set',
|
||||||
|
@ -382,23 +360,9 @@ class JailsReaderTest(LogCaptureTestCase):
|
||||||
'brokenaction',
|
'brokenaction',
|
||||||
'actionban',
|
'actionban',
|
||||||
'hit with big stick <ip>'],
|
'hit with big stick <ip>'],
|
||||||
['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'],
|
['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', '<IP>'],
|
['set', 'parse_to_end_of_jail.conf', 'addfailregex', '<IP>'],
|
||||||
['start', 'emptyaction'],
|
['start', 'emptyaction'],
|
||||||
['start', 'special'],
|
|
||||||
['start', 'missinglogfiles'],
|
['start', 'missinglogfiles'],
|
||||||
['start', 'brokenaction'],
|
['start', 'brokenaction'],
|
||||||
['start', 'parse_to_end_of_jail.conf'],]))
|
['start', 'parse_to_end_of_jail.conf'],]))
|
||||||
|
@ -572,6 +536,7 @@ class JailsReaderTest(LogCaptureTestCase):
|
||||||
jailfd = open(os.path.join(basedir, "jail.conf"), 'w')
|
jailfd = open(os.path.join(basedir, "jail.conf"), 'w')
|
||||||
jailfd.write("""
|
jailfd.write("""
|
||||||
[testjail1]
|
[testjail1]
|
||||||
|
enabled = true
|
||||||
action = testaction1[actname=test1]
|
action = testaction1[actname=test1]
|
||||||
testaction1[actname=test2]
|
testaction1[actname=test2]
|
||||||
testaction.py
|
testaction.py
|
||||||
|
|
|
@ -14,6 +14,7 @@ ignoreregex =
|
||||||
ignoreip =
|
ignoreip =
|
||||||
|
|
||||||
[missinglogfiles]
|
[missinglogfiles]
|
||||||
|
enabled = true
|
||||||
logpath = /weapons/of/mass/destruction
|
logpath = /weapons/of/mass/destruction
|
||||||
|
|
||||||
[brokenactiondef]
|
[brokenactiondef]
|
||||||
|
@ -25,6 +26,7 @@ enabled = true
|
||||||
action = brokenaction
|
action = brokenaction
|
||||||
|
|
||||||
[missingbitsjail]
|
[missingbitsjail]
|
||||||
|
enabled = true
|
||||||
filter = catchallthebadies
|
filter = catchallthebadies
|
||||||
action = thefunkychickendance
|
action = thefunkychickendance
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue