-
-
Notifications
You must be signed in to change notification settings - Fork 5
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
Nix: inability to resolve some ~wrapped / impure setuid executables such as sudo
#29
Comments
I have a use case this is biting me in. The scripts are running as root already under systemd. My approach has been to use substitute in place:
and then passing resholve:
but I would prefer to tell resholve that I do want it to resolve these paths even if it is troublesome. I guess the main reason I prefer it is because I accidentally made a mistake the first time I made this adjustment: I passed an absolute path to |
I'd be grateful for some help — perhaps the resolution could then be added to the documentation? |
@dbaynard Just in case you're watching here but not there, I reached out to what I assume is your handle on Matrix earlier this evening. |
There's a similar case in |
@SamLukeYes the last workaround in the first post may help here. Since 0.8.3 you can use (This assumes that you've verified that the unwrapped commands will run correctly for the invocations in your script.) |
It looks like systemd is adding a new sudo replacement named run0 that doesn’t use setuid. I bet that you could workaround this problem by using run0 instead of sudo. |
Nix has to special-case some setuid executables, and this disrupts resholve's ability to resolve them to absolute paths. (There are a number of interlocking issues here, and I suspect this will take some time--and some willingness to be squeaky wheels--to get this fixed in Nixpkgs. I vaguely plan to document these issues--but for now I'm just outlining.)
I don't have a lot of the Nix(OS)/nixpkgs system-level perspective to have the best handle on all of this. I get the impression there isn't a canonical list, but guessing from the run wrappers on my own NixOS system, this seems like a fair list:
In the near future, I'll update resholve to raise the following error for a cross-platform subset (ping chsh newgrp passwd su sudo mount umount) of these whenever
NIX_BUILD_TOP
is in the environment:In the short term, your best bets for working around this are:
fake
directive via the CLI or the Nix API. here's an example of what this would look like forsudo
:--fake 'external:sudo'
prologue
option to inject (at the head of the script) some refinement based on your context:In some more limited cases, you may know that you have access to an executable that doesn't actually need a setuid wrapper and you really just need resholve to get out of your way. If you're really sure, you can tell it to back off by adding
fix
directive via the CLI or the Nix API. Here's an example of what this would look like forsudo
:CLI:
--fix 'sudo'
Nix:
The text was updated successfully, but these errors were encountered: