summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jelen <jjelen@redhat.com>2019-12-19 18:56:43 +0100
committerAndreas Schneider <asn@cryptomilk.org>2019-12-23 14:45:24 +0100
commite5553a92d9ed34d2926673b0e672d7c43b33a1d2 (patch)
tree43365a82439b4394f8e148203cda1dfc3c65c9c7
parent3a6751f3d2318abb63975439104543ee6f3131ad (diff)
downloadlibssh-e5553a92d9ed34d2926673b0e672d7c43b33a1d2.tar.gz
libssh-e5553a92d9ed34d2926673b0e672d7c43b33a1d2.tar.xz
libssh-e5553a92d9ed34d2926673b0e672d7c43b33a1d2.zip
socket: Use the users shell for running proxy command
Fixes T200 and tests on ubuntu, which is using dash Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
-rw-r--r--src/socket.c16
1 files 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);