From: simon Date: Fri, 22 Sep 2000 13:10:19 +0000 (+0000) Subject: Bug fix: line discipline selection is not enabled until after ssh X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/commitdiff_plain/6f34e365eed04c1b4ebcf6d90511dd9e4400880a Bug fix: line discipline selection is not enabled until after ssh authentication phase to stop user/password prompts behaving oddly git-svn-id: svn://svn.tartarus.org/sgt/putty@614 cda61777-01e9-0310-a592-d414129be87e --- diff --git a/plink.c b/plink.c index fd9d36dd..db48d544 100644 --- a/plink.c +++ b/plink.c @@ -32,12 +32,19 @@ void connection_fatal (char *p, ...) { } HANDLE outhandle; +DWORD orig_console_mode; + +void begin_session(void) { + if (!cfg.ldisc_term) + SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), ENABLE_PROCESSED_INPUT); + else + SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), orig_console_mode); +} void term_out(void) { int reap; DWORD ret; - reap = 0; while (reap < inbuf_head) { if (!WriteFile(outhandle, inbuf+reap, inbuf_head-reap, &ret, NULL)) @@ -277,8 +284,8 @@ int main(int argc, char **argv) { netevent = CreateEvent(NULL, FALSE, FALSE, NULL); stdinevent = CreateEvent(NULL, FALSE, FALSE, NULL); - if (!cfg.ldisc_term) - SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), ENABLE_PROCESSED_INPUT); + GetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), &orig_console_mode); + SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), ENABLE_PROCESSED_INPUT); outhandle = GetStdHandle(STD_OUTPUT_HANDLE); /* diff --git a/putty.h b/putty.h index 8de3aff1..5307c8a1 100644 --- a/putty.h +++ b/putty.h @@ -244,6 +244,7 @@ void optimised_move (int, int, int); void connection_fatal(char *, ...); void fatalbox (char *, ...); void beep (int); +void begin_session(void); #define OPTIMISE_IS_SCROLL 1 /* diff --git a/raw.c b/raw.c index dd0f64a1..f7df52cb 100644 --- a/raw.c +++ b/raw.c @@ -131,6 +131,11 @@ static char *raw_init (HWND hwnd, char *host, int port, char **realhost) { default: return "WSAAsyncSelect(): unknown error"; } + /* + * We have no pre-session phase. + */ + begin_session(); + return NULL; } diff --git a/scp.c b/scp.c index 0b2a26c3..7466e433 100644 --- a/scp.c +++ b/scp.c @@ -68,12 +68,14 @@ static void send_str_msg(unsigned int msg_id, char *str); static void gui_update_stats(char *name, unsigned long size, int percentage, time_t elapsed); /* - * This function is needed to link with ssh.c, but it never gets called. + * These functions are needed to link with ssh.c, but never get called. */ void term_out(void) { abort(); } +void begin_session(void) { +} /* GUI Adaptation - Sept 2000 */ void send_msg(HWND h, UINT message, WPARAM wParam) diff --git a/ssh.c b/ssh.c index fddb68d1..3cfab606 100644 --- a/ssh.c +++ b/ssh.c @@ -1628,6 +1628,7 @@ static void ssh1_protocol(unsigned char *in, int inlen, int ispkt) { ssh_send_ok = 1; ssh_channels = newtree234(ssh_channelcmp); + begin_session(); while (1) { crReturnV; if (ispkt) { @@ -2335,6 +2336,7 @@ static void do_ssh2_authconn(unsigned char *in, int inlen, int ispkt) * Transfer data! */ ssh_send_ok = 1; + begin_session(); while (1) { static int try_send; crReturnV; diff --git a/telnet.c b/telnet.c index 75435c6f..5e6ba3c2 100644 --- a/telnet.c +++ b/telnet.c @@ -583,6 +583,12 @@ static char *telnet_init (HWND hwnd, char *host, int port, char **realhost) { * Set up SYNCH state. */ in_synch = FALSE; + + /* + * We have no pre-session phase. + */ + begin_session(); + return NULL; } diff --git a/window.c b/window.c index b4971232..be4b4e8d 100644 --- a/window.c +++ b/window.c @@ -82,6 +82,12 @@ static Mouse_Button lastbtn; static char *window_name, *icon_name; +static Ldisc *real_ldisc; + +void begin_session(void) { + ldisc = real_ldisc; +} + int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) { static char appname[] = "PuTTY"; WORD winsock_ver; @@ -239,7 +245,10 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) { } } - ldisc = (cfg.ldisc_term ? &ldisc_term : &ldisc_simple); + real_ldisc = (cfg.ldisc_term ? &ldisc_term : &ldisc_simple); + /* To start with, we use the simple line discipline, so we can + * type passwords etc without fear of them being echoed... */ + ldisc = &ldisc_simple; if (!prev) { wndclass.style = 0;