[PATCH]: Patch to fix hang on exit bug under Linux and add optional exit delay

Ed Phillips ed at UDel.Edu
Fri Nov 16 02:38:27 EST 2001


On Thu, 15 Nov 2001, Markus Friedl wrote:

> Date: Thu, 15 Nov 2001 11:14:24 +0100
> From: Markus Friedl <markus at openbsd.org>
> To: Andreas Hasenack <andreas at conectiva.com.br>
> Cc: pcpa at conectiva.com.br, openssh-unix-dev at mindrot.org, openssh at openbsd.org
> Subject: Re: [PATCH]: Patch to fix hang on exit bug under Linux and add
>     optional exit delay
>
> On Wed, Nov 14, 2001 at 02:20:17PM -0200, Andreas Hasenack wrote:
> > diff -u openssh-2.9p1/clientloop.c openssh/clientloop.c
> > --- openssh-2.9p1/clientloop.c	Fri Apr 20 09:50:51 2001
> > +++ openssh/clientloop.c	Mon May  7 17:10:52 2001
> > @@ -840,8 +840,11 @@
> >  		/* Process buffered packets sent by the server. */
> >  		client_process_buffered_input_packets();
> >
> > -		if (compat20 && session_closed && !channel_still_open())
> > +		if (compat20 && session_closed) {
> > +			if (channel_still_open())
> > +				channel_stop_listening();
> >  			break;
> > +		}
>
> i guess this patch is for disabling listen() for local forwarding
> after the login session has been closed.
>
> i think this matches the protocol 1 behaviour, but i have to
> do some more tests.
>
> >  		rekeying = (xxx_kex != NULL && !xxx_kex->done);
> >
> > @@ -1186,6 +1189,7 @@
> >  	} else if (strcmp(rtype, "exit-status") == 0) {
> >  		success = 1;
> >  		exit_status = packet_get_int();
> > +		session_closed = 1;
>
> well, it's possible to send data after the exit-status, so
> i'm still not quite sure.
>
> the only 'fix' for the so called hang-on-exit would be:

Only fix?

> allow data loss in the server if a pty is allocated. i think
> this would match the telnetd and rlogind behaviour best.
> but i'm not 100% sure, people should test their telnetd/rlogind
> servers and check that they throw away data after the login
> shell dies. but once again: openssh is not telnet.

I'm still not understanding why sshd can't figure out when to close the
socket that connects back to the client... is this just the open-ended
design of the V2 protocol?  Just because there are no sshd children left
running and no file desriptors left to process, sshd still needs to stay
running?

	Ed

Ed Phillips <ed at udel.edu> University of Delaware (302) 831-6082
Systems Programmer III, Network and Systems Services
finger -l ed at polycut.nss.udel.edu for PGP public key




More information about the openssh-unix-dev mailing list