-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Act on elevation requirements in majority cases #2126
Conversation
@check-spelling-bot ReportUnrecognized words, please review:
Previously acknowledged words that are now absentactivatable amd Archs dsc enr FWW Globals hackathon lww mytool Packagedx parametermap Uninitialize WDAG whatif wsbTo accept these unrecognized words as correct (and remove the previously acknowledged and now absent words), run the following commands... in a clone of the [email protected]:JohnMcPMS/winget-cli.git repository
|
@@ -1287,4 +1287,10 @@ Please specify one of them using the `--source` option to proceed.</value> | |||
<data name="WaitArgumentDescription" xml:space="preserve"> | |||
<value>Prompts the user to press any key before exiting</value> | |||
</data> | |||
<data name="InstallerElevationExpected" xml:space="preserve"> | |||
<value>The installer will request to run elevated, expect a prompt.</value> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
// This installer cannot be run elevated, but we are running elevated. | ||
// Implementation of de-elevation is complex; simply block for now. | ||
if (installer->ElevationRequirement == ElevationRequirementEnum::ElevationProhibited && Runtime::IsRunningAsAdmin()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (installer->ElevationRequirement == ElevationRequirementEnum::ElevationProhibited && Runtime::IsRunningAsAdmin())
I'm sort of mixed. Did you think of moving to installer selection in case there're other applicable installers? Or it's preferred to tell the user to run non-elevated again since this is what we think is the best installer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it may be best to have it in the installer, especially given that there is a feature request to filter by elevation requirement. However, if there are no applicable installers based solely on the fact that the user is running in an elevated terminal, then it still should say elevation prohibited rather than no applicable installer found
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that installer selection is appropriate, we don't even have user intent without #1898. I don't consider "is winget running as admin or not" user intent here, because I want to be able to run my Terminal as user and elevate installers as needed. #1898 should be implemented in installer selection (as well as search) though, because we would have user intent.
Side note: I broke VS Code on my machine due to forcing it to install elevated. Be safe out there... |
const std::filesystem::path& installerPath = context.Get<Execution::Data::InstallerPath>(); | ||
|
||
Msi::MsiParsedArguments parsedArgs = Msi::ParseMSIArguments(context.Get<Execution::Data::InstallerArgs>()); | ||
|
||
// Inform of elevation requirements | ||
if (!Runtime::IsRunningAsAdmin() && installer->ElevationRequirement == Manifest::ElevationRequirementEnum::ElevatesSelf) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought that using runas would suppress the prompt, as suggested in the issue; But, perhaps I read it incorrectly or was mistaken |
Nope, not having a way to bypass UAC is very much an intentional part of the design |
Fixes #1537, #1538
Change
When
ElevationRequirement
is set toelevationProhibited
is set and winget is run elevated, block the installation with an error.When
elevatesSelf
orelevationRequired
is set and winget is not run elevated, inform the user that an elevation prompt is expected. Also in the case ofelevationRequired
, use therunas
verb on ShellExecute to run the installer elevated. This can be used on installers that will fail if they are not run elevated.The message is a warning (yellow text) and is the last line below:
Validation
Manually validated each of the 3 elevation requirement options, as automated testing of elevation is not possible on the build server.
Microsoft Reviewers: Open in CodeFlow