diff options
author | djm@openbsd.org <djm@openbsd.org> | 2016-04-29 08:07:53 +0000 |
---|---|---|
committer | Colin Watson <cjwatson@debian.org> | 2016-07-22 14:16:22 +0100 |
commit | 751d1f6494fb3ffd75188de7390c28725a5b91a6 (patch) | |
tree | a9c60b131cd3d31c3b27619da11f49246bc4baa9 /ssh.c | |
parent | abde8dda29c2db2405d6fbca2fe022430e2c1177 (diff) |
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
Origin: upstream, https://anongit.mindrot.org/openssh.git/commit/?id=d2d6bf864e52af8491a60dd507f85b74361f5da3
Bug: https://bugzilla.mindrot.org/show_bug.cgi?id=1988
Bug-Debian: https://bugs.debian.org/714526
Last-Update: 2016-07-22
Patch-Name: control-persist-close-stderr.patch
Diffstat (limited to 'ssh.c')
-rw-r--r-- | ssh.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -1392,7 +1392,7 @@ static void | |||
1392 | control_persist_detach(void) | 1392 | control_persist_detach(void) |
1393 | { | 1393 | { |
1394 | pid_t pid; | 1394 | pid_t pid; |
1395 | int devnull; | 1395 | int devnull, keep_stderr; |
1396 | 1396 | ||
1397 | debug("%s: backgrounding master process", __func__); | 1397 | debug("%s: backgrounding master process", __func__); |
1398 | 1398 | ||
@@ -1423,8 +1423,10 @@ control_persist_detach(void) | |||
1423 | error("%s: open(\"/dev/null\"): %s", __func__, | 1423 | error("%s: open(\"/dev/null\"): %s", __func__, |
1424 | strerror(errno)); | 1424 | strerror(errno)); |
1425 | } else { | 1425 | } else { |
1426 | keep_stderr = log_is_on_stderr() && debug_flag; | ||
1426 | if (dup2(devnull, STDIN_FILENO) == -1 || | 1427 | if (dup2(devnull, STDIN_FILENO) == -1 || |
1427 | dup2(devnull, STDOUT_FILENO) == -1) | 1428 | dup2(devnull, STDOUT_FILENO) == -1 || |
1429 | (!keep_stderr && dup2(devnull, STDERR_FILENO) == -1)) | ||
1428 | error("%s: dup2: %s", __func__, strerror(errno)); | 1430 | error("%s: dup2: %s", __func__, strerror(errno)); |
1429 | if (devnull > STDERR_FILENO) | 1431 | if (devnull > STDERR_FILENO) |
1430 | close(devnull); | 1432 | close(devnull); |