]> andersk Git - openssh.git/commitdiff
- markus@cvs.openbsd.org 2002/07/19 15:43:33
authormouring <mouring>
Tue, 23 Jul 2002 21:01:56 +0000 (21:01 +0000)
committermouring <mouring>
Tue, 23 Jul 2002 21:01:56 +0000 (21:01 +0000)
     [log.c log.h session.c sshd.c]
     remove fatal cleanups after fork; based on discussions with and code
     from solar.

ChangeLog
log.c
log.h
session.c
sshd.c

index 16503db25acd9997f9ccfd1fe7405e8cba9319bc..55a4eb3c98d0e06d5d187e8ec30c039ec383ab34 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 20020723
  - (bal) [bsd-cray.c bsd-cray.h] Part 2 of Cray merger. 
+ - (bal) OpenBSD Sync
+   - markus@cvs.openbsd.org 2002/07/19 15:43:33
+     [log.c log.h session.c sshd.c]
+     remove fatal cleanups after fork; based on discussions with and code
+     from solar.
  
 20020722
  - (bal) AIX tty data limiting patch fix by leigh@solinno.co.uk
diff --git a/log.c b/log.c
index 8c09ec1b261c6823e277c331b60d48de93a56e6d..96626d7d4dab379a948b8d6ceb86a333f7246916 100644 (file)
--- a/log.c
+++ b/log.c
@@ -34,7 +34,7 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: log.c,v 1.23 2002/07/06 01:00:49 deraadt Exp $");
+RCSID("$OpenBSD: log.c,v 1.24 2002/07/19 15:43:33 markus Exp $");
 
 #include "log.h"
 #include "xmalloc.h"
@@ -223,6 +223,18 @@ fatal_remove_cleanup(void (*proc) (void *context), void *context)
            (u_long) proc, (u_long) context);
 }
 
+/* Remove all cleanups, to be called after fork() */
+void
+fatal_remove_all_cleanups(void)
+{
+       struct fatal_cleanup *cu, *next_cu;
+
+       for (cu = fatal_cleanups; cu; cu = next_cu) {
+               next_cu = cu->next;
+               xfree(cu);
+       }
+}
+
 /* Cleanup and exit */
 void
 fatal_cleanup(void)
diff --git a/log.h b/log.h
index 3e4c3c3a7064b510c277d35df000789d8164a752..917fafa69179b3f4b797c4f7b091fdd7b722f243 100644 (file)
--- a/log.h
+++ b/log.h
@@ -1,4 +1,4 @@
-/*     $OpenBSD: log.h,v 1.7 2002/05/19 20:54:52 deraadt Exp $ */
+/*     $OpenBSD: log.h,v 1.8 2002/07/19 15:43:33 markus Exp $  */
 
 /*
  * Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -64,6 +64,7 @@ void     debug3(const char *, ...) __attribute__((format(printf, 1, 2)));
 void     fatal_cleanup(void);
 void     fatal_add_cleanup(void (*) (void *), void *);
 void     fatal_remove_cleanup(void (*) (void *), void *);
+void     fatal_remove_all_cleanups(void);
 
 void    do_log(LogLevel, const char *, va_list);
 
index 3c759e4725c16a140a2698339480e9d515302e1e..38388d43af96b4685b70e1013ef162d6e9ca27a8 100644 (file)
--- a/session.c
+++ b/session.c
@@ -33,7 +33,7 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: session.c,v 1.143 2002/06/30 21:54:16 deraadt Exp $");
+RCSID("$OpenBSD: session.c,v 1.144 2002/07/19 15:43:33 markus Exp $");
 
 #include "ssh.h"
 #include "ssh1.h"
@@ -470,6 +470,8 @@ do_exec_no_pty(Session *s, const char *command)
 
        /* Fork the child. */
        if ((pid = fork()) == 0) {
+               fatal_remove_all_cleanups();
+
                /* Child.  Reinitialize the log since the pid has changed. */
                log_init(__progname, options.log_level, options.log_facility, log_stderr);
 
@@ -585,6 +587,7 @@ do_exec_pty(Session *s, const char *command)
 
        /* Fork the child. */
        if ((pid = fork()) == 0) {
+               fatal_remove_all_cleanups();
 
                /* Child.  Reinitialize the log because the pid has changed. */
                log_init(__progname, options.log_level, options.log_facility, log_stderr);
diff --git a/sshd.c b/sshd.c
index 8f9d3c3928448ee5c666be2dc84b0c5504c156cd..427ca35455b46cd76cbf0b28344a213eab16464b 100644 (file)
--- a/sshd.c
+++ b/sshd.c
@@ -42,7 +42,7 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: sshd.c,v 1.255 2002/06/30 21:59:45 deraadt Exp $");
+RCSID("$OpenBSD: sshd.c,v 1.256 2002/07/19 15:43:33 markus Exp $");
 
 #include <openssl/dh.h>
 #include <openssl/bn.h>
@@ -303,9 +303,6 @@ grace_alarm_handler(int sig)
 {
        /* XXX no idea how fix this signal handler */
 
-       /* Close the connection. */
-       packet_close();
-
        /* Log error and exit. */
        fatal("Timeout before authentication for %s.", get_remote_ipaddr());
 }
@@ -589,6 +586,8 @@ privsep_preauth(void)
        if (pid == -1) {
                fatal("fork of unprivileged child failed");
        } else if (pid != 0) {
+               fatal_remove_cleanup((void (*) (void *)) packet_close, NULL);
+
                debug2("Network child is on pid %ld", (long)pid);
 
                close(pmonitor->m_recvfd);
@@ -602,6 +601,10 @@ privsep_preauth(void)
                while (waitpid(pid, &status, 0) < 0)
                        if (errno != EINTR)
                                break;
+
+               /* Reinstall, since the child has finished */
+               fatal_add_cleanup((void (*) (void *)) packet_close, NULL);
+
                return (authctxt);
        } else {
                /* child */
@@ -649,6 +652,8 @@ privsep_postauth(Authctxt *authctxt)
        if (pmonitor->m_pid == -1)
                fatal("fork of unprivileged child failed");
        else if (pmonitor->m_pid != 0) {
+               fatal_remove_cleanup((void (*) (void *)) packet_close, NULL);
+
                debug2("User child is on pid %ld", (long)pmonitor->m_pid);
                close(pmonitor->m_recvfd);
                monitor_child_postauth(pmonitor);
This page took 0.068678 seconds and 5 git commands to generate.