chore: Remove wrapper script for fail2ban service#3032
Merged
polarathene merged 4 commits intodocker-mailserver:masterfrom Jan 29, 2023
Merged
chore: Remove wrapper script for fail2ban service#3032polarathene merged 4 commits intodocker-mailserver:masterfrom
polarathene merged 4 commits intodocker-mailserver:masterfrom
Conversation
- This does not appear necessary. The server can be run with foreground mode. - `daemons-stack.sh` removal of the socket can be handled by the fail2ban server when using the `-x` option.
These were both added as supposed fixes in 2016 for the then Ubuntu 2014 base image. Removing them causes no failures in tests.
These have barely any overhead in layer weight. The DNS package may provide some QoL improvements, while the `pyinotify` is a better alternative than polling logs to check for updates. We have `gamin` package installed but `fail2ban` would complain in the log that it was not able to initialize the module for it. There only appears to be a `python-gamin` dependent on EOL python 2, no longer available from Debian Bullseye.
georglauterbach
approved these changes
Jan 27, 2023
Member
georglauterbach
left a comment
There was a problem hiding this comment.
I actuall wanted to tackle this for a long time! Outstanding work, very nice!
casperklein
approved these changes
Jan 29, 2023
8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Main motivation for this was avoiding the
sleepapproach in the wrapper script if we don't actually need to rely on it.I've additionally removed the
/var/log/auth.logreferences in the project (excluding a test case intests.batsthat's probably not that useful and will be removed later), and added two optional packages for Fail2Ban.Commit messages do provide context, but more verbose details have been provided below.
Changes
Supervisord starts
fail2ban-serverdirectly nowFail2Ban docs for the CLI (only lists for v0.8) or Github master branch. This removes the need to manually manage removal of the socket at startup (
-x) and run in foreground (-f), letting us drop some scripts.I have compared to the
fail2ban-client startcommand that runs thefail2ban-serverprocess with slightly different options (such as--async), but according to the docs that is for internal usage only and not advised to run the server with directly, so I've avoided matching those additional args./var/log/auth.logrootuser) "Unable to open env file: /etc/default/locale".auth.logfile or when in DMS, but assume they would create the file if it doesn't exist?rsyslogd/syslogto manage it, and I've most commonly seen it referenced for SSHD. But also that thersyslogpackage has some differences on Debian from the Ubuntu one that we had installed (at least with default user/group, possibly configs?).Added Fail2Ban optional dependencies
pyinotifyanddnspythonare listed on the F2B Github README, both are minimal overhead to image weight.While we presently have the
gaminpackage installed, and Fail2Ban offers it as one of the notification methods, it can only do so with a Python 2 package no longer available on Debian as Python 2 is EOL now. Besides Fail2Ban devs have noted it's performance was very bad.I'm not entirely sure about the
pyinotifypackage. It may be more beneficial than constant polling of log files, but the project has not been maintained since June 2015. I have looked at thepython3-pyinotifydebian package where the Gitlab source appears to maintain a fork of the upstream project.The
dnspythonpackage may also be of some value? (It is actively maintained) I do recall there was a PR a while back to disable DNS lookups due to NFTables/IPTables (possibly with F2B?) not resolving DNS requests properly? Having this package may have resolved that 🤷♂️If neither seem worthwhile, let me know and I can drop them. I only looked into this when viewing Fail2Ban logs warning about failure to initialize
gaminandpyinotifybackends, so it falls back to polling strategy. The default config isbackend=autoAFAIK, hence no change beyond installingpython3-pyinotifyis required. I have noticed the logs for that backend is not as nice as the polling ones. We could drop it since there has been no complaints with the polling backend currently used?Background history for the wrapper script
A PR from July 2017 introduced
supervisordto manage processes. It added wrapper scripts for Postfix and Fail2Ban citing that they could not be run in foreground mode, and these wrapper scripts were necessary to support these services due to their usage of multiple processes.That doesn't seem to align to the current state of the image though? It'd seem we'd want more wrapper scripts then:
Click to view process tree
I don't think the wrapper script is providing any actual value? If it is, could we get a proper test for that, and confirmation that none of the other processes above are at risk? (the list is output from this PRs changes applied)
The referenced PR did originally run fail2ban in foreground mode, but in a later commit of that PR changed it to the wrapper script approach instead, with the context of:
Clearly you could start it in foreground mode? We also had a stop grace period added many years later after that PR. So I'm not sure that concern is valid anymore. It seems safe to remove the wrapper script?
UPDATE: I've since realized that PR was originally based off this PR (which the merged PR referenced as an "issue" it resolved, rather than the actual issue / FR) which had the
fail2ban-server -fusage without the wrapper script. The associated issue from Dec 2016 references a serverfault thread which is where the wrapper script appears to have been adapted from in the July 2017 PR that was merged.Type of change
Checklist: