From db3be478c1c8d73fa24a630cb576bff816b62b35 Mon Sep 17 00:00:00 2001 From: Ezra Peisach Date: Wed, 6 Jun 2001 21:21:53 +0000 Subject: [PATCH] * auth-proto.h: Add prototypes for getauthmask(), auth_enable, auth_disable(), auth_onoff(), auth_togdebug(), auth_status(), auth_name(), auth_sendname(), auth_debug(), and auth_printsub(). * auth.c: Include unistd.h and cleanup some assignments in conditionals. * auth.h: Explicitly declare auth_debug mode as an int. * enc-proto.h: Add prototypes for EncryptDisable(), EncryptType(), EncryptStart(), EncryptStartInput(), EncryptStartOutput(), EncryptStop(), EncryptStopInput(), EncryptStopOutput(), EncryptStatus(), encrypt_gen_printsub(), printsub(). * enc_des.c: Declare encrypt_debug_mode as int. Cleanup unused variables and assignments in conditionals. * encrypt.c: Include stdio.h for sprintf prototype. Cleanup assignments in conditionals. * getent.c: Conditionalize definition of some variables. * kerberos5.c: Explicitly declare auth_debug_mode an int. * misc-proto.h: Add prototype for auth_encrypt_user(). * misc.c: Include auth.h and encrypt.h for prototypes. * misc.h: Add prototypes for isprfix(), genget(), Ambiguous(). * parsetos.c: Include stdlib.h for strtol() prototype. * forward.c, kerberos.c, setenv.c: Assignment in conditional cleanup. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@13280 dc483132-0cff-0310-8789-dd5450dbe970 --- src/appl/telnet/libtelnet/ChangeLog | 36 ++++++++++++++++++++ src/appl/telnet/libtelnet/auth-proto.h | 13 +++++++ src/appl/telnet/libtelnet/auth.c | 5 +-- src/appl/telnet/libtelnet/auth.h | 2 +- src/appl/telnet/libtelnet/enc-proto.h | 12 +++++++ src/appl/telnet/libtelnet/enc_des.c | 12 ++----- src/appl/telnet/libtelnet/encrypt.c | 7 ++-- src/appl/telnet/libtelnet/forward.c | 12 +++---- src/appl/telnet/libtelnet/getent.c | 3 ++ src/appl/telnet/libtelnet/kerberos.c | 47 ++++++++++++++------------ src/appl/telnet/libtelnet/kerberos5.c | 2 +- src/appl/telnet/libtelnet/misc-proto.h | 1 + src/appl/telnet/libtelnet/misc.c | 5 ++- src/appl/telnet/libtelnet/misc.h | 12 +++++++ src/appl/telnet/libtelnet/parsetos.c | 3 ++ src/appl/telnet/libtelnet/setenv.c | 5 +-- 16 files changed, 130 insertions(+), 47 deletions(-) diff --git a/src/appl/telnet/libtelnet/ChangeLog b/src/appl/telnet/libtelnet/ChangeLog index 3695791e2..5c33058e6 100644 --- a/src/appl/telnet/libtelnet/ChangeLog +++ b/src/appl/telnet/libtelnet/ChangeLog @@ -1,3 +1,39 @@ +2001-06-06 Ezra Peisach + + * auth-proto.h: Add prototypes for getauthmask(), auth_enable, + auth_disable(), auth_onoff(), auth_togdebug(), auth_status(), + auth_name(), auth_sendname(), auth_debug(), and auth_printsub(). + + * auth.c: Include unistd.h and cleanup some assignments in + conditionals. + + * auth.h: Explicitly declare auth_debug mode as an int. + + * enc-proto.h: Add prototypes for EncryptDisable(), EncryptType(), + EncryptStart(), EncryptStartInput(), EncryptStartOutput(), + EncryptStop(), EncryptStopInput(), EncryptStopOutput(), + EncryptStatus(), encrypt_gen_printsub(), printsub(). + + * enc_des.c: Declare encrypt_debug_mode as int. Cleanup unused + variables and assignments in conditionals. + + * encrypt.c: Include stdio.h for sprintf prototype. Cleanup + assignments in conditionals. + + * getent.c: Conditionalize definition of some variables. + + * kerberos5.c: Explicitly declare auth_debug_mode an int. + + * misc-proto.h: Add prototype for auth_encrypt_user(). + + * misc.c: Include auth.h and encrypt.h for prototypes. + + * misc.h: Add prototypes for isprfix(), genget(), Ambiguous(). + + * parsetos.c: Include stdlib.h for strtol() prototype. + + * forward.c, kerberos.c, setenv.c: Assignment in conditional cleanup. + 2001-04-03 Tom Yu * configure.in: Check for setenv, unsetenv, and getenv. Compile diff --git a/src/appl/telnet/libtelnet/auth-proto.h b/src/appl/telnet/libtelnet/auth-proto.h index b1a0bb0b8..bf7615e7a 100644 --- a/src/appl/telnet/libtelnet/auth-proto.h +++ b/src/appl/telnet/libtelnet/auth-proto.h @@ -80,6 +80,19 @@ int auth_must_encrypt P((void)); void auth_disable_name P((char *)); void auth_gen_printsub P((unsigned char *, int, unsigned char *, int)); + +int getauthmask P((char *, int *)); +int auth_enable P((char *)); +int auth_disable P((char *)); +int auth_onoff P((char *, int)); +int auth_togdebug P((int)); +int auth_status P((void)); +void auth_name P((unsigned char *, int)); +int auth_sendname P((unsigned char *, int)); +void auth_debug P((int)); +void auth_printsub P((unsigned char *, int, unsigned char *, int)); + + #ifdef KRB4 int kerberos4_init P((Authenticator *, int)); int kerberos4_send P((Authenticator *)); diff --git a/src/appl/telnet/libtelnet/auth.c b/src/appl/telnet/libtelnet/auth.c index f10ffb7aa..d3150846a 100644 --- a/src/appl/telnet/libtelnet/auth.c +++ b/src/appl/telnet/libtelnet/auth.c @@ -65,6 +65,7 @@ #include #ifdef __STDC__ #include +#include #endif #ifdef HAVE_STRING_H #include @@ -468,7 +469,7 @@ auth_is(data, cnt) return; } - if (ap = findauthenticator(data[0], data[1])) { + if ((ap = findauthenticator(data[0], data[1]))) { if (ap->is) (*ap->is)(ap, data+2, cnt-2); } else if (auth_debug_mode) @@ -486,7 +487,7 @@ auth_reply(data, cnt) if (cnt < 2) return; - if (ap = findauthenticator(data[0], data[1])) { + if ((ap = findauthenticator(data[0], data[1]))) { if (ap->reply) (*ap->reply)(ap, data+2, cnt-2); } else if (auth_debug_mode) diff --git a/src/appl/telnet/libtelnet/auth.h b/src/appl/telnet/libtelnet/auth.h index 0fe8bcf6f..f7d869c0b 100644 --- a/src/appl/telnet/libtelnet/auth.h +++ b/src/appl/telnet/libtelnet/auth.h @@ -89,5 +89,5 @@ typedef struct XauthP { #define OPTS_FORWARD_CREDS 0x00000002 #define OPTS_FORWARDABLE_CREDS 0x00000001 -extern auth_debug_mode; +extern int auth_debug_mode; #endif diff --git a/src/appl/telnet/libtelnet/enc-proto.h b/src/appl/telnet/libtelnet/enc-proto.h index 2a17d44f4..f9ee6725b 100644 --- a/src/appl/telnet/libtelnet/enc-proto.h +++ b/src/appl/telnet/libtelnet/enc-proto.h @@ -81,13 +81,25 @@ void encrypt_send_request_end P((void)); void encrypt_send_end P((void)); void encrypt_wait P((void)); int encrypt_is_encrypting P((void)); +int EncryptEnable P((char *, char *)); +int EncryptDisable P((char *, char *)); +int EncryptType P((char *, char *)); +int EncryptStart P((char *)); +int EncryptStartInput P((void)); +int EncryptStartOutput P((void)); +int EncryptStop P((char *)); +int EncryptStopInput P((void)); +int EncryptStopOutput P((void)); +int EncryptStatus P((void)); void encrypt_send_support P((void)); void encrypt_send_keyid P((int, unsigned char *, int, int)); int net_write P((unsigned char *, int)); +void encrypt_gen_printsub P((unsigned char *, int, unsigned char *, int)); #ifdef TELENTD void encrypt_wait P((void)); #else +void printsub P((int, unsigned char *, int)); int encrypt_cmd P((int, char **)); void encrypt_display P((void)); #endif diff --git a/src/appl/telnet/libtelnet/enc_des.c b/src/appl/telnet/libtelnet/enc_des.c index 3912b35e9..2b2091485 100644 --- a/src/appl/telnet/libtelnet/enc_des.c +++ b/src/appl/telnet/libtelnet/enc_des.c @@ -78,7 +78,7 @@ #include "key-proto.h" #include "misc-proto.h" -extern encrypt_debug_mode; +extern int encrypt_debug_mode; extern krb5_context telnet_context; @@ -234,7 +234,6 @@ fb64_start(fbp, dir, server) int dir; int server; { - Block b; int x; unsigned char *p; register int state; @@ -276,8 +275,8 @@ fb64_start(fbp, dir, server) d.data = fbp->temp_feed; d.length = sizeof(fbp->temp_feed); - if (code = krb5_c_random_make_octets(telnet_context, - &d)) + if ((code = krb5_c_random_make_octets(telnet_context, + &d))) return(FAILED); } @@ -327,9 +326,7 @@ fb64_is(data, cnt, fbp) int cnt; struct fb *fbp; { - int x; unsigned char *p; - Block b; register int state = fbp->state[DIR_DECRYPT-1]; if (cnt-- < 1) @@ -419,9 +416,6 @@ fb64_reply(data, cnt, fbp) int cnt; struct fb *fbp; { - int x; - unsigned char *p; - Block b; register int state = fbp->state[DIR_ENCRYPT-1]; if (cnt-- < 1) diff --git a/src/appl/telnet/libtelnet/encrypt.c b/src/appl/telnet/libtelnet/encrypt.c index 8833188bc..c843ca94f 100644 --- a/src/appl/telnet/libtelnet/encrypt.c +++ b/src/appl/telnet/libtelnet/encrypt.c @@ -58,6 +58,7 @@ #ifdef ENCRYPTION +#include #define ENCRYPT_NAMES #include @@ -249,7 +250,7 @@ EncryptDisable(type, mode) if (isprefix(type, "help") || isprefix(type, "?")) { printf("Usage: encrypt disable [input|output]\n"); encrypt_list_types(); - } else if ((ep = (Encryptions *)genget(type, encryptions, + } else if ((ep = (Encryptions *)genget(type, (char **) encryptions, sizeof(Encryptions))) == 0) { printf("%s: invalid encryption type\n", type); } else if (Ambiguous(ep)) { @@ -284,7 +285,7 @@ EncryptType(type, mode) if (isprefix(type, "help") || isprefix(type, "?")) { printf("Usage: encrypt type [input|output]\n"); encrypt_list_types(); - } else if ((ep = (Encryptions *)genget(type, encryptions, + } else if ((ep = (Encryptions *)genget(type, (char **) encryptions, sizeof(Encryptions))) == 0) { printf("%s: invalid encryption type\n", type); } else if (Ambiguous(ep)) { @@ -644,7 +645,7 @@ encrypt_start(data, cnt) return; } - if (ep = finddecryption(decrypt_mode)) { + if ((ep = finddecryption(decrypt_mode))) { decrypt_input = ep->input; if (encrypt_verbose) printf("[ Input is now decrypted with type %s ]\r\n", diff --git a/src/appl/telnet/libtelnet/forward.c b/src/appl/telnet/libtelnet/forward.c index 2d13067ef..1042a452a 100644 --- a/src/appl/telnet/libtelnet/forward.c +++ b/src/appl/telnet/libtelnet/forward.c @@ -43,21 +43,21 @@ rd_and_store_for_creds(context, auth_context, inbuf, ticket) krb5_error_code retval; char ccname[35]; krb5_ccache ccache = NULL; - char *tty; - if (retval = krb5_rd_cred(context, auth_context, inbuf, &creds, NULL)) + if ((retval = krb5_rd_cred(context, auth_context, inbuf, &creds, NULL))) return(retval); - sprintf(ccname, "FILE:/tmp/krb5cc_p%d", getpid()); + sprintf(ccname, "FILE:/tmp/krb5cc_p%ld", (long) getpid()); setenv(KRB5_ENV_CCNAME, ccname, 1); - if (retval = krb5_cc_resolve(context, ccname, &ccache)) + if ((retval = krb5_cc_resolve(context, ccname, &ccache))) goto cleanup; - if (retval = krb5_cc_initialize(context, ccache, ticket->enc_part2->client)) + if ((retval = krb5_cc_initialize(context, ccache, + ticket->enc_part2->client))) goto cleanup; - if (retval = krb5_cc_store_cred(context, ccache, *creds)) + if ((retval = krb5_cc_store_cred(context, ccache, *creds))) goto cleanup; cleanup: diff --git a/src/appl/telnet/libtelnet/getent.c b/src/appl/telnet/libtelnet/getent.c index 7a80f54de..8d77ba3bf 100644 --- a/src/appl/telnet/libtelnet/getent.c +++ b/src/appl/telnet/libtelnet/getent.c @@ -33,9 +33,12 @@ /* based on @(#)getent.c 8.1 (Berkeley) 6/4/93 */ +#ifdef HAVE_CGETENT static char *area; +#endif /*ARGSUSED*/ +int getent(cp, name) char *cp, *name; { diff --git a/src/appl/telnet/libtelnet/kerberos.c b/src/appl/telnet/libtelnet/kerberos.c index eb657aee6..4fe0b11a5 100644 --- a/src/appl/telnet/libtelnet/kerberos.c +++ b/src/appl/telnet/libtelnet/kerberos.c @@ -106,13 +106,17 @@ #include "auth.h" #include "misc.h" -extern auth_debug_mode; +extern int auth_debug_mode; extern krb5_context telnet_context; +int kerberos4_cksum P((unsigned char *, int)); + static unsigned char str_data[1024] = { IAC, SB, TELOPT_AUTHENTICATION, 0, AUTHTYPE_KERBEROS_V4, }; +#if 0 static unsigned char str_name[1024] = { IAC, SB, TELOPT_AUTHENTICATION, TELQUAL_NAME, }; +#endif #define KRB_AUTH 0 /* Authentication data follows */ #define KRB_REJECT 1 /* Rejected (reason might follow) */ @@ -127,7 +131,6 @@ static char name[ANAME_SZ]; static AUTH_DAT adat = { 0 }; #ifdef ENCRYPTION static Block session_key = { 0 }; -static Schedule sched; static krb5_keyblock krbkey; static Block challenge = { 0 }; #endif /* ENCRYPTION */ @@ -219,7 +222,7 @@ kerberos4_send(ap) memset(instance, 0, sizeof(instance)); - if (realm = krb_get_phost(RemoteHostName)) + if ((realm = krb_get_phost(RemoteHostName))) strncpy(instance, realm, sizeof(instance)); instance[sizeof(instance)-1] = '\0'; @@ -230,11 +233,11 @@ kerberos4_send(ap) printf("Kerberos V4: no realm for %s\r\n", RemoteHostName); return(0); } - if (r = krb_mk_req(&auth, KRB_SERVICE_NAME, instance, realm, 0)) { + if ((r = krb_mk_req(&auth, KRB_SERVICE_NAME, instance, realm, 0))) { printf("mk_req failed: %s\r\n", krb_err_txt[r]); return(0); } - if (r = krb_get_cred(KRB_SERVICE_NAME, instance, realm, &cred)) { + if ((r = krb_get_cred(KRB_SERVICE_NAME, instance, realm, &cred))) { printf("get_cred failed: %s\r\n", krb_err_txt[r]); return(0); } @@ -261,15 +264,15 @@ kerberos4_send(ap) data.data = cred.session; data.length = 8; /* sizeof(cred.session) */; - if (code = krb5_c_random_seed(telnet_context, &data)) { + if ((code = krb5_c_random_seed(telnet_context, &data))) { com_err("libtelnet", code, "while seeding random number generator"); return(0); } - if (code = krb5_c_make_random_key(telnet_context, - ENCTYPE_DES_CBC_RAW, - &random_key)) { + if ((code = krb5_c_make_random_key(telnet_context, + ENCTYPE_DES_CBC_RAW, + &random_key))) { com_err("libtelnet", code, "while creating random session key"); return(0); @@ -327,8 +330,8 @@ kerberos4_send(ap) encdata.ciphertext.length = 8; encdata.enctype = ENCTYPE_UNKNOWN; - if (code = krb5_c_encrypt(telnet_context, &krbkey, 0, 0, &data, - &encdata)) { + if ((code = krb5_c_encrypt(telnet_context, &krbkey, 0, 0, + &data, &encdata))) { com_err("libtelnet", code, "while encrypting random key"); return(0); } @@ -380,8 +383,8 @@ kerberos4_is(ap, data, cnt) printf("\r\n"); } instance[0] = '*'; instance[1] = 0; - if (r = krb_rd_req(&auth, KRB_SERVICE_NAME, - instance, 0, &adat, "")) { + if ((r = krb_rd_req(&auth, KRB_SERVICE_NAME, + instance, 0, &adat, ""))) { if (auth_debug_mode) printf("Kerberos failed him as %s\r\n", name); Data(ap, KRB_REJECT, (void *)krb_err_txt[r], -1); @@ -423,7 +426,7 @@ kerberos4_is(ap, data, cnt) kdata.data = session_key; kdata.length = 8; - if (code = krb5_c_random_seed(telnet_context, &kdata)) { + if ((code = krb5_c_random_seed(telnet_context, &kdata))) { com_err("libtelnet", code, "while seeding random number generator"); return; @@ -446,8 +449,8 @@ kerberos4_is(ap, data, cnt) encdata.ciphertext.length = 8; encdata.enctype = ENCTYPE_UNKNOWN; - if (code = krb5_c_encrypt(telnet_context, &krbkey, 0, 0, - &kdata, &encdata)) { + if ((code = krb5_c_encrypt(telnet_context, &krbkey, 0, 0, + &kdata, &encdata))) { com_err("libtelnet", code, "while encrypting random key"); return; } @@ -467,8 +470,8 @@ kerberos4_is(ap, data, cnt) kdata.data = challenge; kdata.length = 8; - if (code = krb5_c_decrypt(telnet_context, &krbkey, 0, 0, - &encdata, &kdata)) { + if ((code = krb5_c_decrypt(telnet_context, &krbkey, 0, 0, + &encdata, &kdata))) { com_err("libtelnet", code, "while decrypting challenge"); return; } @@ -488,8 +491,8 @@ kerberos4_is(ap, data, cnt) encdata.ciphertext.length = 8; encdata.enctype = ENCTYPE_UNKNOWN; - if (code = krb5_c_encrypt(telnet_context, &krbkey, 0, 0, - &kdata, &encdata)) { + if ((code = krb5_c_encrypt(telnet_context, &krbkey, 0, 0, + &kdata, &encdata))) { com_err("libtelnet", code, "while decrypting challenge"); return; } @@ -550,8 +553,8 @@ kerberos4_reply(ap, data, cnt) encdata.ciphertext.length = 8; encdata.enctype = ENCTYPE_UNKNOWN; - if (code = krb5_c_encrypt(telnet_context, &krbkey, - 0, 0, &kdata, &encdata)) { + if ((code = krb5_c_encrypt(telnet_context, &krbkey, + 0, 0, &kdata, &encdata))) { com_err("libtelnet", code, "while encrypting session_key"); return; diff --git a/src/appl/telnet/libtelnet/kerberos5.c b/src/appl/telnet/libtelnet/kerberos5.c index b4c73980b..9be561c1a 100644 --- a/src/appl/telnet/libtelnet/kerberos5.c +++ b/src/appl/telnet/libtelnet/kerberos5.c @@ -85,7 +85,7 @@ extern char *malloc(); #include "auth.h" #include "misc.h" -extern auth_debug_mode; +extern int auth_debug_mode; extern int net; #ifdef FORWARD diff --git a/src/appl/telnet/libtelnet/misc-proto.h b/src/appl/telnet/libtelnet/misc-proto.h index 3924a4651..9046fa365 100644 --- a/src/appl/telnet/libtelnet/misc-proto.h +++ b/src/appl/telnet/libtelnet/misc-proto.h @@ -68,6 +68,7 @@ #endif void auth_encrypt_init P((char *, char *, char *, int)); +void auth_encrypt_user P((char *)); void auth_encrypt_connect P((int)); void printd P((unsigned char *, int)); diff --git a/src/appl/telnet/libtelnet/misc.c b/src/appl/telnet/libtelnet/misc.c index 78f48f8d7..96fb87bc2 100644 --- a/src/appl/telnet/libtelnet/misc.c +++ b/src/appl/telnet/libtelnet/misc.c @@ -33,8 +33,11 @@ /* based on @(#)misc.c 8.1 (Berkeley) 6/4/93 */ -#include "misc.h" #include +#include +#include "misc.h" +#include "auth.h" +#include "encrypt.h" char *RemoteHostName; char *LocalHostName; diff --git a/src/appl/telnet/libtelnet/misc.h b/src/appl/telnet/libtelnet/misc.h index 41ffa7f67..3f87154d8 100644 --- a/src/appl/telnet/libtelnet/misc.h +++ b/src/appl/telnet/libtelnet/misc.h @@ -39,4 +39,16 @@ extern char *RemoteHostName; extern int ConnectedCount; extern int ReservedPort; +#if !defined(P) +#ifdef __STDC__ +#define P(x) x +#else +#define P(x) () +#endif +#endif + +int isprefix P((char *, char *)); +char **genget P((char *, char **, int)); +int Ambiguous P((void *)); + #include "misc-proto.h" diff --git a/src/appl/telnet/libtelnet/parsetos.c b/src/appl/telnet/libtelnet/parsetos.c index ad2a3a28a..c88205e48 100644 --- a/src/appl/telnet/libtelnet/parsetos.c +++ b/src/appl/telnet/libtelnet/parsetos.c @@ -5,6 +5,7 @@ */ #include +#include #include #include #include @@ -18,7 +19,9 @@ parsetos(name, proto) char *name; char *proto; { +#if 0 register char *c; +#endif int tos; #ifdef HAVE_GETTOSBYNAME diff --git a/src/appl/telnet/libtelnet/setenv.c b/src/appl/telnet/libtelnet/setenv.c index bc4f22da9..b8e153835 100644 --- a/src/appl/telnet/libtelnet/setenv.c +++ b/src/appl/telnet/libtelnet/setenv.c @@ -53,6 +53,7 @@ static char *__findenv __P((const char *, int *)); * "value". If rewrite is set, replace any current value. */ #ifndef HAVE_SETENV +int setenv(name, value, rewrite) register const char *name; register const char *value; @@ -70,7 +71,7 @@ setenv(name, value, rewrite) if (!rewrite) return (0); if (strlen(c) >= l_value) { /* old larger; copy over */ - while (*c++ = *value++); + while ((*c++ = *value++)); return (0); } } else { /* create new slot */ @@ -100,7 +101,7 @@ setenv(name, value, rewrite) malloc((size_t)((int)(c - name) + l_value + 2)))) return (-1); for (c = environ[offset]; (*c = *name++) && *c != '='; ++c); - for (*c++ = '='; *c++ = *value++;); + for (*c++ = '='; (*c++ = *value++);); return (0); } #endif -- 2.26.2