SSH connection hanging on logout

Markus Friedl markus.friedl at informatik.uni-erlangen.de
Thu May 17 07:46:46 EST 2001


On Wed, May 16, 2001 at 08:18:03AM -0000, John Bowman wrote:
> The following is a CORRECTION, with a REVISED PATCH, to my message posted
> to this list on 2001-05-15 2:55:37.
> 
> Here is a new version of the hang-on-exit patch (2001-05-08 23:52:24), which:
> 
> 1. fixes the hang-on-exit bug under Protocol 2 (without data loss);
> 2. does not exit if there are unterminated X applications;
> 3. exits the session when all X applications have closed.
> 
> Of these three tests, Openssh-2.9p1 under Protocol 2 passes only the second 
> one. The third item is another type of hanging bug in Openssh, as is
> demonstrated by the following test:
> 
> ssh -2 host
> xterm -e sleep 20 &
> exit
> 
> Even after the xsession terminates, the ssh session is left hanging forever.
> The correct behaviour is to wait 20 seconds for the X application to close
> and then exit.
> 
> -- John Bowman
> 
> University of Alberta
> http://www.math.ualberta.ca/~bowman
> 
> P.S. Since the hang-on-exit patch is only effective under Protocol 2,
> a conditional to the call to chan_shutdown_read() has been added.
> 
>  
> 
> diff -ur openssh-2.9p1/channels.c openssh-2.9p1J/channels.c
> --- openssh-2.9p1/channels.c	Tue Apr 17 12:14:35 2001
> +++ openssh-2.9p1J/channels.c	Wed May 16 01:22:16 2001
> @@ -333,6 +333,9 @@
>  		xfree(c->remote_name);
>  		c->remote_name = NULL;
>  	}
> +
> +	if(channel_find_open() == -1)
> +		shutdown(packet_get_connection_out(), SHUT_RDWR);
>  			continue;

> +			if(channel_find_open() == -1)
> +			  	shutdown(packet_get_connection_out(),
> +					 SHUT_RDWR);

imho, this is wrong. you are not allowed to shutdown the TCP
connection to the peer. the peer can still request a second shell
sessions.



More information about the openssh-unix-dev mailing list