hang on exit

Markus Friedl markus at openbsd.org
Tue Feb 5 06:32:26 EST 2002


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;
 }
 



More information about the openssh-unix-dev mailing list