summaryrefslogtreecommitdiff
path: root/sshd.c
diff options
context:
space:
mode:
authorBen Lindstrom <mouring@eviladmin.org>2002-07-23 21:01:56 +0000
committerBen Lindstrom <mouring@eviladmin.org>2002-07-23 21:01:56 +0000
commit264ee307a8fd171dbb44121ec05b83f4143408cf (patch)
tree879766e789662f58ab0b8b7482126f743072e6c2 /sshd.c
parent6f52b3e39958dde417eacd9ca8fb513a3ea5b769 (diff)
- 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.
Diffstat (limited to 'sshd.c')
-rw-r--r--sshd.c13
1 files changed, 9 insertions, 4 deletions
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);