-
Notifications
You must be signed in to change notification settings - Fork 786
Allow using doas on linux systems #611
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
Conversation
|
Would it be better to just modify the logic here? https://github.com/sshuttle/sshuttle/blob/master/sshuttle/client.py#L213 Maybe we could use doas if that is in the path and otherwise use sudo. The logic to base the decision on platform name could then be removed. |
|
Searching in the path feels a bit wrong. What if both sudo and doas are in the path? What if doas is at I would maybe even replace all this logic option |
|
I don't have strong feelings about it, I just wanted to mention it as an option. If both were in the path, we'd have to default to one or the other. Considering the idea that a malicious executable might be in the path is a good point. Right now, sshuttle just looks for various commands in the path: sudo, nft, iptables, etc. I agree that making a more general privilege-elevation option that points to the desired binary might be good. We'd have to look at the name in the option to determine the correct arguments to pass. I suppose we'd want to consider doing this kind of approach across the board for the other commands that sshuttle runs too? |
|
I am a little bit sad about adding yet another argument to the main function. Which already has a huge number of arguments :-( Particularly one that is specific to an optional 3rd party package.
A generic solution that means we don't need to have arguments for each specific "grant root" would probably be ideal. If this is possible. Maybe something like:
Where we append the command to run to the end of this. For this to work, we would need to slip command into arguments correctly, and pass the quoted value as one argument. If we want to keep the -p argument that is. Also looking at the existing code, the variable |
This is an alternative solution to pull request sshuttle#611. Previously, sshuttle would use doas on OpenBSD and sudo on Linux. However, some Linux distributions are opting to use doas. This patch changes the logic so that there can be multiple attempts to elevate privilages. If the first command fails to run, it moves on to the next command. Part of the existing code looked like it might be attempting to do this, but it didn't work. It also looks for the presence of doas and sudo in the path. If we can find doas (but cannot find sudo) or if the platform is OpenBSD, we try doas first. Otherwise, we try sudo, then doas. We try all the options until one succeeds (including running the command without sudo or doas) regardless of what is in the path. I'm open to adjusting the logic here based on feedback. If systems have both sudo and doas, they might be configured to give different users different permissions. For example, if a user wishes to use doas on this system, sshuttle would try sudo first and the user would need to enter invalid passwords to eventually cause sudo to fail and cause sshuttle to then try doas. This might not be ideal, but it avoids implement another sshuttle argument that the user would need to specify. Perhaps machines actually using doas will not have sudo installed?
|
Closing as I merged #708. |
Some linux distributions allow switching
sudowithdoas. This PR adds a flag-d --doaswhich allows users to usedoasfor privilege elevation.