fix testbreak with SSH_ASKPASS change (#394)

Added askpass utility to support change around SSH_ASKPASS logic. Since prompt is now passed as a commandline parameter to SSH_ASKPASS, "cmd /c echo" based logic no longer works for automated passing of password.
This commit is contained in:
Manoj Ampalam 2019-09-13 14:13:42 -07:00 committed by GitHub
parent 675e761d75
commit d9773976a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 24 additions and 2 deletions

View File

@ -345,10 +345,13 @@ function Get-LocalUserProfile
if (-not (Test-Path $userProfileRegistry) ) {
#create profile
if (-not($env:DISPLAY)) { $env:DISPLAY = 1 }
$env:SSH_ASKPASS="$($env:ComSpec) /c echo $($OpenSSHTestAccountsPassword)"
$askpass_util = Join-Path $Script:E2ETestDirectory "utilities\askpass_util\askpass_util.exe"
$env:SSH_ASKPASS=$askpass_util
$env:ASKPASS_PASSWORD=$OpenSSHTestAccountsPassword
$ret = ssh -p 47002 "$User@localhost" echo %userprofile%
if ($env:DISPLAY -eq 1) { Remove-Item env:\DISPLAY }
remove-item "env:SSH_ASKPASS" -ErrorAction SilentlyContinue
Remove-item "env:ASKPASS_PASSWORD" -ErrorAction SilentlyContinue
}
(Get-ItemProperty -Path $userProfileRegistry -Name 'ProfileImagePath').ProfileImagePath

View File

@ -97,7 +97,9 @@ function Add-PasswordSetting
$platform = Get-Platform
if ($platform -eq [PlatformType]::Windows) {
if (-not($env:DISPLAY)) {$env:DISPLAY = 1}
$env:SSH_ASKPASS="cmd.exe /c echo $pass"
$askpass_util = Join-Path $PSScriptRoot "utilities\askpass_util\askpass_util.exe"
$env:SSH_ASKPASS=$askpass_util
$env:ASKPASS_PASSWORD=$pass
}
}
@ -105,6 +107,7 @@ function Remove-PasswordSetting
{
if ($env:DISPLAY -eq 1) { Remove-Item env:\DISPLAY }
Remove-item "env:SSH_ASKPASS" -ErrorAction SilentlyContinue
Remove-item "env:ASKPASS_PASSWORD" -ErrorAction SilentlyContinue
}
$Taskfolder = "\OpenSSHTestTasks\"

View File

@ -0,0 +1,3 @@
askpass_util is a test utility to be used in conjunction with SSH_ASKPASS in ssh.
It simply spits out environment variable stored in ASKPASS_PASSWORD.

View File

@ -0,0 +1,13 @@
// askpass_util.cpp : Defines the entry point for the console application.
//
#include <Windows.h>
#include <stdio.h>
int main()
{
//read from environment variable, spit it out on stdout
printf("%s", getenv("ASKPASS_PASSWORD"));
return 0;
}