summaryrefslogtreecommitdiffstats
path: root/ssh.c
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2016-04-29 10:07:53 +0200
committerDamien Miller <djm@mindrot.org>2016-04-29 10:09:02 +0200
commitd2d6bf864e52af8491a60dd507f85b74361f5da3 (patch)
treeaee80e780864479d2b477f7698adeecd47c5a5e8 /ssh.c
parentupstream commit (diff)
downloadopenssh-d2d6bf864e52af8491a60dd507f85b74361f5da3.tar.xz
openssh-d2d6bf864e52af8491a60dd507f85b74361f5da3.zip
upstream commit
close ControlPersist background process stderr when not in debug mode or when logging to a file or syslog. bz#1988 ok dtucker Upstream-ID: 4fb726f0fdcb155ad419913cea10dc4afd409d24
Diffstat (limited to 'ssh.c')
-rw-r--r--ssh.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/ssh.c b/ssh.c
index a999d5079..a881ba14c 100644
--- a/ssh.c
+++ b/ssh.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssh.c,v 1.437 2016/03/07 19:02:43 djm Exp $ */
+/* $OpenBSD: ssh.c,v 1.438 2016/04/29 08:07:53 djm Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -1395,7 +1395,7 @@ static void
control_persist_detach(void)
{
pid_t pid;
- int devnull;
+ int devnull, keep_stderr;
debug("%s: backgrounding master process", __func__);
@@ -1426,8 +1426,10 @@ control_persist_detach(void)
error("%s: open(\"/dev/null\"): %s", __func__,
strerror(errno));
} else {
+ keep_stderr = log_is_on_stderr() && debug_flag;
if (dup2(devnull, STDIN_FILENO) == -1 ||
- dup2(devnull, STDOUT_FILENO) == -1)
+ dup2(devnull, STDOUT_FILENO) == -1 ||
+ (!keep_stderr && dup2(devnull, STDERR_FILENO) == -1))
error("%s: dup2: %s", __func__, strerror(errno));
if (devnull > STDERR_FILENO)
close(devnull);