Bug fix: line discipline selection is not enabled until after ssh
authorsimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Fri, 22 Sep 2000 13:10:19 +0000 (13:10 +0000)
committersimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Fri, 22 Sep 2000 13:10:19 +0000 (13:10 +0000)
authentication phase to stop user/password prompts behaving oddly

git-svn-id: svn://svn.tartarus.org/sgt/putty@614 cda61777-01e9-0310-a592-d414129be87e

plink.c
putty.h
raw.c
scp.c
ssh.c
telnet.c
window.c

diff --git a/plink.c b/plink.c
index fd9d36d..db48d54 100644 (file)
--- 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 8de3aff..5307c8a 100644 (file)
--- 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 dd0f64a..f7df52c 100644 (file)
--- 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 0b2a26c..7466e43 100644 (file)
--- 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 fddb68d..3cfab60 100644 (file)
--- 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;
index 75435c6..5e6ba3c 100644 (file)
--- 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;
 }
 
index b497123..be4b4e8 100644 (file)
--- 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;