mirror of https://github.com/fail2ban/fail2ban
Merge branch '0.10' into 0.11
commit
93634dd822
|
@ -164,7 +164,11 @@ class FilterPoll(FileFilter):
|
||||||
return False
|
return False
|
||||||
# log error:
|
# log error:
|
||||||
if self.__file404Cnt[filename] < 2:
|
if self.__file404Cnt[filename] < 2:
|
||||||
logSys.error("Unable to get stat on %s because of: %s",
|
if e.errno == 2:
|
||||||
|
logSys.debug("Log absence detected (possibly rotation) for %s, reason: %s",
|
||||||
|
filename, e)
|
||||||
|
else: # pragma: no cover
|
||||||
|
logSys.error("Unable to get stat on %s because of: %s",
|
||||||
filename, e,
|
filename, e,
|
||||||
exc_info=logSys.getEffectiveLevel()<=logging.DEBUG)
|
exc_info=logSys.getEffectiveLevel()<=logging.DEBUG)
|
||||||
# increase file and common error counters:
|
# increase file and common error counters:
|
||||||
|
@ -175,3 +179,6 @@ class FilterPoll(FileFilter):
|
||||||
self.__file404Cnt[filename] = 0
|
self.__file404Cnt[filename] = 0
|
||||||
self.delLogPath(filename)
|
self.delLogPath(filename)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def getPendingPaths(self):
|
||||||
|
return self.__file404Cnt.keys()
|
||||||
|
|
|
@ -161,6 +161,9 @@ class FilterPyinotify(FileFilter):
|
||||||
del self.__pending[path]
|
del self.__pending[path]
|
||||||
except KeyError: pass
|
except KeyError: pass
|
||||||
|
|
||||||
|
def getPendingPaths(self):
|
||||||
|
return self.__pending.keys()
|
||||||
|
|
||||||
def _checkPending(self):
|
def _checkPending(self):
|
||||||
if not self.__pending:
|
if not self.__pending:
|
||||||
return
|
return
|
||||||
|
@ -225,7 +228,11 @@ class FilterPyinotify(FileFilter):
|
||||||
def _delFileWatcher(self, path):
|
def _delFileWatcher(self, path):
|
||||||
try:
|
try:
|
||||||
wdInt = self.__watchFiles.pop(path)
|
wdInt = self.__watchFiles.pop(path)
|
||||||
wd = self.__monitor.rm_watch(wdInt)
|
if self.__monitor.get_path(wdInt) is not None:
|
||||||
|
wd = self.__monitor.rm_watch(wdInt)
|
||||||
|
else: # pragma: no cover
|
||||||
|
logSys.debug("Non-existing file watcher %r for file %s", wdInt, path)
|
||||||
|
wd = {wdInt: 1}
|
||||||
if wd[wdInt]:
|
if wd[wdInt]:
|
||||||
logSys.debug("Removed file watcher for %s", path)
|
logSys.debug("Removed file watcher for %s", path)
|
||||||
return True
|
return True
|
||||||
|
@ -249,7 +256,10 @@ class FilterPyinotify(FileFilter):
|
||||||
# Remove watches for the directory:
|
# Remove watches for the directory:
|
||||||
try:
|
try:
|
||||||
wdInt = self.__watchDirs.pop(path_dir)
|
wdInt = self.__watchDirs.pop(path_dir)
|
||||||
self.__monitor.rm_watch(wdInt)
|
if self.__monitor.get_path(wdInt) is not None:
|
||||||
|
self.__monitor.rm_watch(wdInt)
|
||||||
|
else: # pragma: no cover
|
||||||
|
logSys.debug("Non-existing file watcher %r for directory %s", wdInt, path_dir)
|
||||||
except KeyError: # pragma: no cover
|
except KeyError: # pragma: no cover
|
||||||
pass
|
pass
|
||||||
# EnvironmentError is parent of IOError, OSError, etc.
|
# EnvironmentError is parent of IOError, OSError, etc.
|
||||||
|
|
|
@ -980,6 +980,18 @@ def get_monitor_failures_testcase(Filter_):
|
||||||
self.assert_correct_last_attempt(GetFailures.FAILURES_01)
|
self.assert_correct_last_attempt(GetFailures.FAILURES_01)
|
||||||
self.assertEqual(self.filter.failManager.getFailTotal(), 6)
|
self.assertEqual(self.filter.failManager.getFailTotal(), 6)
|
||||||
|
|
||||||
|
def test_del_file(self):
|
||||||
|
# test filter reaction by delete watching file:
|
||||||
|
self.file.close()
|
||||||
|
self.waitForTicks(1)
|
||||||
|
# remove file (cause detection of log-rotation)...
|
||||||
|
os.unlink(self.name)
|
||||||
|
# check it was detected (in pending files):
|
||||||
|
self.waitForTicks(2)
|
||||||
|
if hasattr(self.filter, "getPendingPaths"):
|
||||||
|
self.assertTrue(Utils.wait_for(lambda: self.name in self.filter.getPendingPaths(), _maxWaitTime(10)))
|
||||||
|
self.assertEqual(len(self.filter.getPendingPaths()), 1)
|
||||||
|
|
||||||
@with_tmpdir
|
@with_tmpdir
|
||||||
def test_move_dir(self, tmp):
|
def test_move_dir(self, tmp):
|
||||||
self.file.close()
|
self.file.close()
|
||||||
|
|
Loading…
Reference in New Issue