-
Notifications
You must be signed in to change notification settings - Fork 137
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
sudo -N
should preserve the current directory
#63
Comments
Alas, for security reasons, the default mode for sudo for windows has to avoid doing any RPC, which means it's going to basically just act as a shim for ShellExecute. You can avoid it by passing -D . to sudo (added in one of the more recent builds). We're still iterating/ideating on ways to avoid this, but we don't have anything at the moment that also avoid RPC. |
Given that constraint, (and others, like |
You know, we had actually considered that one too. In that case, we then fall into the case where the UAC will show "Command Prompt" as the application being elevated, rather than the actual target application. I believe that was an undesirable outcome, though I'll loop back on that with the security folks. I too agree, that solution would work, but I'm (very mildly) worried that less well-informed users will be surprised that |
For some reason, ShellExecuteEx with Verb=RunAs respects the starting directory if it is elevating dotnet apps but not for other types... (eg. Is it possible that you guys alter ShellExecuteEx (in a backwards-compatible way) to respect the starting directory in every case? ... and, if the answer is no (or if sudo is running on older windows) then... I think users would find it more familiar to see a UAC popup for |
Ok, but.......Linux has been doing it this way since almost the start. Why can't Windows? |
Sudo for Windows version
1.0.0
Windows build number
10.0.26063.1
Other Software
No response
Steps to reproduce
According to my tests, the general expectation regarding
sudo
is that it preserves the current directory.If you run
sudo rm *
orsudo del *.*
the user would expect to affect files in the current directory.If you do
sudo notepad ./filename
, the user expects that the path resolves relative to the current directory.But currently:
-N
is usedforceNewWindow
mode... then the current folder is set to
C:\WINDOWS\System32
insteadFor example
See:
I know you mentioned this was by-design. IMO that design choice should be reconsidered. This is not just unpredictable and inconvenient... In these edge cases it can also be dangerous.
Expected Behavior
Sudo should preserve the current directory, regardless of being invoked from an elevated process, a non-elevated one, with or without
-N
, and with any configuration mode.Actual Behavior
Sudo preserves the current directory depending on the
-N
argument, the config mode, or the elevation status of the caller.The text was updated successfully, but these errors were encountered: