diff options
author | Jakub Jelen <jjelen@redhat.com> | 2019-06-19 14:27:36 +0200 |
---|---|---|
committer | Jakub Jelen <jjelen@redhat.com> | 2019-06-19 18:01:28 +0200 |
commit | 6c49c41c19157cbafb8f4b90276b83550da98da9 (patch) | |
tree | a561ba5b7dc5ebecca96d28d3113067eac6dc2a7 | |
parent | bd65568749a1da652ac15964347cc2f5835ee1fa (diff) | |
download | libssh-6c49c41c19157cbafb8f4b90276b83550da98da9.tar.gz libssh-6c49c41c19157cbafb8f4b90276b83550da98da9.tar.xz libssh-6c49c41c19157cbafb8f4b90276b83550da98da9.zip |
socket: Do not process stderr of proxy commands (Fixes T130)
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
-rw-r--r-- | src/socket.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/socket.c b/src/socket.c index 64c486e3..bbba443d 100644 --- a/src/socket.c +++ b/src/socket.c @@ -839,11 +839,18 @@ void ssh_execute_command(const char *command, socket_t in, socket_t out) { const char *args[] = {"/bin/sh", "-c", command, NULL}; + /* Prepare /dev/null socket for the stderr redirection */ + int devnull = open("/dev/null", O_WRONLY); + if (devnull == -1) { + SSH_LOG(SSH_LOG_WARNING, "Failed to open stderr"); + exit(1); + } - /* redirect in and out to stdin, stdout and stderr */ + /* redirect in and out to stdin, stdout */ dup2(in, 0); dup2(out, 1); - dup2(out, 2); + /* Ignore anything on the stderr */ + dup2(devnull, STDERR_FILENO); close(in); close(out); execv(args[0], (char * const *)args); |