-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Dropbear filter when logging to STDOUT #3597
base: master
Are you sure you want to change the base?
Conversation
The captured values from following lines must simply match the parameter in JSON (time, host etc), so just copy-paste it from another lines and adjust the values inside to the values of your line... fail2ban/fail2ban/tests/utils.py Line 52 in 8170e9f
what is basically So Aug 14 12:00:00 CEST 2005 , so it can be 2004 (if date without year is before that time) and/or in CET if the TZ is different at parsed timestamp.
Or just add it to this PR (or to file direct without failJSON), I'd extended it by myself. |
Not sure whether I understood in which case it can be 2004. But following the other entries, I think it should work the way I added it now 😅. While producing those, I recognised two other issues:
This is Independent of systemd vs init.d service, the changed output after prefix is the same in both cases. Max retry failures are IMO not important, since usually, the failed attempts before this happens match and lead to a ban already, before max retries are even hit. Invalid user logins however IMO are important, and I am not sure why those do not contain the host anymore. I'll check back with Dropbear. This is however unrelated to the systemd/STDOUT / |
I opened an issue about the broken matches: #3791 Another thing: For systemd services like used on Debian, shall I add the
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another thing: For systemd services like used on Debian, shall I add the journalmatch right here?
Sure.
Since Debian Bookworm, the distribution ships Dropbear with a native systemd service instead of the default upstream init.d service, and accordingly uses the `-F` and `-E` flags, to run it in foreground and have it logging to STDOUT instead of syslog. As usual, timestamps and also the PID are now included by the log message emitted by Dropbear, in addition to the systemd journal log prefix. The Dropbear filter hence does not match anymore. This commit adds the PID and timestamp as optional pattern between prefix and fail log text, to support Dropbear on Debian Bookworm and newer (and likely new versions of other distros) without breaking the old pattern when running Dropbear without `-E` flag. Additionally, for performance reasons, this commit adds a `journalmatch` entry, matching Debian's and Fedora's `dropbear.service` with `dropbear` executable/identifier, the most likely match for a Dropbear systemd service. Signed-off-by: MichaIng <micha@dietpi.com>
Dropbear uses `strftime` `"%b %d %H:%M:%S` to print its timestamps, hence we know the day and time format, but the month could be localized. We hence allow any 3 word characters for it, and additionally simplify the day and time pattern into a single group. Signed-off-by: MichaIng <micha@dietpi.com>
Since Debian Bookworm, the distribution ships Dropbear with a native systemd service instead of the default upstream init.d service, and accordingly uses the
-F
and-E
flags, to run it in foreground and have it logging to STDOUT instead of syslog.As usual, timestamps and also the PID are now included by the log message emitted by Dropbear, in addition to the systemd journal log prefix.
The Dropbear filter hence does not match anymore. This commit adds the PID and timestamp as optional pattern between prefix and fail log text, to support Dropbear on Debian Bookworm and newer (and likely new versions of other distros) without breaking the old pattern when running Dropbear without
-E
flag.Additionally, for performance reasons, this commit adds a
journalmatch
entry, matching Debian's and Fedora'sdropbear.service
withdropbear
executable/identifier, the most likely match for a Dropbear systemd service.Before submitting your PR, please review the following checklist:
CHOOSE CORRECT BRANCH: if filing a bugfix/enhancement
against certain release version, choose
0.9
,0.10
or0.11
branch,for dev-edition use
master
branchCONSIDER adding a unit test if your PR resolves an issue
LIST ISSUES this PR resolves
MAKE SURE this PR doesn't break existing tests
KEEP PR small so it could be easily reviewed.
AVOID making unnecessary stylistic changes in unrelated code
ACCOMPANY each new
failregex
for filterX
with sample log lineswithin
fail2ban/tests/files/logs/X
fileI can add a line to https://github.com/fail2ban/fail2ban/blob/master/fail2ban/tests/files/logs/dropbear, but is there a way to get this
failJSON
?