Skip to content

Commit ed76997

Browse files
authored
add back explicit termination of preauth child process (#814)
1 parent 2586de1 commit ed76997

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

regress/pesterTests/SSHD.Tests.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ Describe "E2E scenarios for sshd" -Tags "CI" {
5555

5656
# with a connection, there should be two additional session processes
5757
$sshdPidsCountWithConn | Should Be (2 + $sshdPidCountBefore)
58-
# after LoginGraceTime expires, one of the session processes should exit
59-
$sshdPidsCountAfter | Should Be (1 + $sshdPidCountBefore)
58+
# after LoginGraceTime expires, both session processes should exit
59+
$sshdPidsCountAfter | Should Be $sshdPidCountBefore
6060
}
6161

6262
It "sshd pre-auth process is spawned under runtime generated virtual account" {

sshd-session.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ pack_config(struct sshbuf* conf)
335335
static void
336336
send_config_state(int fd, struct sshbuf* conf)
337337
{
338-
/* copied from send_rexec_state() in sshd.c
338+
/* copied from send_rexec_state() in sshd.c
339339
On Windows, uses pack_hostkeys_for_child() and pack_config() */
340340
struct sshbuf* keys;
341341
u_int mlen;
@@ -542,7 +542,15 @@ privsep_child_cmdline()
542542
static void
543543
grace_alarm_handler(int sig)
544544
{
545-
#ifndef WINDOWS
545+
#ifdef WINDOWS
546+
/*
547+
* continue to use explicit kill on the child process ID
548+
* Windows does not currently support authorized keys
549+
* command helpers, so this is sufficient
550+
*/
551+
if (pmonitor != NULL && pmonitor->m_pid > 0)
552+
kill(pmonitor->m_pid, SIGALRM);
553+
#else
546554
/*
547555
* Try to kill any processes that we have spawned, E.g. authorized
548556
* keys command helpers or privsep children.

0 commit comments

Comments
 (0)