diff svr-session.c @ 553:8711f20b89ab

- For uclinux, only cleanup on exit for the main process. This avoids trashing the state when a failing child exits.
author Matt Johnston <matt@ucc.asn.au>
date Thu, 09 Jul 2009 16:01:30 +0000
parents 9f583f4d59a6
children 005530560594
line wrap: on
line diff
--- a/svr-session.c	Tue Jun 16 15:22:33 2009 +0000
+++ b/svr-session.c	Thu Jul 09 16:01:30 2009 +0000
@@ -85,6 +85,10 @@
 	/* Initialise server specific parts of the session */
 	svr_ses.childpipe = childpipe;
 	svr_ses.addrstring = addrstring;
+#ifdef __uClinux__
+	svr_ses.server_pid = getpid();
+#endif
+	svr_ses.addrstring = addrstring;
 	svr_authinitialise();
 	chaninitialise(svr_chantypes);
 	svr_chansessinitialise();
@@ -144,11 +148,20 @@
 
 	_dropbear_log(LOG_INFO, fmtbuf, param);
 
-	/* free potential public key options */
-	svr_pubkey_options_cleanup();
+#ifdef __uClinux__
+	/* only the main server process should cleanup - we don't want
+	 * forked children doing that */
+	if (svr_ses.server_pid == getpid())
+#else
+	if (1)
+#endif
+	{
+		/* free potential public key options */
+		svr_pubkey_options_cleanup();
 
-	/* must be after we've done with username etc */
-	common_session_cleanup();
+		/* must be after we've done with username etc */
+		common_session_cleanup();
+	}
 
 	exit(exitcode);