diff options
author | Jacques Vidrine <nectar@FreeBSD.org> | 2002-04-30 14:50:51 +0000 |
---|---|---|
committer | Jacques Vidrine <nectar@FreeBSD.org> | 2002-04-30 14:50:51 +0000 |
commit | 95bef86183b0ed644d84d7437fd343ed222ac606 (patch) | |
tree | cacff2d70386162e46823f2de1891ffcc4f41b2e /crypto/heimdal/appl/telnet/telnet/telnet.c | |
parent | 7c688114cf4cb5ac34f9e7c271962d6fa4bec144 (diff) | |
download | src-95bef86183b0ed644d84d7437fd343ed222ac606.tar.gz src-95bef86183b0ed644d84d7437fd343ed222ac606.zip |
MFC: Update Heimdal Kerberos to 0.4e around 2002/02/17.
Notes
Notes:
svn path=/stable/4/; revision=95799
Diffstat (limited to 'crypto/heimdal/appl/telnet/telnet/telnet.c')
-rw-r--r-- | crypto/heimdal/appl/telnet/telnet/telnet.c | 74 |
1 files changed, 71 insertions, 3 deletions
diff --git a/crypto/heimdal/appl/telnet/telnet/telnet.c b/crypto/heimdal/appl/telnet/telnet/telnet.c index e705a7babf40..fab32a7ee875 100644 --- a/crypto/heimdal/appl/telnet/telnet/telnet.c +++ b/crypto/heimdal/appl/telnet/telnet/telnet.c @@ -36,7 +36,7 @@ #include <termcap.h> #endif -RCSID("$Id: telnet.c,v 1.28 2000/11/08 17:32:43 joda Exp $"); +RCSID("$Id: telnet.c,v 1.31 2001/12/20 20:39:52 joda Exp $"); #define strip(x) (eight ? (x) : ((x) & 0x7f)) @@ -70,6 +70,7 @@ int netdata, /* Print out network data flow */ crlf, /* Should '\r' be mapped to <CR><LF> (or <CR><NUL>)? */ telnetport, + wantencryption = 0, SYNCHing, /* we are in TELNET SYNCH mode */ flushout, /* flush output */ autoflush = 0, /* flush output when interrupting? */ @@ -84,6 +85,8 @@ int char *prompt = 0; +int scheduler_lockout_tty = 0; + cc_t escape; cc_t rlogin; #ifdef KLUDGELINEMODE @@ -579,7 +582,7 @@ mklist(char *buf, char *name) #define ISASCII(c) (!((c)&0x80)) if ((c == ' ') || !ISASCII(c)) n = 1; - else if (islower(c)) + else if (islower((unsigned char)c)) *cp = toupper(c); } @@ -1957,7 +1960,7 @@ telsnd() */ -static int + int Scheduler(int block) /* should we block in the select ? */ { /* One wants to be a bit careful about setting returnValue @@ -1988,6 +1991,10 @@ Scheduler(int block) /* should we block in the select ? */ /* If we have seen a signal recently, reset things */ + if (scheduler_lockout_tty) { + ttyin = ttyout = 0; + } + /* Call to system code to process rings */ returnValue = process_rings(netin, netout, netex, ttyin, ttyout, !block); @@ -2010,6 +2017,8 @@ Scheduler(int block) /* should we block in the select ? */ void my_telnet(char *user) { + int printed_encrypt = 0; + sys_telnet_init(); #if defined(AUTHENTICATION) || defined(ENCRYPTION) @@ -2048,6 +2057,64 @@ my_telnet(char *user) tel_enter_binary(binary); } +#ifdef ENCRYPTION + /* + * Note: we assume a tie to the authentication option here. This + * is necessary so that authentication fails, we don't spin + * forever. + */ + if (wantencryption) { + extern int auth_has_failed; + time_t timeout = time(0) + 60; + + send_do(TELOPT_ENCRYPT, 1); + send_will(TELOPT_ENCRYPT, 1); + while (1) { + if (my_want_state_is_wont(TELOPT_AUTHENTICATION)) { + printf("\nServer refused to negotiate authentication,\n"); + printf("which is required for encryption.\n"); + Exit(1); + } + if (auth_has_failed) { + printf("\nAuthentication negotation has failed,\n"); + printf("which is required for encryption.\n"); + Exit(1); + } + if (my_want_state_is_dont(TELOPT_ENCRYPT) || + my_want_state_is_wont(TELOPT_ENCRYPT)) { + printf("\nServer refused to negotiate encryption.\n"); + Exit(1); + } + if (encrypt_is_encrypting()) + break; + if (time(0) > timeout) { + printf("\nEncryption could not be enabled.\n"); + Exit(1); + } + if (printed_encrypt == 0) { + printed_encrypt = 1; + printf("Waiting for encryption to be negotiated...\n"); + /* + * 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 interrupt.\n"); + Exit(1); + } + telnet_spin(); + } + if (printed_encrypt) { + printf("done.\n"); + intr_waiting = 0; + setconnmode(0); + } + } +#endif + for (;;) { int schedValue; @@ -2286,6 +2353,7 @@ sendnaws() if (my_state_is_wont(TELOPT_NAWS)) return; +#undef PUTSHORT #define PUTSHORT(cp, x) { if ((*cp++ = ((x)>>8)&0xff) == IAC) *cp++ = IAC; \ if ((*cp++ = ((x))&0xff) == IAC) *cp++ = IAC; } |