Skip to content

Commit 0096029

Browse files
authored
fix non-interactive session regression with sshd-session (#775)
* change sshd to sshd-session for process flag * add pester test
1 parent a96b3fb commit 0096029

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

contrib/win32/win32compat/w32fd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1084,7 +1084,7 @@ spawn_child_internal(const char* cmd, char *const argv[], HANDLE in, HANDLE out,
10841084
si.hStdError = err;
10851085
si.dwFlags = STARTF_USESTDHANDLES;
10861086

1087-
if (strstr(cmd, "sshd.exe")) {
1087+
if (strstr(cmd, "sshd-session.exe")) {
10881088
flags |= DETACHED_PROCESS;
10891089
}
10901090

regress/pesterTests/SSH.Tests.ps1

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,15 +244,41 @@ Describe "E2E scenarios for ssh client" -Tags "CI" {
244244
$o | Should Be `$env:computername
245245
}
246246
}
247+
248+
Context "$tC - configure powershell as default shell with admin user" {
249+
BeforeAll {
250+
$tI=1
251+
$shell_path = (Get-Command powershell.exe -ErrorAction SilentlyContinue).path
252+
if ($shell_path -ne $null) {
253+
ConfigureDefaultShell -default_shell_path $shell_path -default_shell_cmd_option_val "-c"
254+
}
255+
$password = $OpenSSHTestInfo['TestAccountPW']
256+
Add-PasswordSetting -Pass $password
257+
}
258+
AfterAll {
259+
$tC++
260+
Remove-ItemProperty -Path $dfltShellRegPath -Name $dfltShellRegKeyName -ErrorAction SilentlyContinue
261+
Remove-ItemProperty -Path $dfltShellRegPath -Name $dfltShellCmdOptionRegKeyName -ErrorAction SilentlyContinue
262+
Remove-PasswordSetting
263+
}
264+
265+
It "$tC.$tI - admin session can write to console" -skip:$skip {
266+
$adminusername = $OpenSSHTestInfo['AdminUser']
267+
$o = ssh $adminusername@test_target "Get-ComputerInfo"
268+
$LASTEXITCODE | Should Be 0
269+
$o | Select-String -Pattern "WindowsVersion" | Should Match "WindowsVersion"
270+
}
271+
}
272+
247273
Context "$tC - configure cmd as default shell" {
248274
BeforeAll {
249275
$tI=1
250276
$shell_path = (Get-Command cmd.exe -ErrorAction SilentlyContinue).path
251277
if($shell_path -ne $null) {
252278
ConfigureDefaultShell -default_shell_path $shell_path -default_shell_cmd_option_val "/c"
279+
}
253280
}
254-
}
255-
AfterAll{
281+
AfterAll {
256282
$tC++
257283
Remove-ItemProperty -Path $dfltShellRegPath -Name $dfltShellRegKeyName -ErrorAction SilentlyContinue
258284
Remove-ItemProperty -Path $dfltShellRegPath -Name $dfltShellCmdOptionRegKeyName -ErrorAction SilentlyContinue

0 commit comments

Comments
 (0)