=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ssh/readconf.c,v retrieving revision 1.336 retrieving revision 1.337 diff -u -r1.336 -r1.337 --- src/usr.bin/ssh/readconf.c 2020/10/03 08:30:47 1.336 +++ src/usr.bin/ssh/readconf.c 2020/10/03 09:22:26 1.337 @@ -1,4 +1,4 @@ -/* $OpenBSD: readconf.c,v 1.336 2020/10/03 08:30:47 djm Exp $ */ +/* $OpenBSD: readconf.c,v 1.337 2020/10/03 09:22:26 djm Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -495,7 +495,7 @@ { char *shell; pid_t pid; - int devnull, status; + int status; if ((shell = getenv("SHELL")) == NULL) shell = _PATH_BSHELL; @@ -505,23 +505,14 @@ shell, strerror(errno)); } - /* Need this to redirect subprocess stdin/out */ - if ((devnull = open(_PATH_DEVNULL, O_RDWR)) == -1) - fatal("open(/dev/null): %s", strerror(errno)); - debug("Executing command: '%.500s'", cmd); /* Fork and execute the command. */ if ((pid = fork()) == 0) { char *argv[4]; - /* Redirect child stdin and stdout. Leave stderr */ - if (dup2(devnull, STDIN_FILENO) == -1) - fatal("dup2: %s", strerror(errno)); - if (dup2(devnull, STDOUT_FILENO) == -1) - fatal("dup2: %s", strerror(errno)); - if (devnull > STDERR_FILENO) - close(devnull); + if (stdfd_devnull(1, 1, 0) == -1) + fatal("%s: stdfd_devnull failed", __func__); closefrom(STDERR_FILENO + 1); argv[0] = shell; @@ -539,8 +530,6 @@ /* Parent. */ if (pid == -1) fatal("%s: fork: %.100s", __func__, strerror(errno)); - - close(devnull); while (waitpid(pid, &status, 0) == -1) { if (errno != EINTR && errno != EAGAIN)