Chocolatey CLI is incorrectly reporting bad permissions on the HttpCache folder and is not setting them correctly
Checklist
- I confirm there are no unresolved issues reported on the Chocolatey Status page.
- I have verified this is the correct repository for opening this issue.
- I have verified no other issues exist related to my problem.
- I have verified this is not an issue for a specific package.
- I have verified this issue is not security related.
- I confirm I am using official, and not unofficial, or modified, Chocolatey products.
What You Are Seeing?
When the permissions on the httpcache folder are changed, Chocolatey CLI shows the following validation warning:
System Cache directory is not locked down to administrators. Remove the directory 'C:\ProgramData\ChocolateyHttpCache' to have Chocolatey CLI create it with the proper permissions. When trying to resolve this warning, the user ran an Advanced Deployment Step in Chocolatey Central Management to remove the httpcache folder and have Chocolatey CLI recreate it. Chocolatey CLI creates the cache folder, with all local machine users having write access to the folder. This permission change causes the recreated httpcache folder to report the same issue of the folder not being locked down to just Administrator user access.
What is Expected?
Chocolatey should be able to recreate this folder with the correct permissions. Chocolatey should be setting the cache folder's ACL before every run of Chocolatey.
How Did You Get This To Happen?
- Install Chocolatey for Business and license it. Note the current permissions on
C:\ProgamData\ChocolateyHttpCachefolder. - Go to the
C:\ProgamData\ChocolateyHttpCachefolder and edit the permissions to addLocalMachine\Usersobject to include Write access. - Run
choco listand the validation warning mentioned above, should be shown. - Undo the folder permissions change done in Step 2.
- Run the following exported Chocolatey Central Management deployment against your test machine.
- You should notice that the
C:\ProgamData\ChocolateyHttpCachefolder has been re-created. However,Usersnow haveWriteaccess, and theCREATOR OWNERhasFull Controlrights. If you runchoco listagain, you get the same validation warning message.
System Details
- Operating System: 20348.3091 (Windows Server 2022)
- Windows PowerShell Version: 5.1.20348.2849
- Chocolatey CLI Version: 2.4.2
- Chocolatey Licensed Extension version: 6.3.1
- Chocolatey Agent version: 2.2.2
- Chocolatey License type (Professional / Business / ?): Business
- Terminal/Emulator: Windows PowerShell & Chocolatey Central Management
Installed Packages
N/AOutput Log
[chocolatey.log](https://gist.github.com/ryanrichter94/1cf7cba454db54ec7d48664842e65012)Additional Context
Adding the following to the PowerShell of the Advanced Deployment Step in the reproduction steps of this issue will programmatically recreate the cache folder, mirroring the ACLs from $env:ChocolateyInstall onto it.
if (Test-Path -Path "C:\ProgramData\ChocolateyHttpCache"){
Write-Error "Chocolatey Cache directory still exists!"
} else {
Write-Output "Recreating Chocolatey Cache Directory"
New-Item -Path "C:\ProgramData\" -Name "ChocolateyHttpCache" -ItemType "directory"
Write-Output "Setting correct permissions for Chocolatey Cache Directory"
$ChocolateyACL = Get-Acl -Path $env:ChocolateyInstall
Set-Acl -Path "C:\ProgramData\ChocolateyHttpCache" -AclObject $ChocolateyAcl
}┆Issue is synchronized with this Clickup task by Unito
Source: chocolatey/choco