microsoft / winget-pkgs

The Microsoft community Windows Package Manager manifest repository
MIT License
8.69k stars 4.53k forks source link

Validation is running manifests with elevationProhibited in an elevated context #72224

Open jedieaston opened 2 years ago

jedieaston commented 2 years ago

As of winget 1.3, winget now supports a ElevationRequirement key for installers, which can tell the client to error out if a user tries to run an installer that will fail when ran as an administrator (https://github.com/microsoft/winget-cli/pull/2126).

The validation service doesn't seem to respect this, and is running installers in an elevated context that have ElevationRequirement: elevationProhibited set. Here's an example using Spotify (https://github.com/microsoft/winget-pkgs/pull/72166):

InstallationClient log:

Installing winget from 'C:\Winget\Dependencies'
winget-cli Installation complete.
WinGet is installed.
Running winget settings --enable LocalManifestFiles
End winget settings --enable LocalManifestFiles
Enabling installation of local manifests succeeded: True
WinGet is installed.
File Watcher -> Register watching C:\, Filter = 
Scope set to: 
Locale set to: 
System Architecture: X86
Running with Elevation: True <----------------------
Starting FileTracker
File Watcher -> Begin watching C:\, Filter = 
Running winget install --manifest D:\TRANSFER\c79454d6-4925-ed11-951f-000d3a9edf5a\Manifest.yaml --accept-package-agreements
End winget install --manifest D:\TRANSFER\c79454d6-4925-ed11-951f-000d3a9edf5a\Manifest.yaml --accept-package-agreements
Installation failed with exit code -1978335146
Stopping FileTracker
File Watcher -> Stop watching C:\, Filter = 

winget install log:

2022-08-26 07:18:37.895 [CORE] WinGet, version [1.3.2091], activity [{E2DC2FEF-304F-444F-9844-056F3881F26C}]
2022-08-26 07:18:37.896 [CORE] OS: Windows.Desktop v10.0.19044.1889
2022-08-26 07:18:37.896 [CORE] Command line Args: C:\Users\Validator\AppData\Local\Microsoft\WindowsApps\winget.exe install --manifest D:\TRANSFER\c79454d6-4925-ed11-951f-000d3a9edf5a\Manifest.yaml --accept-package-agreements
2022-08-26 07:18:37.896 [CORE] Package: Microsoft.DesktopAppInstaller v1.18.2091.0
2022-08-26 07:18:37.896 [CORE] IsCOMCall:0; Caller: winget-cli
2022-08-26 07:18:37.907 [CLI ] WinGet invoked with arguments: 'install' '--manifest' 'D:\TRANSFER\c79454d6-4925-ed11-951f-000d3a9edf5a\Manifest.yaml' '--accept-package-agreements'
2022-08-26 07:18:37.909 [CLI ] Found subcommand: install
2022-08-26 07:18:37.909 [CLI ] Leaf command to execute: root:install
2022-08-26 07:18:37.928 [CLI ] Executing command: install
2022-08-26 07:18:37.932 [CLI ] Manifest fields: Name [Spotify], Version [1.1.92.647.ga4397eb7]
2022-08-26 07:18:37.956 [CLI ] Starting installer selection.
2022-08-26 07:18:37.956 [CLI ] Completed installer selection.
2022-08-26 07:18:37.989 [CLI ] Terminating context: 0x8a150056 at D:\a\_work\1\s\external\pkg\src\AppInstallerCLICore\Workflows\InstallFlow.cpp:7f

This is currently blocking Spotify from being updated, so if this is going to be a painful fix I can remove the ElevationRequirement key until it's resolved.

denelon commented 2 years ago

We should fix this bug and leave the key in the manifest so the user experience works correctly. Unless I'm interpreting this incorrectly.

jedieaston commented 2 years ago

You're understanding correctly (it was kind of hard to explain, sorry). I don't want to remove the key, but if this fix is super complicated I wondered if we should remove it temporarily since Spotify is currently entirely borked.

Trenly commented 2 years ago

Or perhaps someone can manually validate and merge spotify

denelon commented 2 years ago

Which PR is spotify?

ItzLevvie commented 2 years ago

https://github.com/microsoft/winget-pkgs/pull/72166

Kaligula0 commented 7 months ago

I think the error I get is related to this issue: The installer cannot be run from an administrator context.. Log:

▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄

Starting package update operation for package id=Spotify.Spotifywith Manager name=Winget
Given installation options are <InstallationOptions: SkipHashCheck=False;InteractiveInstallation=False;RunAsAdministrator=False;Version=;Architecture=;InstallationScope=;InstallationScope=;CustomParameters=;RemoveDataOnUninstall=False>
Process Executable     : C:\Program Files\WingetUI\PackageEngine\Managers\winget-cli_x64\winget.exe
Process Call Arguments :  update --id Spotify.Spotify --exact --accept-source-agreements --silent --disable-interactivity --accept-package-agreements --force --include-unknown
Working Directory      : C:\Users\Ja
    |    - 
    |   ███▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒  1024 KB / 9.78 MB
    |   ██████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒  2.00 MB / 9.78 MB
    |   █████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒  3.00 MB / 9.78 MB
    |   ████████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒  4.00 MB / 9.78 MB
    |   ███████████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒  5.00 MB / 9.78 MB
    |   ██████████████████▒▒▒▒▒▒▒▒▒▒▒▒  6.00 MB / 9.78 MB
    |   █████████████████████▒▒▒▒▒▒▒▒▒  7.00 MB / 9.78 MB
    |   ████████████████████████▒▒▒▒▒▒  8.00 MB / 9.78 MB
    |   ███████████████████████████▒▒▒  9.00 MB / 9.78 MB
    |    - 
    | The installer cannot be run from an administrator context.
Process Exit Code      : -1978335146
Process End Time       : 05.04.2024 16:23:34

(I use WingetUI, which is an UI for winget; never used winget alone; but I don't think that matters).

Trenly commented 6 months ago

@jedieaston - has this been resolved? See https://github.com/microsoft/winget-pkgs/pull/150294/files