options: Use exec for the proxy command

This wont create a new process but replace the shell.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
This commit is contained in:
Andreas Schneider
2022-08-29 14:01:53 +02:00
parent d642b20d9c
commit bd2db30174

View File

@@ -1518,7 +1518,23 @@ int ssh_options_apply(ssh_session session)
session->opts.global_knownhosts = tmp;
if (session->opts.ProxyCommand != NULL) {
tmp = ssh_path_expand_escape(session, session->opts.ProxyCommand);
char *p = NULL;
size_t plen = strlen(session->opts.ProxyCommand) +
5 /* strlen("exec ") */;
p = malloc(plen + 1 /* \0 */);
if (p == NULL) {
return -1;
}
rc = snprintf(p, plen + 1, "exec %s", session->opts.ProxyCommand);
if ((size_t)rc != plen) {
free(p);
return -1;
}
tmp = ssh_path_expand_escape(session, p);
free(p);
if (tmp == NULL) {
return -1;
}