diff options
author | djm@openbsd.org <djm@openbsd.org> | 2020-10-03 11:22:26 +0200 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2020-10-03 11:34:24 +0200 |
commit | 396d32f3a1a16e54df2a76b2a9b237868580dcbe (patch) | |
tree | 77019a916fcb969986a349aaede7409a25778b6a /readpass.c | |
parent | upstream: enable UpdateHostkeys by default when the configuration (diff) | |
download | openssh-396d32f3a1a16e54df2a76b2a9b237868580dcbe.tar.xz openssh-396d32f3a1a16e54df2a76b2a9b237868580dcbe.zip |
upstream: There are lots of place where we want to redirect stdin,
stdout and/or stderr to /dev/null. Factor all these out to a single
stdfd_devnull() function that allows selection of which of these to redirect.
ok markus@
OpenBSD-Commit-ID: 3033ba5a4c47cacfd5def020d42cabc52fad3099
Diffstat (limited to 'readpass.c')
-rw-r--r-- | readpass.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/readpass.c b/readpass.c index 122d2a87c..7e79f49e4 100644 --- a/readpass.c +++ b/readpass.c @@ -1,4 +1,4 @@ -/* $OpenBSD: readpass.c,v 1.63 2020/08/11 09:45:54 djm Exp $ */ +/* $OpenBSD: readpass.c,v 1.64 2020/10/03 09:22:26 djm Exp $ */ /* * Copyright (c) 2001 Markus Friedl. All rights reserved. * @@ -232,7 +232,6 @@ notify_start(int force_askpass, const char *fmt, ...) { va_list args; char *prompt = NULL; - int devnull; pid_t pid; void (*osigchld)(int); const char *askpass, *s; @@ -270,11 +269,8 @@ notify_start(int force_askpass, const char *fmt, ...) return NULL; } if (pid == 0) { - if ((devnull = open(_PATH_DEVNULL, O_RDWR)) == -1) - fatal("%s: open %s", __func__, strerror(errno)); - if (dup2(devnull, STDIN_FILENO) == -1 || - dup2(devnull, STDOUT_FILENO) == -1) - fatal("%s: dup2: %s", __func__, strerror(errno)); + if (stdfd_devnull(1, 1, 0) == -1) + fatal("%s: stdfd_devnull failed", __func__); closefrom(STDERR_FILENO + 1); setenv("SSH_ASKPASS_PROMPT", "none", 1); /* hint to UI */ execlp(askpass, askpass, prompt, (char *)NULL); |