mirror of https://github.com/fail2ban/fail2ban
BF: fail2ban now don't print maxlines twice when using ignoreregex
Also read failregex first, as more natural place to get maxlines value from.pull/285/head
parent
6df949b29a
commit
3dbe2c04ca
|
@ -199,6 +199,7 @@ class Fail2banRegex(object):
|
||||||
if not self._maxlines_set:
|
if not self._maxlines_set:
|
||||||
self._filter.setMaxLines(int(v))
|
self._filter.setMaxLines(int(v))
|
||||||
self._maxlines_set = True
|
self._maxlines_set = True
|
||||||
|
print "Use maxlines : %d" % self._filter.getMaxLines()
|
||||||
|
|
||||||
def setJournalMatch(self, v):
|
def setJournalMatch(self, v):
|
||||||
if self._journalmatch is None:
|
if self._journalmatch is None:
|
||||||
|
@ -236,8 +237,6 @@ class Fail2banRegex(object):
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
self.setMaxLines(maxlines)
|
self.setMaxLines(maxlines)
|
||||||
print "Use maxlines : %d" % (
|
|
||||||
self._filter.getMaxLines(), )
|
|
||||||
except ValueError:
|
except ValueError:
|
||||||
print "ERROR: Invalid value for maxlines (%(maxlines)r) " \
|
print "ERROR: Invalid value for maxlines (%(maxlines)r) " \
|
||||||
"read from %(value)s" % locals()
|
"read from %(value)s" % locals()
|
||||||
|
@ -432,11 +431,11 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
cmd_log, cmd_regex = args[:2]
|
cmd_log, cmd_regex = args[:2]
|
||||||
|
|
||||||
|
fail2banRegex.readRegex(cmd_regex, 'fail') or sys.exit(-1)
|
||||||
|
|
||||||
if len(args) == 3:
|
if len(args) == 3:
|
||||||
fail2banRegex.readRegex(args[2], 'ignore') or sys.exit(-1)
|
fail2banRegex.readRegex(args[2], 'ignore') or sys.exit(-1)
|
||||||
|
|
||||||
fail2banRegex.readRegex(cmd_regex, 'fail') or sys.exit(-1)
|
|
||||||
|
|
||||||
if os.path.isfile(cmd_log):
|
if os.path.isfile(cmd_log):
|
||||||
try:
|
try:
|
||||||
hdlr = open(cmd_log, 'rb')
|
hdlr = open(cmd_log, 'rb')
|
||||||
|
|
Loading…
Reference in New Issue