-
Notifications
You must be signed in to change notification settings - Fork 908
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
Attempting to use ProtectedData.Protect with LocalMachine scope fails when run on non-Windows system as a non-root user #2437
Comments
TheCakeIsNaOH
added a commit
to TheCakeIsNaOH/choco
that referenced
this issue
Nov 2, 2021
TheCakeIsNaOH
added a commit
to TheCakeIsNaOH/choco
that referenced
this issue
Nov 2, 2021
TheCakeIsNaOH
added a commit
to TheCakeIsNaOH/choco
that referenced
this issue
Nov 2, 2021
When running on mono on a non-Windows system, the ProtectedData methods use /usr/local/.mono/keypair as the folder to save keypairs. This folder is not normally writable by non-root users, thus erroring when used by a normal user. This catches that error and falls back to using the CurrentUser scope. Also, during data unprotection, it will try to fall back to CurrentUser scope if the decryption fails for other reasons, so as to attempt to decrypt data encrypted with CurrentUser if the LocalSystem scope starts working.
TheCakeIsNaOH
added a commit
to TheCakeIsNaOH/choco
that referenced
this issue
Nov 2, 2021
When running on mono on a non-Windows system, the ProtectedData methods use /usr/local/.mono/keypair as the folder to save keypairs. This folder is not normally writable by non-root users, thus erroring when used by a normal user. This catches that error and falls back to using the CurrentUser scope. Also, during data unprotection, it will try to fall back to CurrentUser scope if the decryption fails for other reasons, so as to attempt to decrypt data encrypted with CurrentUser if the LocalSystem scope starts working.
TheCakeIsNaOH
added a commit
to TheCakeIsNaOH/choco
that referenced
this issue
Nov 2, 2021
When running on mono on a non-Windows system, the ProtectedData methods use /usr/local/.mono/keypair as the folder to save keypairs. This folder is not normally writable by non-root users, thus erroring when used by a normal user. This catches that error and falls back to using the CurrentUser scope. Also, during data unprotection, it will try to fall back to CurrentUser scope if the decryption fails for other reasons, so as to attempt to decrypt data encrypted with CurrentUser if the LocalSystem scope starts working.
TheCakeIsNaOH
added a commit
to TheCakeIsNaOH/choco
that referenced
this issue
Nov 2, 2021
When running on mono on a non-Windows system, the ProtectedData methods use /usr/local/.mono/keypair as the folder to save keypairs. This folder is not normally writable by non-root users, thus erroring when used by a normal user. This catches that error and falls back to using the CurrentUser scope. Also, during data unprotection, it will try to fall back to CurrentUser scope if the decryption fails for other reasons, so as to attempt to decrypt data encrypted with CurrentUser if the LocalSystem scope starts working.
TheCakeIsNaOH
added a commit
to TheCakeIsNaOH/choco
that referenced
this issue
Nov 2, 2021
When running on mono on a non-Windows system, the ProtectedData methods use /usr/local/.mono/keypair as the folder to save keypairs. This folder is not normally writable by non-root users, thus erroring when used by a normal user. This catches that error and falls back to using the CurrentUser scope. Also, during data unprotection, it will try to fall back to CurrentUser scope if the decryption fails for other reasons, so as to attempt to decrypt data encrypted with CurrentUser if the LocalSystem scope starts working.
This was referenced Nov 2, 2021
TheCakeIsNaOH
added a commit
to TheCakeIsNaOH/choco
that referenced
this issue
Nov 3, 2021
When running on mono on a non-Windows system, the ProtectedData methods use /usr/local/.mono/keypair as the folder to save keypairs. This folder is not normally writable by non-root users, thus erroring when used by a normal user. This catches that error and falls back to using the CurrentUser scope. Also, during data unprotection, it will try to fall back to CurrentUser scope if the decryption fails for other reasons, so as to attempt to decrypt data encrypted with CurrentUser if the LocalSystem scope starts working.
TheCakeIsNaOH
added a commit
to TheCakeIsNaOH/choco
that referenced
this issue
Nov 5, 2021
When running on mono on a non-Windows system, the ProtectedData methods use /usr/local/.mono/keypair as the folder to save keypairs. This folder is not normally writable by non-root users, thus erroring when used by a normal user. This catches that error and falls back to using the CurrentUser scope. Also, during data unprotection, it will try to fall back to CurrentUser scope if the decryption fails for other reasons, so as to attempt to decrypt data encrypted with CurrentUser if the LocalSystem scope starts working.
gep13
pushed a commit
to TheCakeIsNaOH/choco
that referenced
this issue
Nov 12, 2021
When running on mono on a non-Windows system, the ProtectedData methods use /usr/local/.mono/keypair as the folder to save keypairs. This folder is not normally writable by non-root users, thus erroring when used by a normal user. This catches that error and falls back to using the CurrentUser scope. Also, during data unprotection, it will try to fall back to CurrentUser scope if the decryption fails for other reasons, so as to attempt to decrypt data encrypted with CurrentUser if the LocalSystem scope starts working.
gep13
added a commit
that referenced
this issue
Nov 12, 2021
(#2437) Fall back to CurrentUser scope when permission denied
gep13
changed the title
Mono ProtectedData.Protect with LocalMachine scope fails when run as a non-root user
Attempting to use ProtectedData.Protect with LocalMachine scope fails when run on non-Windows system as a non-root user
Jan 17, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What You Are Seeing?
Issue first found here:
#2435 (comment)
When running choco as a non-root user, choco install can fail.
First, it outputs this message
Then later on, it exits with this error
What is Expected?
That a debug build of choco can install (portable) packages as non-root.
How Did You Get This To Happen? (Steps to Reproduce)
mono choco.exe install curl
as a non-root user from thebuild_output/chocolatey
folder.What is really going on
ProtectedData.Protect
stores it's keypair for theLocalMachine
scope inside/usr/share/.mono
by default. However, that folder is not writable by non-root users. So, whenProtectedData.Protect
tries to generate a keypair there and choco is not running as a root user, it throws an error.This specifically an issue when it is called inside
ChocolateyPackageService.capture_arguments
, as the error is caught by a try/catch block inNugetService.install_run
, so it just outputs the outer exception message and continues. That catch block re-runsChocolateyPackageService.handle_package_result
which then re-runsChocolateyPackageService.set_pending
, which then tries and fails to create the.chocolateyPending
file. This results in the misleading error message.Output Log
Full Log Output
The text was updated successfully, but these errors were encountered: