From 1e28c9e6bad1bd601606b6a6a3d6aa4ca441d21d Mon Sep 17 00:00:00 2001 From: Tim Rice Date: Mon, 13 May 2002 17:07:18 -0700 Subject: 20020514 [sshpty.c] set tty modes when allocating old style bsd ptys to match what newer style ptys have when allocated. Based on a patch by Roger Cornelius [README.privsep] UnixWare 7 and OpenUNIX 8 work. --- sshpty.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'sshpty.c') diff --git a/sshpty.c b/sshpty.c index 71c48b573..91de75939 100644 --- a/sshpty.c +++ b/sshpty.c @@ -199,6 +199,7 @@ pty_allocate(int *ptyfd, int *ttyfd, char *namebuf, int namebuflen) 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 @@ pty_allocate(int *ptyfd, int *ttyfd, char *namebuf, int namebuflen) 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; -- cgit v1.2.3