# HG changeset patch # User Matt Johnston # Date 1247155290 0 # Node ID 8711f20b89aba896ec52d6eec6b40916db7e86cb # Parent 00e619aa2f9ad098074919d3164d64f2d4f3f617 - For uclinux, only cleanup on exit for the main process. This avoids trashing the state when a failing child exits. diff -r 00e619aa2f9a -r 8711f20b89ab session.h --- a/session.h Tue Jun 16 15:22:33 2009 +0000 +++ b/session.h Thu Jul 09 16:01:30 2009 +0000 @@ -213,6 +213,10 @@ /* The numeric address they connected from, used for logging */ char * addrstring; +#ifdef __uClinux__ + pid_t server_pid; +#endif + }; typedef enum { diff -r 00e619aa2f9a -r 8711f20b89ab svr-session.c --- 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);