From e5553a92d9ed34d2926673b0e672d7c43b33a1d2 Mon Sep 17 00:00:00 2001 From: Jakub Jelen Date: Thu, 19 Dec 2019 18:56:43 +0100 Subject: socket: Use the users shell for running proxy command Fixes T200 and tests on ubuntu, which is using dash Signed-off-by: Jakub Jelen Reviewed-by: Andreas Schneider --- src/socket.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/socket.c b/src/socket.c index 2fef8e7e..b3594311 100644 --- a/src/socket.c +++ b/src/socket.c @@ -869,14 +869,26 @@ int ssh_socket_connect(ssh_socket s, void ssh_execute_command(const char *command, socket_t in, socket_t out) { - const char *args[] = {"/bin/sh", "-c", command, NULL}; + const char *shell = NULL; + const char *args[] = {NULL/*shell*/, "-c", command, NULL}; + int devnull; + /* Prepare /dev/null socket for the stderr redirection */ - int devnull = open("/dev/null", O_WRONLY); + devnull = open("/dev/null", O_WRONLY); if (devnull == -1) { SSH_LOG(SSH_LOG_WARNING, "Failed to open /dev/null"); exit(1); } + /* By default, use the current users shell */ + shell = getenv("SHELL"); + if (shell == NULL || shell[0] == '\0') { + /* Fall back to bash. There are issues with dash or + * whatever people tend to link to /bin/sh */ + shell = "/bin/bash"; + } + args[0] = shell; + /* redirect in and out to stdin, stdout */ dup2(in, 0); dup2(out, 1); -- cgit v1.2.3