1
1

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>
Этот коммит содержится в:
Jakub Jelen 2019-06-19 14:27:36 +02:00
родитель bd65568749
Коммит 6c49c41c19

Просмотреть файл

@ -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);