-
Notifications
You must be signed in to change notification settings - Fork 595
Send signals as Icinga user in safe-reload and logrotate #10530
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
base: master
Are you sure you want to change the base?
Conversation
In contrast to the regular `kill` binary, `icinga2 internal signal` drops permissions before sending the signal. This is important as the PID file can be written by the Icinga user, dropping the permissions prevents that user from using this to send signals to processes it is not supposed to signal. SIGUSR1 wasn't among the list of signals supported by `icinga2 internal signal`, so it is added there.
notifempty@LOGROTATE_CREATE@ | ||
postrotate | ||
/bin/kill -USR1 $(cat @ICINGA2_INITRUNDIR@/icinga2.pid 2> /dev/null) 2> /dev/null || true | ||
@CMAKE_INSTALL_FULL_SBINDIR@/icinga2 internal signal --sig SIGUSR1 --pid "$(cat @ICINGA2_INITRUNDIR@/icinga2.pid 2> /dev/null)" 2> /dev/null || true |
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.
Be aware that this is a config file which we've currently told the package manager not to override by %config(noreplace).
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.
Unfortunate, but not much we can do about it except mentioning it in the changelog. I've added a corresponding hint to the PR description.
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.
That's not true! We can at least consider %config, i.e w/o (noreplace).
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.
If the file was modified, there was probably a reason for doing so. Just overwriting it would likely break something.
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.
And just keeping it leaves a security hole(?) for all who don't read the changelog, but modified stuff. Also, %config makes a backup of your modifications.
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.
- This is a valid reason for %config
- Needs proper upgrade log, though (breaking changes awareness)
- Also %config must be kept long enough, as users may skip a version
|
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.
Discuss #10530 (comment) with Eric (in the next core status meeting).
RPM
performs its .rpmsave/.rpmnew dance only if both the package maintainer and the admin change a config file: https://serverfault.com/a/672640?utm_source=chatgpt.com
Given that the issue here is security-related, I consider a plain %config reasonable, especially as it will (backup and) replace the edited file (warning the user) only once.
Yes, only once. I mean, just look at the file's history: https://github.com/Icinga/icinga2/commits/master/etc/logrotate.d/icinga2.cmake
Spoiler:
We can also revert it in a year or similar.
Debian
always asks the user, offering a diff: https://raphaelhertzog.com/2010/09/21/debian-conffile-configuration-file-managed-by-dpkg/?utm_source=chatgpt.com
Just pressing Enter, for simply keep my changes, is tempting, though.
Both of them
provide post-scripts, so we could replace /bin/kill -USR1
with sed(1). A good workaround IMAO.
Eric also mentioned a(n Icinga 2) runtime check (that the file is sane).
In contrast to the regular
kill
binary,icinga2 internal signal
drops permissions before sending the signal. This is important as the PID file can be written by the Icinga user, dropping the permissions prevents that user from using this to send signals to processes it is not supposed to signal.SIGUSR1 wasn't among the list of signals supported by
icinga2 internal signal
, so it is added there.Important
Mention in changelog:
The logrotate config is installed in /etc and may not be updated by a package update in case it was modified.
Tests
systemctl reload icinga2
(and also calling/usr/lib/icinga2/safe-reload
) still successfully reload Icinga 2.icinga2 internal signal
indeed drops privileges (more of a sanity check):fixes #10527