mirror of https://github.com/fail2ban/fail2ban
filter.py: repair start-time of initial seek to time (regardless the position of `findtime` option in config);
jailreader.py: additionally relocate the option `logpath` after all log-related data (backend, date-pattern, etc) that may be needed by the first usage (gh-2173). Thanks to Matt Stancliff (mattsta)pull/2173/head
parent
00a0e98041
commit
1eb93e2556
|
@ -93,9 +93,6 @@ class JailReader(ConfigReader):
|
|||
["string", "backend", "auto"],
|
||||
["int", "maxretry", None],
|
||||
["string", "findtime", None],
|
||||
["string", "logpath", None],
|
||||
["string", "logtimezone", None],
|
||||
["string", "logencoding", None],
|
||||
["string", "bantime", None],
|
||||
["string", "usedns", None], # be sure usedns is before all regex(s) in stream
|
||||
["string", "failregex", None],
|
||||
|
@ -105,6 +102,9 @@ class JailReader(ConfigReader):
|
|||
["string", "ignoreip", None],
|
||||
["string", "filter", ""],
|
||||
["string", "datepattern", None],
|
||||
["string", "logtimezone", None],
|
||||
["string", "logencoding", None],
|
||||
["string", "logpath", None], # logpath after all log-related data (backend, date-pattern, etc)
|
||||
["string", "action", ""]]
|
||||
|
||||
# Before interpolation (substitution) add static options always available as default:
|
||||
|
|
|
@ -887,9 +887,6 @@ class FileFilter(Filter):
|
|||
self.__logs[path] = log
|
||||
logSys.info("Added logfile: %r (pos = %s, hash = %s)" , path, log.getPos(), log.getHash())
|
||||
if autoSeek:
|
||||
# if default, seek to "current time" - "find time":
|
||||
if isinstance(autoSeek, bool):
|
||||
autoSeek = MyTime.time() - self.getFindTime()
|
||||
self.__autoSeek[path] = autoSeek
|
||||
self._addLogPath(path) # backend specific
|
||||
|
||||
|
@ -999,18 +996,21 @@ class FileFilter(Filter):
|
|||
return False
|
||||
|
||||
# seek to find time for first usage only (prevent performance decline with polling of big files)
|
||||
if self.__autoSeek.get(filename):
|
||||
startTime = self.__autoSeek[filename]
|
||||
del self.__autoSeek[filename]
|
||||
# prevent completely read of big files first time (after start of service),
|
||||
# initial seek to start time using half-interval search algorithm:
|
||||
try:
|
||||
self.seekToTime(log, startTime)
|
||||
except Exception as e: # pragma: no cover
|
||||
logSys.error("Error during seek to start time in \"%s\"", filename)
|
||||
raise
|
||||
logSys.exception(e)
|
||||
return False
|
||||
if self.__autoSeek:
|
||||
startTime = self.__autoSeek.pop(filename, None)
|
||||
if startTime:
|
||||
# if default, seek to "current time" - "find time":
|
||||
if isinstance(startTime, bool):
|
||||
startTime = MyTime.time() - self.getFindTime()
|
||||
# prevent completely read of big files first time (after start of service),
|
||||
# initial seek to start time using half-interval search algorithm:
|
||||
try:
|
||||
self.seekToTime(log, startTime)
|
||||
except Exception as e: # pragma: no cover
|
||||
logSys.error("Error during seek to start time in \"%s\"", filename)
|
||||
raise
|
||||
logSys.exception(e)
|
||||
return False
|
||||
|
||||
if has_content:
|
||||
while not self.idle:
|
||||
|
|
Loading…
Reference in New Issue