-
-
Notifications
You must be signed in to change notification settings - Fork 14.5k
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
Fixes #18124: atomically replace /var/setuid-wrappers/ #18186
Conversation
ce81121
to
cb3c1a7
Compare
cb3c1a7
to
e06bd0a
Compare
(for @edolstra: That's the "I've reviewed this" 👍 ) |
Before this commit updating /var/setuid-wrappers/ folder introduced a small window where NixOS activation scripts could be terminated and resulted into empty /var/setuid-wrappers/ folder. That's very unfortunate because one might lose sudo binary. Instead we use two atomic operations mv and ln (as described in https://axialcorps.com/2013/07/03/atomically-replacing-files-and-directories/) to achieve atomicity. Since /var/setuid-wrappers is not a directory anymore, tmpfs mountpoints were removed in installation scripts and in boot process. Tested: - upgrade /var/setuid-wrappers/ from folder to a symlink - make sure /run/setuid-wrappers-dirs/ legacy symlink is really deleted
e06bd0a
to
084ddc4
Compare
@edolstra I've hardcoded the new wrappers dir path, let me know if we should take another path. |
@@ -115,9 +115,29 @@ in | |||
# programs to be wrapped. | |||
SETUID_PATH=${config.system.path}/bin:${config.system.path}/sbin | |||
|
|||
rm -f ${wrapperDir}/* # */ | |||
mkdir -p /run/setuid-wrapper-dirs | |||
wrapperDir=$(mktemp --directory --tmpdir=/run/setuid-wrapper-dirs setuid-wrappers.XXXXXXXXXX) |
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 change breaks for me because mktemp sets permissions of drwx------
- any idea why this works for you?
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.
Maybe different defaults? There were some fixes yesterday, is this still an issue for you?
@edolstra the good news the following protection works:
but we have to update it now, should we just hardcode
/run/setuid-wrappers-dirs/
?cc @shlevy