From 90d53ee9d8f6dd241dd3d502f563f4f892e7b063 Mon Sep 17 00:00:00 2001 From: Rob Reynolds Date: Wed, 20 Jan 2016 11:03:15 -0600 Subject: [PATCH] (GH-560) Load ChocolateyInstaller module from known location Only load the chocolateyinstaller module and script runner powershell file from an exact known location. This reduces the chance that it could be found and used from another location under the Chocolatey Install directory location. --- .../infrastructure.app/services/PowershellService.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/chocolatey/infrastructure.app/services/PowershellService.cs b/src/chocolatey/infrastructure.app/services/PowershellService.cs index 38bb87cee6..55c226f025 100644 --- a/src/chocolatey/infrastructure.app/services/PowershellService.cs +++ b/src/chocolatey/infrastructure.app/services/PowershellService.cs @@ -97,12 +97,15 @@ public bool uninstall(ChocolateyConfiguration configuration, PackageResult packa return run_action(configuration, packageResult, CommandNameType.uninstall); } + private string get_helpers_folder() + { + return _fileSystem.combine_paths(ApplicationParameters.InstallLocation, "helpers"); + } + public string wrap_script_with_module(string script, ChocolateyConfiguration config) { - var installerModules = _fileSystem.get_files(ApplicationParameters.InstallLocation, "chocolateyInstaller.psm1", SearchOption.AllDirectories); - var installerModule = installerModules.FirstOrDefault(); - var scriptRunners = _fileSystem.get_files(ApplicationParameters.InstallLocation, "chocolateyScriptRunner.ps1", SearchOption.AllDirectories); - var scriptRunner = scriptRunners.FirstOrDefault(); + var installerModule = _fileSystem.combine_paths(get_helpers_folder(), "chocolateyInstaller.psm1"); + var scriptRunner = _fileSystem.combine_paths(get_helpers_folder(), "chocolateyScriptRunner.ps1"); // removed setting all errors to terminating. Will cause too // many issues in existing packages, including upgrading // Chocolatey from older POSH client due to log errors