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
*/
#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"
(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)
-/* $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>
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);
*/
#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"
/* 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);
/* 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);
*/
#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>
{
/* 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());
}
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);
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 */
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);