mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-11-30 13:01:23 +03:00
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>
This commit is contained in:
committed by
Andreas Schneider
parent
3a6751f3d2
commit
e5553a92d9
16
src/socket.c
16
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);
|
||||
|
||||
Reference in New Issue
Block a user