summaryrefslogtreecommitdiff
path: root/sshpty.c
diff options
context:
space:
mode:
authorTim Rice <tim@multitalents.net>2002-05-13 17:07:18 -0700
committerTim Rice <tim@multitalents.net>2002-05-13 17:07:18 -0700
commit1e28c9e6bad1bd601606b6a6a3d6aa4ca441d21d (patch)
tree57a9a87316afb218a5a630bdd5174b24088ae34a /sshpty.c
parentf8defa2327a1ff265e7b4229e3adc97fc9f82594 (diff)
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 71c48b573..91de75939 100644
--- a/sshpty.c
+++ b/sshpty.c
@@ -199,6 +199,7 @@ pty_allocate(int *ptyfd, int *ttyfd, char *namebuf, int namebuflen)
199 const char *ptyminors = "0123456789abcdef"; 199 const char *ptyminors = "0123456789abcdef";
200 int num_minors = strlen(ptyminors); 200 int num_minors = strlen(ptyminors);
201 int num_ptys = strlen(ptymajors) * num_minors; 201 int num_ptys = strlen(ptymajors) * num_minors;
202 struct termios tio;
202 203
203 for (i = 0; i < num_ptys; i++) { 204 for (i = 0; i < num_ptys; i++) {
204 snprintf(buf, sizeof buf, "/dev/pty%c%c", ptymajors[i / num_minors], 205 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)
223 close(*ptyfd); 224 close(*ptyfd);
224 return 0; 225 return 0;
225 } 226 }
227 /* set tty modes to a sane state for broken clients */
228 if (tcgetattr(*ptyfd, &tio) < 0)
229 log("Getting tty modes for pty failed: %.100s", strerror(errno));
230 else {
231 tio.c_lflag |= (ECHO | ISIG | ICANON);
232 tio.c_oflag |= (OPOST | ONLCR);
233 tio.c_iflag |= ICRNL;
234
235 /* Set the new modes for the terminal. */
236 if (tcsetattr(*ptyfd, TCSANOW, &tio) < 0)
237 log("Setting tty modes for pty failed: %.100s", strerror(errno));
238 }
239
226 return 1; 240 return 1;
227 } 241 }
228 return 0; 242 return 0;