-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
savecore: add missing call to cap_openlog when in capabilities mode #1546
base: main
Are you sure you want to change the base?
savecore: add missing call to cap_openlog when in capabilities mode #1546
Conversation
Signed-off-by: Stéphane Rochoy <[email protected]>
e775981
to
3d688bd
Compare
I'm looking to add a test as it should be trivial. |
Oh yes I didn't notice the Draft tag. The C change itself looks good :) |
git rebase -i main |
81e3954
to
41a32d6
Compare
Sorry for the initial noise. I cleaned the commits. But one question remain about the test I propose to add: what is the proper way to test the instance of |
41a32d6
to
e03cff4
Compare
@oshogbo Do you have an opinion on this? Do you want me to just ignore |
Any news on this topic? Should I just call |
Yes, you should do that. The test suite is intended to run against an installed system. There aren't any other tests tweaked to work with DESTDIR. However, you can always alter PATH when running this test yourself. |
e03cff4
to
4973e68
Compare
Sorry, for late response. LGTM. |
4973e68
to
bffe1ab
Compare
I adjusted copyright to 2025. |
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.
While I don't dispute the results of your testing, I don't understand why it works. Shouldn't it be sufficient to run openlog before cap_enter? I don't understand why the program even needs cap_syslog in the first place. IIUC, cap_syslog is only needed if you must open a syslog connection after cap_enter.
Signed-off-by: Stéphane Rochoy <[email protected]>
bffe1ab
to
e4eb4d1
Compare
I'm just starting to discover this API so don't hesitate to dispute anything ;)
I have to admit I didn't even try to move the call to |
Not after, before. |
Well, the observations that initially led me to think a call to Test 1:
Test 2:
Test 3:
And I've just done an additional test:
I guess it is. The following sequence show capabilities don't interfere with
|
It sounds like we can elminate cap_openlog/cap_syslog and go back to plain openlog/syslog, then. Could you please do that? |
@asomers Sorry, I'm just jumping in. It's not like syslog might want to reopen the file or connect again to |
Since savecore is a short-lived program, running for only a few seconds, I don't think we need to worry about syslogd restarts. Are there any other reasons why syslog(3) might reconnect? |
Yeah, that's a valid point. I don't have a strong opinion on this. I'm not sure what happens when the log file is rotated. |
syslogd handles log rotation transparently to loggers. syslog(3) users don't need to reopen sockets after a log rotation. I can't see any reason not to use the plain syslog() and openlog() functions. |
So the question is why do we have |
I think it was due to an oversight in d7fffd0 . The author replaced several other services with their capsicumized versions, where that's really needed. I think he just didn't realize that the non-capsicum syslog would work fine. |
Yes, I think it was probably me being overlay paranoid. As was already noted, savecore is a short-lived program, it's unlikely that it'll hit the conditions under which syslog(3) needs to reconnect (syslogd restarts, or its logging buffer is full). So, plain openlog()+syslog() should work fine in practice. OTOH, I suspect the patch in this PR is also fine as-is. Maybe let's merge it and consider removing cap_syslog separately, given that we're just trying to fix a simple bug here? Either approach is ok with me. |
So the short-term plan is to add the missing call to But I'm not sure to understand the long-term plan: is it to just drop the use of |
It's to handle the rare case where syslog(3) has to reconnect to syslogd's socket. In capability mode, connect() is not allowed, so we use a casper service. This is mostly suitable for long-running programs, where the likelihood of needing to reconnect at some point is high. I tend to think that syslog(3) could instead just open /var/run (limiting rights to CAP_CONNECTAT, CAP_LOOKUP, CAP_WRITE, ...?) and use connectat(2) when needed. @oshogbo do you see any problem with this alternative? It means that we hold an extra capability for /var/run, but I think that's a small downside. |
When run in capabilities mode,
savecore
seems to lack a call tocap_openlog
. Notably it break the use ofLOG_PERROR
.With the original one:
With the patched one: