fix bash test failures

This commit is contained in:
Tess Gauthier 2024-08-15 15:59:46 -04:00
parent 8e7aee937a
commit 9215a127ba
3 changed files with 17 additions and 7 deletions

View File

@ -45,8 +45,14 @@ echo "ls ${OBJ}" | ${SFTP} -D ${SFTPSERVER} >/dev/null 2>&1 \
# XXX always successful # XXX always successful
verbose "$tid: shell" verbose "$tid: shell"
echo "!echo hi there" | ${SFTP} -D ${SFTPSERVER} 2>&1 | \ if [ "$os" == "windows" ]; then
egrep '^hi there$' >/dev/null || fail "shell failed" # Windows output has additional text so change grep check to be less strict
echo "!echo hi there" | ${SFTP} -D ${SFTPSERVER} 2>&1 | \
grep -E 'hi there' >/dev/null || fail "shell failed"
else
echo "!echo hi there" | ${SFTP} -D ${SFTPSERVER} 2>&1 | \
grep -E '^hi there$' >/dev/null || fail "shell failed"
fi
verbose "$tid: pwd" verbose "$tid: pwd"
echo "pwd" | ${SFTP} -D ${SFTPSERVER} >/dev/null 2>&1 \ echo "pwd" | ${SFTP} -D ${SFTPSERVER} >/dev/null 2>&1 \

View File

@ -494,7 +494,11 @@ fill_default_server_options(ServerOptions *options)
if (options->unused_connection_timeout == -1) if (options->unused_connection_timeout == -1)
options->unused_connection_timeout = 0; options->unused_connection_timeout = 0;
if (options->sshd_session_path == NULL) if (options->sshd_session_path == NULL)
#ifdef WINDOWS
options->sshd_session_path = derelativise_path(_PATH_SSHD_SESSION);
#else
options->sshd_session_path = xstrdup(_PATH_SSHD_SESSION); options->sshd_session_path = xstrdup(_PATH_SSHD_SESSION);
#endif /* WINDOWS */
assemble_algorithms(options); assemble_algorithms(options);

6
sshd.c
View File

@ -1154,8 +1154,8 @@ server_accept_loop(int *sock_in, int *sock_out, int *newsock, int *config_s,
posix_spawnattr_setpgroup(&attributes, 0) != 0) posix_spawnattr_setpgroup(&attributes, 0) != 0)
error("posix_spawn initialization failed"); error("posix_spawn initialization failed");
else { else {
pid_t pid; child = child_register(startup_p[0], *newsock);
if (posix_spawn(&pid, rexec_argv[0], &actions, &attributes, rexec_argv, NULL) != 0) if (posix_spawn(&child->pid, rexec_argv[0], &actions, &attributes, rexec_argv, NULL) != 0)
error("%s, posix_spawn failed", __func__); error("%s, posix_spawn failed", __func__);
posix_spawn_file_actions_destroy(&actions); posix_spawn_file_actions_destroy(&actions);
posix_spawnattr_destroy(&attributes); posix_spawnattr_destroy(&attributes);
@ -1922,7 +1922,7 @@ main(int ac, char **av)
send_rexec_state(config_s[0], cfg); send_rexec_state(config_s[0], cfg);
close(config_s[0]); close(config_s[0]);
close(newsock); close(newsock);
cleanup_exit(0); cleanup_exit(255);
#endif /* FORK_NOT_SUPPORTED */ #endif /* FORK_NOT_SUPPORTED */
} }