sys_bsd.c(intr): Added checks to intr_waiting and intr_happened to
authorTheodore Tso <tytso@mit.edu>
Thu, 14 Nov 1996 19:53:33 +0000 (19:53 +0000)
committerTheodore Tso <tytso@mit.edu>
Thu, 14 Nov 1996 19:53:33 +0000 (19:53 +0000)
handle ^C while waiting for encryption negotiation.

telnet.c (telnet): Allow ^C to work while waiting for encryption
negotiation to finish. [telnet/64]

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@9414 dc483132-0cff-0310-8789-dd5450dbe970

src/appl/telnet/telnet/ChangeLog
src/appl/telnet/telnet/externs.h
src/appl/telnet/telnet/sys_bsd.c
src/appl/telnet/telnet/telnet.c

index 2a1a0c6ddffca590020b83b775838e23036e2f28..8080dba471468d3c85cf84f984cf35f9ef5f0d4b 100644 (file)
@@ -1,3 +1,11 @@
+Thu Nov 14 14:25:51 1996  Theodore Ts'o  <tytso@rsts-11.mit.edu>
+
+       * sys_bsd.c(intr): Added checks to intr_waiting and intr_happened
+               to handle ^C while waiting for encryption negotiation.
+
+       * telnet.c (telnet): Allow ^C to work while waiting for encryption
+               negotiation to finish. [telnet/64]
+
 Sun Nov 10 17:34:40 1996  Sam Hartman  <hartmans@mit.edu>
 
        * commands.c (tn): Reverse resolve address to deal with dialup
index 40f5e493562827f9af345220fc4dc3c4328b9b9b..c09527f6da6e1de6dd6c62c8d404dc0b558b2289 100644 (file)
@@ -157,6 +157,8 @@ extern int
     termdata,          /* Print out terminal data flow */
     debug;                     /* Debug level */
 
+extern int intr_happened, intr_waiting;        /* for interrupt handling */
+
 extern cc_t escape;    /* Escape to command mode */
 extern cc_t rlogin;    /* Rlogin mode escape character */
 #ifdef KLUDGELINEMODE
index dbbb9078e5eac5100bad07bb9908eff7d2cee655..90ea810c19dc2b9dac26cf74f2d1ef57a7863f6e 100644 (file)
@@ -855,11 +855,18 @@ deadpeer(sig)
        longjmp(peerdied, -1);
 }
 
+int intr_happened = 0;
+int intr_waiting = 0;
+
     /* ARGSUSED */
     SIG_FUNC_RET
 intr(sig)
     int sig;
 {
+    if (intr_waiting) {
+       intr_happened = 1;
+       return;
+    }
     if (localchars) {
        intp();
        return;
index e89f50629a2e58960569121c94efd99d37d7f0f8..2ef24320edf3f5c3208ca6e46efc8d481c9ffca6 100644 (file)
@@ -2254,6 +2254,8 @@ Scheduler(block)
 telnet(user)
     char *user;
 {
+    int printed_encrypt = 0;
+    
     sys_telnet_init();
 
 #if    defined(AUTHENTICATION) || defined(ENCRYPTION) 
@@ -2310,28 +2312,47 @@ telnet(user)
        send_will(TELOPT_ENCRYPT, 1);
        while (1) {
            if (my_want_state_is_wont(TELOPT_AUTHENTICATION)) {
-               printf("Server refused to negotiation authentication, which is required\n");
+               printf("\nServer refused to negotiation authentication, which is required\n");
                printf("for encryption.  Good bye.\n\r");
                Exit(1);
            }
            if (auth_has_failed) {
-               printf("Authentication negotation has failed, which is required for\n");
+               printf("\nAuthentication negotation has failed, which is required for\n");
                printf("encryption.  Good bye.\n\r");
                Exit(1);
            }
            if (my_want_state_is_dont(TELOPT_ENCRYPT) ||
                my_want_state_is_wont(TELOPT_ENCRYPT)) {
-               printf("Server refused to negotiate encryption.  Good bye.\n\r");
+               printf("\nServer refused to negotiate encryption.  Good bye.\n\r");
                Exit(1);
            }
            if (encrypt_is_encrypting())
                break;
            if (time(0) > timeout) {
-               printf("Encryption could not be enabled.  Goodbye.\n\r");
+               printf("\nEncryption could not be enabled.  Goodbye.\n\r");
                Exit(1);
            }
+           if (printed_encrypt == 0) {
+                   printed_encrypt = 1;
+                   printf("Waiting for encryption to be negotiated...");
+                   /*
+                    * Turn on MODE_TRAPSIG and then turn off localchars 
+                    * so that ^C will cause telnet to exit.
+                    */
+                   TerminalNewMode(getconnmode()|MODE_TRAPSIG);
+                   intr_waiting = 1;
+           }
+           if (intr_happened) {
+                   printf("\nUser requested an interrupt.  Goodbye.\n\r");
+                   Exit(1);
+           }
            telnet_spin();
        }
+       if (printed_encrypt) {
+               printf("done.\n");
+               intr_waiting = 0;
+               setconnmode(0);
+       }
     }
 #endif