Skip to content

Commit

Permalink
(GH-560) Load ChocolateyInstaller module from known location
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ferventcoder committed Jan 20, 2016
1 parent 2e98de3 commit 90d53ee
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/chocolatey/infrastructure.app/services/PowershellService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 90d53ee

Please sign in to comment.