From 7c18cdbd39279c691633f16d70139c7c8db82f1a Mon Sep 17 00:00:00 2001 From: jochen Date: Mon, 28 Sep 2026 20:45:32 +0200 Subject: [PATCH] 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. --- modules/fail2ban/module.json | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/fail2ban/module.json b/modules/fail2ban/module.json index df7d3bb..fcf27f3 100644 --- a/modules/fail2ban/module.json +++ b/modules/fail2ban/module.json @@ -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",