summaryrefslogtreecommitdiff
path: root/usr.bin/ssh/log.c
diff options
context:
space:
mode:
authorDamien Miller <djm@cvs.openbsd.org>2020-07-03 06:46:42 +0000
committerDamien Miller <djm@cvs.openbsd.org>2020-07-03 06:46:42 +0000
commitf81531bda1462524d448ce4a147cda3aecf401a5 (patch)
tree859cf0fd5132f6241a5c1f33dc70786bcf07d014 /usr.bin/ssh/log.c
parent21cffd728ed60e74cfc5dac7f6486109c5427c7d (diff)
when redirecting sshd's log output to a file, undo this redirection
after the session child process is forked(); ok dtucker@
Diffstat (limited to 'usr.bin/ssh/log.c')
-rw-r--r--usr.bin/ssh/log.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/usr.bin/ssh/log.c b/usr.bin/ssh/log.c
index 8456bd76d88..5f5757fb16e 100644
--- a/usr.bin/ssh/log.c
+++ b/usr.bin/ssh/log.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: log.c,v 1.51 2018/07/27 12:03:17 markus Exp $ */
+/* $OpenBSD: log.c,v 1.52 2020/07/03 06:46:41 djm Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -336,6 +336,14 @@ log_redirect_stderr_to(const char *logfile)
{
int fd;
+ if (logfile == NULL) {
+ if (log_stderr_fd != STDERR_FILENO) {
+ close(log_stderr_fd);
+ log_stderr_fd = STDERR_FILENO;
+ }
+ return;
+ }
+
if ((fd = open(logfile, O_WRONLY|O_CREAT|O_APPEND, 0600)) == -1) {
fprintf(stderr, "Couldn't open logfile %s: %s\n", logfile,
strerror(errno));