Add support for opendoas #339
Closed
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.
I saw that there is a closed PR that tried to add support to other privilege elevation programs, not sure as to why it was never merged, so I apologize if this PR is inappropriate because of that, that said, if the PR is welcomed here is what I added:
only support for doas, with an environment variable
NH_USE_DOAS, if set to 1 or true, it will, well... use doas instead of sudo.To prevent any breaking changes, I kept all the sudo logic within main.rs intact, just enclosed it on a clause to only add flags (--preserve-env and -A) if sudo is the selected helper.
For command.rs and main.rs I also added checks so doas is not run when on macos, but this is temporary, as my job will later this year provide me with a macbook, I could see about adding support for macos, at the moment I can only test on nixos/liunx.
I did a bunch of tests with and without the flag (so testing sudo and doas) and it seems like nothing broke, I hope this helps. Of course if any changes are required I will be more than welcomed to implement them.