Skip to content
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

Allow elevation through non-linux commands #1881

Merged
merged 10 commits into from
Aug 7, 2024

Conversation

nagilson
Copy link
Member

@nagilson nagilson commented Jul 15, 2024

We use @vscode/sudo-prompt to elevate. This way we don't need to handle the user password.

As discussed here #1620 Sudo-prompt does not store elevation permission, so every time it makes a request, it makes a new password request. For linux this is extremely annoying so there is a ton of extra setup I do to prevent this requirement.

For windows and mac, we can just call into the API directly since we dont need to elevate multiple times, it's less annoying.
This codepath was never used before (runUnderSudo only ever provided on linux.)

image
The prompt looks like this on Mac.
image
Windows.

There isn't much we can do to change that, since that's part of vscode's library.

On Windows, sometimes we will fail to run due to denied permissions, we can at least retry by launching the application with more permissions the first time.

For Mac and Windows when uninstalling, for some uninstallation methods, we need to be elevated from the beginning, otherwise the install will immediately fail. Example. https://github.com/dotnet/cli-lab/blob/ffb7b78931370c04f6b2a045cf8e79d299f66286/src/dotnet-core-uninstall/Shared/Commands/UninstallCommandExec.cs#L41

This PR will enable future code to elevate. Namely, #1897 cannot work without this because it needs to run sudo rm.

nagilson added 5 commits July 15, 2024 14:38
This is now what is hitting the EPERM and ENOENT errors.
We need to skip the check and see what happens from here, such as allowing to elevate via windows.

This also adds specific handlers for when we fail to download the SDK.
Need to double check that cancelling is handled properly now that its a promise reject
@nagilson nagilson changed the title Elevate before running the install on Windows Allow elevation through non-linux commands Jul 29, 2024
@nagilson nagilson marked this pull request as ready for review August 6, 2024 16:57
@nagilson nagilson requested a review from smitpatel August 7, 2024 17:17
@nagilson nagilson merged commit bbd5f88 into dotnet:main Aug 7, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants