summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--log.c14
-rw-r--r--log.h3
-rw-r--r--session.c5
-rw-r--r--sshd.c13
5 files changed, 34 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index 01b30968c..3b92fd015 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
120020723 120020723
2 - (bal) [bsd-cray.c bsd-cray.h] Part 2 of Cray merger. 2 - (bal) [bsd-cray.c bsd-cray.h] Part 2 of Cray merger.
3 - (bal) OpenBSD Sync
4 - markus@cvs.openbsd.org 2002/07/19 15:43:33
5 [log.c log.h session.c sshd.c]
6 remove fatal cleanups after fork; based on discussions with and code
7 from solar.
3 8
420020722 920020722
5 - (bal) AIX tty data limiting patch fix by leigh@solinno.co.uk 10 - (bal) AIX tty data limiting patch fix by leigh@solinno.co.uk
@@ -1423,4 +1428,4 @@
1423 - (stevesk) entropy.c: typo in debug message 1428 - (stevesk) entropy.c: typo in debug message
1424 - (djm) ssh-keygen -i needs seeded RNG; report from markus@ 1429 - (djm) ssh-keygen -i needs seeded RNG; report from markus@
1425 1430
1426$Id: ChangeLog,v 1.2394 2002/07/23 21:00:17 mouring Exp $ 1431$Id: ChangeLog,v 1.2395 2002/07/23 21:01:56 mouring Exp $
diff --git a/log.c b/log.c
index 8c09ec1b2..96626d7d4 100644
--- a/log.c
+++ b/log.c
@@ -34,7 +34,7 @@
34 */ 34 */
35 35
36#include "includes.h" 36#include "includes.h"
37RCSID("$OpenBSD: log.c,v 1.23 2002/07/06 01:00:49 deraadt Exp $"); 37RCSID("$OpenBSD: log.c,v 1.24 2002/07/19 15:43:33 markus Exp $");
38 38
39#include "log.h" 39#include "log.h"
40#include "xmalloc.h" 40#include "xmalloc.h"
@@ -223,6 +223,18 @@ fatal_remove_cleanup(void (*proc) (void *context), void *context)
223 (u_long) proc, (u_long) context); 223 (u_long) proc, (u_long) context);
224} 224}
225 225
226/* Remove all cleanups, to be called after fork() */
227void
228fatal_remove_all_cleanups(void)
229{
230 struct fatal_cleanup *cu, *next_cu;
231
232 for (cu = fatal_cleanups; cu; cu = next_cu) {
233 next_cu = cu->next;
234 xfree(cu);
235 }
236}
237
226/* Cleanup and exit */ 238/* Cleanup and exit */
227void 239void
228fatal_cleanup(void) 240fatal_cleanup(void)
diff --git a/log.h b/log.h
index 3e4c3c3a7..917fafa69 100644
--- a/log.h
+++ b/log.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: log.h,v 1.7 2002/05/19 20:54:52 deraadt Exp $ */ 1/* $OpenBSD: log.h,v 1.8 2002/07/19 15:43:33 markus Exp $ */
2 2
3/* 3/*
4 * Author: Tatu Ylonen <ylo@cs.hut.fi> 4 * Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -64,6 +64,7 @@ void debug3(const char *, ...) __attribute__((format(printf, 1, 2)));
64void fatal_cleanup(void); 64void fatal_cleanup(void);
65void fatal_add_cleanup(void (*) (void *), void *); 65void fatal_add_cleanup(void (*) (void *), void *);
66void fatal_remove_cleanup(void (*) (void *), void *); 66void fatal_remove_cleanup(void (*) (void *), void *);
67void fatal_remove_all_cleanups(void);
67 68
68void do_log(LogLevel, const char *, va_list); 69void do_log(LogLevel, const char *, va_list);
69 70
diff --git a/session.c b/session.c
index 3c759e472..38388d43a 100644
--- a/session.c
+++ b/session.c
@@ -33,7 +33,7 @@
33 */ 33 */
34 34
35#include "includes.h" 35#include "includes.h"
36RCSID("$OpenBSD: session.c,v 1.143 2002/06/30 21:54:16 deraadt Exp $"); 36RCSID("$OpenBSD: session.c,v 1.144 2002/07/19 15:43:33 markus Exp $");
37 37
38#include "ssh.h" 38#include "ssh.h"
39#include "ssh1.h" 39#include "ssh1.h"
@@ -470,6 +470,8 @@ do_exec_no_pty(Session *s, const char *command)
470 470
471 /* Fork the child. */ 471 /* Fork the child. */
472 if ((pid = fork()) == 0) { 472 if ((pid = fork()) == 0) {
473 fatal_remove_all_cleanups();
474
473 /* Child. Reinitialize the log since the pid has changed. */ 475 /* Child. Reinitialize the log since the pid has changed. */
474 log_init(__progname, options.log_level, options.log_facility, log_stderr); 476 log_init(__progname, options.log_level, options.log_facility, log_stderr);
475 477
@@ -585,6 +587,7 @@ do_exec_pty(Session *s, const char *command)
585 587
586 /* Fork the child. */ 588 /* Fork the child. */
587 if ((pid = fork()) == 0) { 589 if ((pid = fork()) == 0) {
590 fatal_remove_all_cleanups();
588 591
589 /* Child. Reinitialize the log because the pid has changed. */ 592 /* Child. Reinitialize the log because the pid has changed. */
590 log_init(__progname, options.log_level, options.log_facility, log_stderr); 593 log_init(__progname, options.log_level, options.log_facility, log_stderr);
diff --git a/sshd.c b/sshd.c
index 8f9d3c392..427ca3545 100644
--- a/sshd.c
+++ b/sshd.c
@@ -42,7 +42,7 @@
42 */ 42 */
43 43
44#include "includes.h" 44#include "includes.h"
45RCSID("$OpenBSD: sshd.c,v 1.255 2002/06/30 21:59:45 deraadt Exp $"); 45RCSID("$OpenBSD: sshd.c,v 1.256 2002/07/19 15:43:33 markus Exp $");
46 46
47#include <openssl/dh.h> 47#include <openssl/dh.h>
48#include <openssl/bn.h> 48#include <openssl/bn.h>
@@ -303,9 +303,6 @@ grace_alarm_handler(int sig)
303{ 303{
304 /* XXX no idea how fix this signal handler */ 304 /* XXX no idea how fix this signal handler */
305 305
306 /* Close the connection. */
307 packet_close();
308
309 /* Log error and exit. */ 306 /* Log error and exit. */
310 fatal("Timeout before authentication for %s.", get_remote_ipaddr()); 307 fatal("Timeout before authentication for %s.", get_remote_ipaddr());
311} 308}
@@ -589,6 +586,8 @@ privsep_preauth(void)
589 if (pid == -1) { 586 if (pid == -1) {
590 fatal("fork of unprivileged child failed"); 587 fatal("fork of unprivileged child failed");
591 } else if (pid != 0) { 588 } else if (pid != 0) {
589 fatal_remove_cleanup((void (*) (void *)) packet_close, NULL);
590
592 debug2("Network child is on pid %ld", (long)pid); 591 debug2("Network child is on pid %ld", (long)pid);
593 592
594 close(pmonitor->m_recvfd); 593 close(pmonitor->m_recvfd);
@@ -602,6 +601,10 @@ privsep_preauth(void)
602 while (waitpid(pid, &status, 0) < 0) 601 while (waitpid(pid, &status, 0) < 0)
603 if (errno != EINTR) 602 if (errno != EINTR)
604 break; 603 break;
604
605 /* Reinstall, since the child has finished */
606 fatal_add_cleanup((void (*) (void *)) packet_close, NULL);
607
605 return (authctxt); 608 return (authctxt);
606 } else { 609 } else {
607 /* child */ 610 /* child */
@@ -649,6 +652,8 @@ privsep_postauth(Authctxt *authctxt)
649 if (pmonitor->m_pid == -1) 652 if (pmonitor->m_pid == -1)
650 fatal("fork of unprivileged child failed"); 653 fatal("fork of unprivileged child failed");
651 else if (pmonitor->m_pid != 0) { 654 else if (pmonitor->m_pid != 0) {
655 fatal_remove_cleanup((void (*) (void *)) packet_close, NULL);
656
652 debug2("User child is on pid %ld", (long)pmonitor->m_pid); 657 debug2("User child is on pid %ld", (long)pmonitor->m_pid);
653 close(pmonitor->m_recvfd); 658 close(pmonitor->m_recvfd);
654 monitor_child_postauth(pmonitor); 659 monitor_child_postauth(pmonitor);