[packages/fail2ban] add patch: log ban age + un-throttle backlog latency warning; rel 5
arekm
arekm at pld-linux.org
Wed Jul 22 09:14:04 CEST 2026
commit f73f086b39e73e0ae5150e281284bf269f5db440
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date: Wed Jul 22 09:10:49 2026 +0200
add patch: log ban age + un-throttle backlog latency warning; rel 5
"(age Ns)" on Ban lines + latency warning per-60s (was 1x/day) to tell a live ban from fail2ban working through a log backlog.
fail2ban-lag-visibility.patch | 57 +++++++++++++++++++++++++++++++++++++++++++
fail2ban.spec | 4 ++-
2 files changed, 60 insertions(+), 1 deletion(-)
---
diff --git a/fail2ban.spec b/fail2ban.spec
index 1aa70cc..7c9db97 100644
--- a/fail2ban.spec
+++ b/fail2ban.spec
@@ -2,7 +2,7 @@ Summary: Ban IPs that make too many password failures
Summary(pl.UTF-8): Blokowanie IP powodujących zbyt dużo prób logowań z błędnym hasłem
Name: fail2ban
Version: 1.1.0
-Release: 4
+Release: 5
License: GPL
Group: Daemons
Source0: https://github.com/fail2ban/fail2ban/archive/%{version}.tar.gz
@@ -16,6 +16,7 @@ Patch1: %{name}-config_from_git.patch
Patch2: %{name}-config_banaction.patch
Patch3: %{name}-no-distutils.patch
Patch4: %{name}-exec_module.patch
+Patch5: %{name}-lag-visibility.patch
URL: http://fail2ban.sourceforge.net/
BuildRequires: python3-devel
BuildRequires: python3-modules
@@ -50,6 +51,7 @@ z sshd czy plikami logów serwera WWW Apache.
%patch -P2 -p1
%patch -P3 -p1
%patch -P4 -p1
+%patch -P5 -p1
rm setup.cfg
sed -E -i -e '1s,#!\s*/usr/bin/env\s+python2(\s|$),#!%{__python3}\1,' -e '1s,#!\s*/usr/bin/env\s+python(\s|$),#!%{__python3}\1,' -e '1s,#!\s*/usr/bin/python(\s|$),#!%{__python3}\1,' \
diff --git a/fail2ban-lag-visibility.patch b/fail2ban-lag-visibility.patch
new file mode 100644
index 0000000..892acf3
--- /dev/null
+++ b/fail2ban-lag-visibility.patch
@@ -0,0 +1,57 @@
+diff -ru a/fail2ban/server/actions.py b/fail2ban/server/actions.py
+--- a/fail2ban/server/actions.py 2026-07-22 09:05:36.238602309 +0200
++++ b/fail2ban/server/actions.py 2026-07-22 09:05:36.239475119 +0200
+@@ -503,7 +503,10 @@
+ # report ticket to observer, to check time should be increased and hereafter observer writes ban to database (asynchronous)
+ if Observers.Main is not None and not bTicket.restored:
+ Observers.Main.add('banFound', bTicket, self._jail, btime)
+- logSys.notice("[%s] %sBan %s", self._jail.name, ('' if not bTicket.restored else 'Restore '), ip)
++ # append how far behind real-time a fresh ban is, so a live ban is
++ # distinguishable from fail2ban working through a log backlog
++ age = '' if bTicket.restored else ' (age %ds)' % max(0, int(MyTime.time() - ticket.getTime()))
++ logSys.notice("[%s] %sBan %s%s", self._jail.name, ('' if not bTicket.restored else 'Restore '), ip, age)
+ # do actions :
+ for name, action in self._actions.items():
+ try:
+diff -ru a/fail2ban/server/filter.py b/fail2ban/server/filter.py
+--- a/fail2ban/server/filter.py 2026-07-22 09:05:36.238824391 +0200
++++ b/fail2ban/server/filter.py 2026-07-22 09:05:36.240029235 +0200
+@@ -606,12 +606,12 @@
+ if self.__ignoreCache: c.set(key, False)
+ return False
+
+- def _logWarnOnce(self, nextLTM, *args):
+- """Log some issue as warning once per day, otherwise level 7"""
++ def _logWarnOnce(self, nextLTM, *args, interval=24*60*60):
++ """Log some issue as warning at most once per interval seconds, otherwise level 7"""
+ if MyTime.time() < getattr(self, nextLTM, 0):
+ if logSys.getEffectiveLevel() <= 7: logSys.log(7, *(args[0]))
+ else:
+- setattr(self, nextLTM, MyTime.time() + 24*60*60)
++ setattr(self, nextLTM, MyTime.time() + interval)
+ for args in args:
+ logSys.warning('[%s] ' + args[0], self.jailName, *args[1:])
+
+@@ -669,15 +669,19 @@
+ # if weird date - we'd simulate now for timing issue (too large deviation from now):
+ delta = int(date - MyTime.time())
+ if abs(delta) > 60:
+- # log timing issue as warning once per day:
++ # latency (backlog) is transient - surface it periodically so
++ # "fail2ban is N behind" stays visible; a timezone skew is a static
++ # misconfig, so leave that at once/day
++ latency = -3300 <= delta < 0
+ self._logWarnOnce("_next_simByTimeWarn",
+ ("Detected a log entry %s %s the current time in operation mode. "
+ "This looks like a %s problem. Treating such entries as if they just happened.",
+ MyTime.seconds2str(abs(delta)), "before" if delta < 0 else "after",
+- "latency" if -3300 <= delta < 0 else "timezone"
++ "latency" if latency else "timezone"
+ ),
+ ("Please check a jail for a timing issue. Line with odd timestamp: %s",
+- line))
++ line),
++ interval=60 if latency else 24*60*60)
+ # simulate now as date:
+ date = MyTime.time()
+ self.__lastDate = date
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/fail2ban.git/commitdiff/f73f086b39e73e0ae5150e281284bf269f5db440
More information about the pld-cvs-commit
mailing list