sshd sets ssh client tty mode to original state after a tty session has ended

this is a needed step for our sshd in tty mode as we ask clients to send
us CRLF as command terminator. But we must reset the mode when the tty
session ends so that sftp running after it does not encounter CRLF mode.
Linux openssh sftp client otherwise would show two lines for each
command typed when run after an ssh session to our server.
This commit is contained in:
quamrulmina 2015-11-19 00:35:59 -06:00
parent 5b34ab66d8
commit cbdfedff94
2 changed files with 17 additions and 8 deletions

18
nchan.c
View File

@ -187,8 +187,24 @@ chan_ibuf_empty(Channel *c)
switch (c->istate) { switch (c->istate) {
case CHAN_INPUT_WAIT_DRAIN: case CHAN_INPUT_WAIT_DRAIN:
if (compat20) { if (compat20) {
if (!(c->flags & (CHAN_CLOSE_SENT|CHAN_LOCAL))) if (!(c->flags & (CHAN_CLOSE_SENT | CHAN_LOCAL))) {
#ifdef WIN32_FIXME
// reset the other side if tty to be how it was before
if (c->isatty) {
char *inittermseq =
"\033[?7h" // end-of-line autowrap ON mode
"\033[20l"; // force NewLineMode off
buffer_append(&c->input, inittermseq, strlen(inittermseq));
int state = c->istate;
c->istate = CHAN_INPUT_WAIT_DRAIN;
channel_output_poll();
packet_write_poll(); // packet_write_wait();
c->istate = state;
}
#endif
chan_send_eof2(c); chan_send_eof2(c);
}
chan_set_istate(c, CHAN_INPUT_CLOSED); chan_set_istate(c, CHAN_INPUT_CLOSED);
} else { } else {
chan_send_ieof1(c); chan_send_ieof1(c);

View File

@ -880,13 +880,6 @@ collect_children(void)
process = s->pid; process = s->pid;
// send the other side terminal to be how it was before if it was tty
if ( (!s -> is_subsystem) && (s ->ttyfd != -1)) {
char *inittermseq = "\033[20l\033[?7h\0" ; // no LFtoCRLF no AUTOWRAPON
Channel *c=channel_by_id ( s->chanid );
buffer_append(&c->input, inittermseq, strlen(inittermseq));
packet_write_poll();
}
session_close_by_pid(s->pid, status); session_close_by_pid(s->pid, status);
if (s->pid) if (s->pid)