From: Theodore Tso Date: Thu, 14 Nov 1996 19:53:33 +0000 (+0000) Subject: sys_bsd.c(intr): Added checks to intr_waiting and intr_happened to X-Git-Tag: krb5-1.0-freeze1~15 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=587f386fb7a06f2e9b5115dcd208a6fc0d1f5b2f;p=krb5.git 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] git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@9414 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/appl/telnet/telnet/ChangeLog b/src/appl/telnet/telnet/ChangeLog index 2a1a0c6dd..8080dba47 100644 --- a/src/appl/telnet/telnet/ChangeLog +++ b/src/appl/telnet/telnet/ChangeLog @@ -1,3 +1,11 @@ +Thu Nov 14 14:25:51 1996 Theodore Ts'o + + * 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 * commands.c (tn): Reverse resolve address to deal with dialup diff --git a/src/appl/telnet/telnet/externs.h b/src/appl/telnet/telnet/externs.h index 40f5e4935..c09527f6d 100644 --- a/src/appl/telnet/telnet/externs.h +++ b/src/appl/telnet/telnet/externs.h @@ -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 diff --git a/src/appl/telnet/telnet/sys_bsd.c b/src/appl/telnet/telnet/sys_bsd.c index dbbb9078e..90ea810c1 100644 --- a/src/appl/telnet/telnet/sys_bsd.c +++ b/src/appl/telnet/telnet/sys_bsd.c @@ -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; diff --git a/src/appl/telnet/telnet/telnet.c b/src/appl/telnet/telnet/telnet.c index e89f50629..2ef24320e 100644 --- a/src/appl/telnet/telnet/telnet.c +++ b/src/appl/telnet/telnet/telnet.c @@ -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