summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2020-07-03 06:46:41 +0000
committerDamien Miller <djm@mindrot.org>2020-07-03 17:03:54 +1000
commitc8935081db35d73ee6355999142fa0776a2af912 (patch)
tree1bf5f1086d43b9087b8604a7a5d8f20d3eca788e
parent183c4aaef944af3a1a909ffa01058c65bac55748 (diff)
upstream: when redirecting sshd's log output to a file, undo this
redirection after the session child process is forked(); ok dtucker@ OpenBSD-Commit-ID: 6df86dd653c91f5bc8ac1916e7680d9d24690865
-rw-r--r--log.c10
-rw-r--r--session.c5
2 files changed, 13 insertions, 2 deletions
diff --git a/log.c b/log.c
index d9c2d136c..6b1a7a314 100644
--- a/log.c
+++ b/log.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: log.c,v 1.51 2018/07/27 12:03:17 markus Exp $ */ 1/* $OpenBSD: log.c,v 1.52 2020/07/03 06:46:41 djm Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -370,6 +370,14 @@ log_redirect_stderr_to(const char *logfile)
370{ 370{
371 int fd; 371 int fd;
372 372
373 if (logfile == NULL) {
374 if (log_stderr_fd != STDERR_FILENO) {
375 close(log_stderr_fd);
376 log_stderr_fd = STDERR_FILENO;
377 }
378 return;
379 }
380
373 if ((fd = open(logfile, O_WRONLY|O_CREAT|O_APPEND, 0600)) == -1) { 381 if ((fd = open(logfile, O_WRONLY|O_CREAT|O_APPEND, 0600)) == -1) {
374 fprintf(stderr, "Couldn't open logfile %s: %s\n", logfile, 382 fprintf(stderr, "Couldn't open logfile %s: %s\n", logfile,
375 strerror(errno)); 383 strerror(errno));
diff --git a/session.c b/session.c
index f6193b98e..a37eb4ae2 100644
--- a/session.c
+++ b/session.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: session.c,v 1.320 2020/06/26 04:45:11 dtucker Exp $ */ 1/* $OpenBSD: session.c,v 1.321 2020/07/03 06:46:41 djm Exp $ */
2/* 2/*
3 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 3 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
4 * All rights reserved 4 * All rights reserved
@@ -1501,6 +1501,9 @@ child_close_fds(struct ssh *ssh)
1501 */ 1501 */
1502 endpwent(); 1502 endpwent();
1503 1503
1504 /* Stop directing logs to a high-numbered fd before we close it */
1505 log_redirect_stderr_to(NULL);
1506
1504 /* 1507 /*
1505 * Close any extra open file descriptors so that we don't have them 1508 * Close any extra open file descriptors so that we don't have them
1506 * hanging around in clients. Note that we want to do this after 1509 * hanging around in clients. Note that we want to do this after