mirror of
https://github.com/PowerShell/openssh-portable.git
synced 2025-07-29 16:54:51 +02:00
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:
parent
675e761d75
commit
d9773976a7
@ -345,10 +345,13 @@ function Get-LocalUserProfile
|
|||||||
if (-not (Test-Path $userProfileRegistry) ) {
|
if (-not (Test-Path $userProfileRegistry) ) {
|
||||||
#create profile
|
#create profile
|
||||||
if (-not($env:DISPLAY)) { $env:DISPLAY = 1 }
|
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%
|
$ret = ssh -p 47002 "$User@localhost" echo %userprofile%
|
||||||
if ($env:DISPLAY -eq 1) { Remove-Item env:\DISPLAY }
|
if ($env:DISPLAY -eq 1) { Remove-Item env:\DISPLAY }
|
||||||
remove-item "env:SSH_ASKPASS" -ErrorAction SilentlyContinue
|
remove-item "env:SSH_ASKPASS" -ErrorAction SilentlyContinue
|
||||||
|
Remove-item "env:ASKPASS_PASSWORD" -ErrorAction SilentlyContinue
|
||||||
}
|
}
|
||||||
|
|
||||||
(Get-ItemProperty -Path $userProfileRegistry -Name 'ProfileImagePath').ProfileImagePath
|
(Get-ItemProperty -Path $userProfileRegistry -Name 'ProfileImagePath').ProfileImagePath
|
||||||
|
@ -97,7 +97,9 @@ function Add-PasswordSetting
|
|||||||
$platform = Get-Platform
|
$platform = Get-Platform
|
||||||
if ($platform -eq [PlatformType]::Windows) {
|
if ($platform -eq [PlatformType]::Windows) {
|
||||||
if (-not($env:DISPLAY)) {$env:DISPLAY = 1}
|
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 }
|
if ($env:DISPLAY -eq 1) { Remove-Item env:\DISPLAY }
|
||||||
Remove-item "env:SSH_ASKPASS" -ErrorAction SilentlyContinue
|
Remove-item "env:SSH_ASKPASS" -ErrorAction SilentlyContinue
|
||||||
|
Remove-item "env:ASKPASS_PASSWORD" -ErrorAction SilentlyContinue
|
||||||
}
|
}
|
||||||
|
|
||||||
$Taskfolder = "\OpenSSHTestTasks\"
|
$Taskfolder = "\OpenSSHTestTasks\"
|
||||||
|
3
regress/pesterTests/utilities/askpass_util/README.txt
Normal file
3
regress/pesterTests/utilities/askpass_util/README.txt
Normal 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.
|
13
regress/pesterTests/utilities/askpass_util/askpass_util.cpp
Normal file
13
regress/pesterTests/utilities/askpass_util/askpass_util.cpp
Normal 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;
|
||||||
|
}
|
||||||
|
|
BIN
regress/pesterTests/utilities/askpass_util/askpass_util.exe
Normal file
BIN
regress/pesterTests/utilities/askpass_util/askpass_util.exe
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user