fix installers not updating system path (#622)
* fix msi installer not updating system path * modify install script to add binary path to system path * debug appveyor * add debug message to add-path and update appveyor to be compatible with changes * fix appveyorhelper.psm1 after accidentally removing call to uninstall * fix typo * use PS drive to modify PATH * rename Add-Path to Add-MachinePath in export list
This commit is contained in:
parent
13a249a7ee
commit
1f03b276fd
|
@ -23,6 +23,9 @@
|
|||
<MajorUpgrade Schedule="afterInstallInitialize" DowngradeErrorMessage="A newer version of !(bind.property.ProductName) is already installed." />
|
||||
<Condition Message="OpenSSH is supported only on Windows 7 and newer."><![CDATA[VersionNT >= 601]]></Condition>
|
||||
|
||||
<!-- assume user wants path to be updated when client binaries are installed, can be overridden during install with ADD_PATH=0 -->
|
||||
<Property Id="ADD_PATH" Value="1" />
|
||||
|
||||
<Feature Id="Client" AllowAdvertise="no">
|
||||
<ComponentGroupRef Id="Client" />
|
||||
</Feature>
|
||||
|
|
|
@ -171,9 +171,12 @@ function Install-OpenSSH
|
|||
|
||||
$machinePath = [Environment]::GetEnvironmentVariable('Path', 'MACHINE')
|
||||
$newMachineEnvironmentPath = $machinePath
|
||||
if (-not ($machinePath.ToLower().Contains($OpenSSHDir.ToLower())))
|
||||
if (-not $machinePath.ToLower().Contains("$OpenSSHDir;".ToLower()))
|
||||
{
|
||||
$newMachineEnvironmentPath = "$OpenSSHDir;$newMachineEnvironmentPath"
|
||||
}
|
||||
if (-not $env:Path.ToLower().Contains("$OpenSSHDir;".ToLower()))
|
||||
{
|
||||
$env:Path = "$OpenSSHDir;$env:Path"
|
||||
}
|
||||
# Update machine environment path
|
||||
|
|
|
@ -829,4 +829,25 @@ function Enable-Privilege {
|
|||
$type[0]::EnablePrivilege($Privilege, $Disable)
|
||||
}
|
||||
|
||||
Export-ModuleMember -Function Repair-FilePermission, Repair-SshdConfigPermission, Repair-SshdHostKeyPermission, Repair-AuthorizedKeyPermission, Repair-UserKeyPermission, Repair-UserSshConfigPermission, Enable-Privilege, Get-UserAccount, Get-UserSID, Repair-AdministratorsAuthorizedKeysPermission, Repair-ModuliFilePermission, Repair-SSHFolderPermission, Repair-SSHFolderFilePermission, Repair-SSHFolderPrivateKeyPermission
|
||||
Function Add-MachinePath {
|
||||
[CmdletBinding(SupportsShouldProcess=$true, ConfirmImpact="High")]
|
||||
param
|
||||
(
|
||||
[parameter(Mandatory=$true)]
|
||||
[string]$FilePath
|
||||
)
|
||||
|
||||
if (Test-Path $FilePath) {
|
||||
$machinePath = (Get-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH).Path
|
||||
if (-not $machinePath.ToLower().Contains("$FilePath;".ToLower()))
|
||||
{
|
||||
$newPath = $FilePath + ’;’ + $machinePath
|
||||
Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH –Value $newPath
|
||||
if ((Get-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH).Path -eq $newPath) {
|
||||
Write-Host "Updated Machine PATH to include OpenSSH directory, restart/re-login required to take effect globally" -ForegroundColor Yellow
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Export-ModuleMember -Function Repair-FilePermission, Repair-SshdConfigPermission, Repair-SshdHostKeyPermission, Repair-AuthorizedKeyPermission, Repair-UserKeyPermission, Repair-UserSshConfigPermission, Enable-Privilege, Get-UserAccount, Get-UserSID, Repair-AdministratorsAuthorizedKeysPermission, Repair-ModuliFilePermission, Repair-SSHFolderPermission, Repair-SSHFolderFilePermission, Repair-SSHFolderPrivateKeyPermission, Add-MachinePath
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
# @manojampalam - removed ntrights.exe dependency
|
||||
# @bingbing8 - removed secedit.exe dependency
|
||||
# @tessgauthier - added permissions check for %programData%/ssh
|
||||
# @tessgauthier - added update to system path for scp/sftp discoverability
|
||||
|
||||
[CmdletBinding(SupportsShouldProcess=$true, ConfirmImpact="High")]
|
||||
param ()
|
||||
|
@ -126,3 +127,6 @@ New-Service -Name sshd -DisplayName "OpenSSH SSH Server" -BinaryPathName `"$sshd
|
|||
sc.exe privs sshd SeAssignPrimaryTokenPrivilege/SeTcbPrivilege/SeBackupPrivilege/SeRestorePrivilege/SeImpersonatePrivilege
|
||||
|
||||
Write-Host -ForegroundColor Green "sshd and ssh-agent services successfully installed"
|
||||
|
||||
# add folder to system PATH
|
||||
Add-MachinePath -FilePath $scriptdir @psBoundParameters
|
||||
|
|
Loading…
Reference in New Issue