openssh PTY allocation

Damien Miller djm at mindrot.org
Sat Aug 6 14:26:09 EST 2011


FYI here is a diff that installs workarounds for all of the problems
with ScreenOS that I'm aware of. These are:

  - PTY allocation
  - scp -- thing
  - keepalives killing the connection
  - multiplexing requests killing the connection

Not sure whether I want to commit these. 

Index: clientloop.c
===================================================================
RCS file: /cvs/src/usr.bin/ssh/clientloop.c,v
retrieving revision 1.236
diff -u -p -r1.236 clientloop.c
--- clientloop.c	22 Jun 2011 22:08:42 -0000	1.236
+++ clientloop.c	6 Aug 2011 04:21:42 -0000
@@ -1375,7 +1375,11 @@ client_loop(int have_pty, int escape_cha
 	char buf[100];
 
 	debug("Entering interactive session.");
-
+	if ((datafellows & SSH_BUG_KEEPALIVE) != 0 &&
+	    options.server_alive_interval != 0) {
+		debug2("Disabling keepalives due to server bug");
+		options.server_alive_interval = 0;
+	}
 	start_time = get_current_time();
 
 	/* Initialize variables. */
Index: compat.c
===================================================================
RCS file: /cvs/src/usr.bin/ssh/compat.c,v
retrieving revision 1.78
diff -u -p -r1.78 compat.c
--- compat.c	11 Sep 2008 14:22:37 -0000	1.78
+++ compat.c	6 Aug 2011 04:21:42 -0000
@@ -146,6 +146,10 @@ compat_datafellows(const char *version)
 					SSH_BUG_IGNOREMSG },
 		{ "*SSH Compatible Server*",			/* Netscreen */
 					SSH_BUG_PASSWORDPAD },
+		{ "NetScreen",
+					SSH_BUG_SCREENOS_PTY|
+					SSH_BUG_KEEPALIVE|
+					SSH_BUG_MULTIPLEX },
 		{ "*OSU_0*,"
 		  "OSU_1.0*,"
 		  "OSU_1.1*,"
Index: compat.h
===================================================================
RCS file: /cvs/src/usr.bin/ssh/compat.h,v
retrieving revision 1.42
diff -u -p -r1.42 compat.h
--- compat.h	11 Sep 2008 14:22:37 -0000	1.42
+++ compat.h	6 Aug 2011 04:21:42 -0000
@@ -58,6 +58,9 @@
 #define SSH_OLD_FORWARD_ADDR	0x01000000
 #define SSH_BUG_RFWD_ADDR	0x02000000
 #define SSH_NEW_OPENSSH		0x04000000
+#define SSH_BUG_SCREENOS_PTY	0x08000000
+#define SSH_BUG_KEEPALIVE	0x10000000
+#define SSH_BUG_MULTIPLEX	0x20000000
 
 void     enable_compat13(void);
 void     enable_compat20(void);
Index: scp.c
===================================================================
RCS file: /cvs/src/usr.bin/ssh/scp.c,v
retrieving revision 1.170
diff -u -p -r1.170 scp.c
--- scp.c	9 Dec 2010 14:13:33 -0000	1.170
+++ scp.c	6 Aug 2011 04:21:42 -0000
@@ -580,12 +580,14 @@ toremote(char *targ, int argc, char **ar
 				host = cleanhostname(argv[i]);
 				suser = NULL;
 			}
-			xasprintf(&bp, "%s -f -- %s", cmd, src);
+			xasprintf(&bp, "%s -f %s%s", cmd,
+			    *src == '-' ? "-- " : "", src);
 			if (do_cmd(host, suser, bp, &remin, &remout) < 0)
 				exit(1);
 			(void) xfree(bp);
 			host = cleanhostname(thost);
-			xasprintf(&bp, "%s -t -- %s", cmd, targ);
+			xasprintf(&bp, "%s -t %s%s", cmd,
+			    *targ == '-' ? "-- " : "", targ);
 			if (do_cmd2(host, tuser, bp, remin, remout) < 0)
 				exit(1);
 			(void) xfree(bp);
@@ -631,7 +633,8 @@ toremote(char *targ, int argc, char **ar
 				errs = 1;
 		} else {	/* local to remote */
 			if (remin == -1) {
-				xasprintf(&bp, "%s -t -- %s", cmd, targ);
+				xasprintf(&bp, "%s -t %s%s", cmd,
+				    *targ == '-' ? "-- " : "", targ);
 				host = cleanhostname(thost);
 				if (do_cmd(host, tuser, bp, &remin,
 				    &remout) < 0)
Index: serverloop.c
===================================================================
RCS file: /cvs/src/usr.bin/ssh/serverloop.c,v
retrieving revision 1.160
diff -u -p -r1.160 serverloop.c
--- serverloop.c	15 May 2011 08:09:01 -0000	1.160
+++ serverloop.c	6 Aug 2011 04:21:42 -0000
@@ -277,6 +277,11 @@ wait_until_can_do_something(fd_set **rea
 	int ret;
 	int client_alive_scheduled = 0;
 
+	if ((datafellows & SSH_BUG_KEEPALIVE) != 0 &&
+	    options.client_alive_interval != 0) {
+		debug2("Disabling keepalives due to client bug");
+		options.client_alive_interval = 0;
+	}
 	/*
 	 * if using client_alive, set the max timeout accordingly,
 	 * and indicate that this particular timeout was for client
Index: ssh.c
===================================================================
RCS file: /cvs/src/usr.bin/ssh/ssh.c,v
retrieving revision 1.364
diff -u -p -r1.364 ssh.c
--- ssh.c	2 Aug 2011 23:15:03 -0000	1.364
+++ ssh.c	6 Aug 2011 04:21:42 -0000
@@ -890,6 +890,13 @@ main(int ac, char **av)
 		}
 	}
 
+	if ((datafellows & SSH_BUG_MULTIPLEX) != 0 &&
+	    options.control_path != NULL &&
+	    options.control_master != SSHCTL_MASTER_NO) {
+		debug("Disabling multiplexing due to server bugs");
+		options.control_master = SSHCTL_MASTER_NO;
+	}
+
 	exit_status = compat20 ? ssh_session2() : ssh_session();
 	packet_close();
 
Index: ttymodes.c
===================================================================
RCS file: /cvs/src/usr.bin/ssh/ttymodes.c,v
retrieving revision 1.29
diff -u -p -r1.29 ttymodes.c
--- ttymodes.c	2 Nov 2008 00:16:16 -0000	1.29
+++ ttymodes.c	6 Aug 2011 04:21:42 -0000
@@ -295,8 +295,11 @@ tty_make_modes(int fd, struct termios *t
 	put_arg(&buf, tio.c_cc[NAME]);
 
 #define TTYMODE(NAME, FIELD, OP) \
-	buffer_put_char(&buf, OP); \
-	put_arg(&buf, ((tio.FIELD & NAME) != 0));
+	if (!compat20 || (datafellows & SSH_BUG_SCREENOS_PTY) == 0 || \
+	    buffer_len(&buf) < 256 - 5) { \
+		buffer_put_char(&buf, OP); \
+		put_arg(&buf, ((tio.FIELD & NAME) != 0)); \
+	}
 
 #include "ttymodes.h"
 


More information about the openssh-unix-dev mailing list