openssh PTY allocation

Damien Miller djm at mindrot.org
Tue Aug 9 16:17:05 EST 2011


On Mon, 8 Aug 2011, Morty Abzug wrote:

> On Sat, Aug 06, 2011 at 02:26:09PM +1000, Damien Miller wrote:
> > 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
> 
> Thanks for the patch.  In my testing, it has the following issues:
> 
> (1) ssh still doesn't work for some of our devices.  I think this is
> because the ttymodes.c portion of your patch has "256" when it should
> be "128".

Even if I do commit something like this diff (which is not guaranteed),
it certainly won't truncate the ttymodes at 128 bytes - fixed versions
of ScreenOS already exist for this problem and chopping so much off is
likely to leave a messed up TTY anyway.

> (2) scp didn't actually work to any of my test netscreens for scp
> $device:ns_sys_config /tmp.  I tried scp -v $device:ns_sys_config /tmp
> to see what the command was.  I got:
> 
> debug1: Sending command: scp -v -f -- ns_sys_config
> 
> As you can see, "--" is still there.

oops, I missed a case:

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	9 Aug 2011 06:10:08 -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)
@@ -664,7 +667,8 @@ tolocal(int argc, char **argv)
 				addargs(&alist, "-r");
 			if (pflag)
 				addargs(&alist, "-p");
-			addargs(&alist, "--");
+			if (*(argv[i]) == '-' || *(argv[argc-1]) == '-')
+				addargs(&alist, "--");
 			addargs(&alist, "%s", argv[i]);
 			addargs(&alist, "%s", argv[argc-1]);
 			if (do_local_cmd(&alist))
@@ -684,7 +688,8 @@ tolocal(int argc, char **argv)
 				suser = pwd->pw_name;
 		}
 		host = cleanhostname(host);
-		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) {
 			(void) xfree(bp);
 			++errs;


More information about the openssh-unix-dev mailing list