From bc2b81133c2c5a460673ddab54fe30bcc2af9ecd Mon Sep 17 00:00:00 2001 From: sebres Date: Fri, 13 Mar 2020 22:07:32 +0100 Subject: [PATCH] pyinotify backend: guarantees initial scanning of log-file by start (retarded via pending event if filter not yet active) --- ChangeLog | 1 + fail2ban/server/filterpyinotify.py | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 6a6b4451..3781f467 100644 --- a/ChangeLog +++ b/ChangeLog @@ -34,6 +34,7 @@ ver. 0.10.6-dev (20??/??/??) - development edition ### Fixes * [stability] prevent race condition - no ban if filter (backend) is continuously busy if too many messages will be found in log, e. g. initial scan of large log-file or journal (gh-2660) +* pyinotify-backend sporadically avoided initial scanning of log-file by start * python 3.9 compatibility (and Travis CI support) * restoring a large number (500+ depending on files ulimit) of current bans when using PyPy fixed * manual ban is written to database, so can be restored by restart (gh-2647) diff --git a/fail2ban/server/filterpyinotify.py b/fail2ban/server/filterpyinotify.py index 185305ca..6d0172da 100644 --- a/fail2ban/server/filterpyinotify.py +++ b/fail2ban/server/filterpyinotify.py @@ -271,7 +271,13 @@ class FilterPyinotify(FileFilter): def _addLogPath(self, path): self._addFileWatcher(path) - self._process_file(path) + # initial scan: + if self.active: + # we can execute it right now: + self._process_file(path) + else: + # retard until filter gets started: + self._addPending(path, ('INITIAL', path)) ## # Delete a log path