summaryrefslogtreecommitdiff
path: root/sshpty.c
diff options
context:
space:
mode:
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;