Skip to content
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

(chocolatey-core.extension/extensions/Get-AppInstallLocation.ps1) Access Denied on Program Files directory will fail all application installs #13

Open
waikinw opened this issue Dec 16, 2021 · 3 comments
Assignees
Labels

Comments

@waikinw
Copy link

waikinw commented Dec 16, 2021

If any directory gets Access Denied (due to antivirus), the current function will fail. Antivirus does not allow directory scan for its own directory under "C:\Program Files**" - "C:\Program Files\AntivirusSoftware". This makes all packages that try to install using using this extension also fail since the app can't complete its registration.

Expected Behavior

Package/Application installs completes successfully.

Current Behavior

Package/Application installs fail when using this function.

Possible Solution

The fix below works but there may be a better method to scan dirs.

For Get-AppInstallLocation.ps1:

line 63 of Get-AppInstallLocation.ps1

Write-Verbose "Trying Program Files with 2 levels depth: $dirs"
#$dirs = $Env:ProgramFiles, "$Env:ProgramFiles\*\*"
#if (Get-ProcessorBits 64) { $dirs += ${ENV:ProgramFiles(x86)}, "${ENV:ProgramFiles(x86)}\*\*" }
#$location = (ls $dirs | ? {$_.PsIsContainer}) -match $AppNamePattern | select -First 1 | % {$_.FullName}
$dirs = @($Env:ProgramFiles)
if (Get-ProcessorBits 64) { $dirs += ${ENV:ProgramFiles(x86)}}
$location = (ls $dirs -filter '*' -depth 2 | ? {$_.PsIsContainer}) -match $AppNamePattern | select -First 1 | % {$_.FullName}

Steps to Reproduce (for bugs)

  1. Create directory under C:\Program Files\AntivirusApp
  2. Revoke all permissions to that directory to simulate "Access Denied" (such as to simulate antivirus blocking all read access)
  3. Attempt app install that uses Chocolatey Core extension -- choco install notepadplusplus

Context

Unable to install any packages using this extension

@AdmiringWorm AdmiringWorm added 0 - _Triaging bug Something isn't working labels Jan 4, 2022
@AdmiringWorm AdmiringWorm self-assigned this Jan 4, 2022
@AdmiringWorm
Copy link
Member

unfortunately, using -depth 2 on the ls alias is not possible.

That option was added in PowerShell v5, and we need to be PowerShell v2 compatible.
I am not sure how to resolve this at the top of my head, but I'll look into it when I have a chance.

@majkinetor
Copy link

@waikinw , Did you try adding -ErrorAction ignore to the original code on ls command?

@waikinw
Copy link
Author

waikinw commented Jan 25, 2022 via email

@AdmiringWorm AdmiringWorm transferred this issue from chocolatey-community/chocolatey-packages Apr 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants