hang on exit

Nicolas Williams Nicolas.Williams at ubsw.com
Tue Feb 5 07:04:51 EST 2002


Woa!

What's up with this? Why a server-side patch? I thought we'd all agreed
that this needs to be a client-side decision. After all, the client
knows when the session exits and can choose what to do.

I just posted a function which has code to force a channel closed. That
has to be possible in order to provide some of the hang-on-exit options
that have been discussed here. I used chan_read_failed() and
chan_write_failed() and channel_close_fds(). I see that you're using
chan_read_failed() here, so, can I conclude that that is the right
approach to forcing channel closures?

Nico


On Mon, Feb 04, 2002 at 08:32:26PM +0100, Markus Friedl wrote:
> untested, as i don't have access to a system that
> shows the hang-on-exit problem.
> 
> Index: servconf.c
> ===================================================================
> RCS file: /cvs/openssh_cvs/servconf.c,v
> retrieving revision 1.74
> diff -u -r1.74 servconf.c
> --- servconf.c	22 Jan 2002 12:35:12 -0000	1.74
> +++ servconf.c	4 Feb 2002 15:46:05 -0000
> @@ -91,6 +91,7 @@
>  	options->permit_empty_passwd = -1;
>  	options->use_login = -1;
>  	options->allow_tcp_forwarding = -1;
> +	options->allow_data_loss_on_pty = -1;
>  	options->num_allow_users = 0;
>  	options->num_deny_users = 0;
>  	options->num_allow_groups = 0;
> @@ -209,6 +210,8 @@
>  		options->use_login = 0;
>  	if (options->allow_tcp_forwarding == -1)
>  		options->allow_tcp_forwarding = 1;
> +	if (options->allow_data_loss_on_pty == -1)
> +		options->allow_data_loss_on_pty = 0;
>  	if (options->gateway_ports == -1)
>  		options->gateway_ports = 0;
>  	if (options->max_startups == -1)
> @@ -257,7 +260,7 @@
>  	sPrintMotd, sPrintLastLog, sIgnoreRhosts,
>  	sX11Forwarding, sX11DisplayOffset,
>  	sStrictModes, sEmptyPasswd, sKeepAlives,
> -	sUseLogin, sAllowTcpForwarding,
> +	sUseLogin, sAllowTcpForwarding, sAllowDataLossOnPty
>  	sAllowUsers, sDenyUsers, sAllowGroups, sDenyGroups,
>  	sIgnoreUserKnownHosts, sCiphers, sMacs, sProtocol, sPidFile,
>  	sGatewayPorts, sPubkeyAuthentication, sXAuthLocation, sSubsystem, sMaxStartups,
> @@ -321,6 +324,7 @@
>  	{ "uselogin", sUseLogin },
>  	{ "keepalive", sKeepAlives },
>  	{ "allowtcpforwarding", sAllowTcpForwarding },
> +	{ "allowdatalossonpty", sAllowDataLossOnPty },
>  	{ "allowusers", sAllowUsers },
>  	{ "denyusers", sDenyUsers },
>  	{ "allowgroups", sAllowGroups },
> @@ -707,6 +711,10 @@
>  
>  	case sAllowTcpForwarding:
>  		intptr = &options->allow_tcp_forwarding;
> +		goto parse_flag;
> +
> +	case sAllowDataLossOnPty:
> +		intptr = &options->allow_data_loss_on_pty;
>  		goto parse_flag;
>  
>  	case sAllowUsers:
> Index: servconf.h
> ===================================================================
> RCS file: /cvs/openssh_cvs/servconf.h,v
> retrieving revision 1.42
> diff -u -r1.42 servconf.h
> --- servconf.h	21 Dec 2001 03:45:49 -0000	1.42
> +++ servconf.h	4 Feb 2002 15:46:05 -0000
> @@ -98,6 +98,7 @@
>  					 * passwords. */
>  	int     use_login;	/* If true, login(1) is used */
>  	int	allow_tcp_forwarding;
> +	int	allow_data_loss_on_pty;
>  	u_int num_allow_users;
>  	char   *allow_users[MAX_ALLOW_USERS];
>  	u_int num_deny_users;
> Index: serverloop.c
> ===================================================================
> RCS file: /cvs/openssh_cvs/serverloop.c,v
> retrieving revision 1.94
> diff -u -r1.94 serverloop.c
> --- serverloop.c	22 Jan 2002 12:29:23 -0000	1.94
> +++ serverloop.c	4 Feb 2002 15:46:06 -0000
> @@ -391,6 +391,11 @@
>  			buffer_append(&stderr_buffer, buf, len);
>  		}
>  	}
> +	if (child_terminated && options.allow_data_loss_on_pty == 1 &&
> +	    fderr == -1 && !fdout_eof) {
> +		close(fdout);
> +		fdout_eof = 1;
> +	}
>  }
>  
>  /*
> Index: session.c
> ===================================================================
> RCS file: /cvs/openssh_cvs/session.c,v
> retrieving revision 1.166
> diff -u -r1.166 session.c
> --- session.c	22 Jan 2002 12:16:34 -0000	1.166
> +++ session.c	4 Feb 2002 15:46:06 -0000
> @@ -1892,6 +1892,9 @@
>  	 */
>  	if (c->ostate != CHAN_OUTPUT_CLOSED)
>  		chan_write_failed(c);
> +	if (s->ttyfd != -1 && c->istate == CHAN_INPUT_OPEN &&
> +	    options.allow_data_loss_on_pty == 1)
> +		chan_read_failed(c);
>  	s->chanid = -1;
>  }
>  
> _______________________________________________
> openssh-unix-dev at mindrot.org mailing list
> http://www.mindrot.org/mailman/listinfo/openssh-unix-dev
-- 
-DISCLAIMER: an automatically appended disclaimer may follow. By posting-
-to a public e-mail mailing list I hereby grant permission to distribute-
-and copy this message.-

Visit our website at http://www.ubswarburg.com

This message contains confidential information and is intended only 
for the individual named.  If you are not the named addressee you 
should not disseminate, distribute or copy this e-mail.  Please 
notify the sender immediately by e-mail if you have received this 
e-mail by mistake and delete this e-mail from your system.

E-mail transmission cannot be guaranteed to be secure or error-free 
as information could be intercepted, corrupted, lost, destroyed, 
arrive late or incomplete, or contain viruses.  The sender therefore 
does not accept liability for any errors or omissions in the contents 
of this message which arise as a result of e-mail transmission.  If 
verification is required please request a hard-copy version.  This 
message is provided for informational purposes and should not be 
construed as a solicitation or offer to buy or sell any securities or 
related financial instruments.




More information about the openssh-unix-dev mailing list