fail2ban: declare the log its own recidive jail reads

The recidive jail bans whoever keeps coming back by reading fail2ban's own
log, and fail2ban checks every jail's log file while it configures itself --
before it has created that log. On a machine where the file is not there
already, no jail is found for recidive, configuration fails, and the whole
service refuses to start, taking the sshd jail with it. Two machines assigned
this module today came up failed for exactly that reason; the two where it
worked had a log from years of the service running.

Declared create-once: the mesh puts an empty file there when it is absent and
never touches it again, because what grows in it is fail2ban's, and the
logrotate file this module already ships is what keeps it small.

This also reverts the previous two commits' fail2ban.local. It declared a
logtarget that the package already sets to the same path on every machine
here -- pacman reports the config pristine -- so it fixed nothing and said
something untrue about why.
This commit is contained in:
2026-09-28 20:45:32 +02:00
parent 4fb16b2e6b
commit 7c18cdbd39
+8 -8
View File
@@ -28,13 +28,6 @@
"path": "/etc/fail2ban/action.d",
"mode": "0755"
},
{
"id": "fail2ban-local",
"type": "file",
"path": "/etc/fail2ban/fail2ban.local",
"mode": "0644",
"content": "[Definition]\n\n# Where fail2ban writes its own log, declared rather than assumed. The recidive jail reads\n# this file to ban whoever keeps coming back, and the logrotate file this module ships\n# rotates it -- but nothing told fail2ban to write there. Where the package default stands,\n# fail2ban logs to the journal, the recidive jail finds no log file, and the whole service\n# refuses to start, taking the sshd jail with it.\n#\n# In .local, not in fail2ban.conf: that file belongs to the package.\nlogtarget = /var/log/fail2ban.log\n"
},
{
"id": "jail-local",
"type": "file",
@@ -49,6 +42,14 @@
"mode": "0644",
"content": "[sshd]\nenabled = true\nport = ssh\nlogpath = %(sshd_log)s\nbackend = %(sshd_backend)s\nmaxretry = 5\n"
},
{
"id": "log",
"type": "file",
"path": "/var/log/fail2ban.log",
"mode": "0640",
"create-once": true,
"content": ""
},
{
"id": "jail-recidive",
"type": "file",
@@ -77,7 +78,6 @@
"state": "running",
"boot": "enabled",
"restart-on": [
"fail2ban-local",
"jail-local",
"jail-sshd",
"jail-recidive",