patch to sshpty.c

Tim Rice tim at multitalents.net
Fri May 10 13:40:49 EST 2002


On Thu, 9 May 2002, Ben Lindstrom wrote:

>
> Is this patch required for all platforms or just SCO? If it is just for
> SCO then why is not stated as such.. If it is more a universal issue then
> do you plan on submitting it back to Markus when we open up the main tree?

I suspect it's a universal issue on BSD-style pty's, but I'm not sure.
That's why I sent it to the list.
The only platform I have here that uses the BSD-style pty is SCO.
It's highly unlikely that it would break the others.

I'd be interested in feedback from anyone that has a platform (other than SCO)
that uses BSD-style ptys.
Ie. running  egrep "PTY|DEV" config.h produces
/* #undef HAVE_DEV_PTMX */
/* #undef HAVE_DEV_PTS_AND_PTC */
/* #undef HAVE_OPENPTY */
/* #undef HAVE_PTY_H */
/* #undef HAVE__GETPTY */


>
> I'd like to see us move some of the more 'Must have for X platform'
> out into openbsd-contrib/port-*.c because the diff is getting too large
> and too unwielding to audit.
>
> - Ben
>
The patch again
-------------------< cut > -----------------
--- sshpty.c.old	Tue Jan 15 17:06:39 2002
+++ sshpty.c	Thu May  9 12:19:06 2002
@@ -199,6 +199,7 @@
 	const char *ptyminors = "0123456789abcdef";
 	int num_minors = strlen(ptyminors);
 	int num_ptys = strlen(ptymajors) * num_minors;
+	struct termios tio;

 	for (i = 0; i < num_ptys; i++) {
 		snprintf(buf, sizeof buf, "/dev/pty%c%c", ptymajors[i / num_minors],
@@ -223,6 +224,19 @@
 			close(*ptyfd);
 			return 0;
 		}
+		/* set tty modes to a sane state for broken clients */
+		if (tcgetattr(*ptyfd, &tio) < 0)
+			log("Getting tty modes for pty failed: %.100s", strerror(errno));
+		else {
+			tio.c_lflag |= (ECHO | ISIG | ICANON);
+			tio.c_oflag |= (OPOST | ONLCR);
+			tio.c_iflag |= ICRNL;
+
+			/* Set the new modes for the terminal. */
+			if (tcsetattr(*ptyfd, TCSANOW, &tio) < 0)
+				log("Setting tty modes for pty failed: %.100s", strerror(errno));
+		}
+
 		return 1;
 	}
 	return 0;
-----------------< end cut > -----------------

-- 
Tim Rice				Multitalents	(707) 887-1469
tim at multitalents.net








More information about the openssh-unix-dev mailing list