summaryrefslogtreecommitdiff
path: root/sshpty.c
diff options
context:
space:
mode:
authortim <tim>2002-05-14 00:07:18 +0000
committertim <tim>2002-05-14 00:07:18 +0000
commit83a8de1c175a27d79c7b766320a2b4255c35b11c (patch)
tree75b52a3ec276d2ce6b568ad93ea49ec1b000fbde /sshpty.c
parent0215c4506c678fd4702ea814a05f1c9fef36b22e (diff)
downloadopenssh-83a8de1c175a27d79c7b766320a2b4255c35b11c.tar.gz
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 <rac@tenzing.org> [README.privsep] UnixWare 7 and OpenUNIX 8 work.
Diffstat (limited to 'sshpty.c')
-rw-r--r--sshpty.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/sshpty.c b/sshpty.c
index 71c48b57..91de7593 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;