-
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
WinGet Database getting corrupted on multi-user systems when using GSudo-like elevation methods #5109
Comments
I have found out that, if prior to calling |
I have found that by specifying the username of an administrative user (local in my case) in gsudo, the temporary file paths are changed to that of the specified user. This approach works in PowerShell (5.1 and 7.5) for interactive and non-interactive sessions, in both new and existing windows.
However, with CMD specifying the username only works with the approach only works for interactive sessions.
I think that this looks more like a problem with gsudo than winget. |
What happens is that GSudo passes the environment variables from the original process (which are the regular user's), and WinGet pulls the temporary folder from the ENV variables. What I reckon the issue is, is that WinGet is properly detecting that it is running as a different user (since the ACLs are correctly set), but is failing to obtain the correct temp folder for the new user, and it uses the one set on %TEMP%. Perhaps WinGet could pull the temp folder location from a different source (perhaps from the windows registry) so this issue doesn't happen. |
Brief description of your issue
Assume the following conditions on a system are met:
There are cases when WinGet will be executed as administrator with some tool like
gsudo
or similar in order to install/upgrade a package, and winget will get corrupted due to the lost of access to the%tmp%/WinGet
folder.This will break
%temp%/WinGet
directory permissions and cause the local user to not being able to use WinGet.IMPORTANT: The issue can not be reproduced if the steps below are performed on an administrator command prompt (cmd.exe -> right-click -> run as administrator.) Window's sudo will not work, since the user is local. GSudo (or equivalent) must be used in order for the issue to be reproducable.
This issue is also reproducible using UniGetUI and upgrading a package via the built-in "Upgrade as administrator" option, which relies on UniGetUI Elevator to elevate WinGet (which is essentialy a custom build of GSudo)
Relevant issues posted on marticliment/UniGetUI, that are caused by this corruption:
Steps to reproduce
winget update
. Everything works fine.Now, there is a WinGet subfolder under %temp%, whose owner is the current user. (as expected).
gsudo winget upgrade Google.Chrome.Exe
. Enter the administrator credentials and click yeswinget upgrade
again. See the following error:On the local user's
%temp%
, the WinGet subfolder is now owned by the administrator account. the local user cannot read nor modify the contents of the%temp%/WinGet
directory. Furthermore, the commandgsudo winget upgrade
works as expected. Deleting the temp folder can solve the issue.Expected behavior
WinGet should detect that it has been elevated, and should use the administrator's account temporary folder, or at least be less restrictive with the permissions of the temp folder.
Actual behavior
WinGet cannot be used anymore unless the temp folder is reset.
Environment
The text was updated successfully, but these errors were encountered: