From 6a2fe45b8186225cbd1d01c1c8db271c67ec378a Mon Sep 17 00:00:00 2001 From: Theodore Tso Date: Thu, 21 Feb 1991 11:48:26 +0000 Subject: [PATCH] Changes to conform with API modifications git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@1753 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/krb425/425data.c | 2 +- src/lib/krb425/kntoln.c | 7 ++++-- src/lib/krb425/krb425.h | 2 +- src/lib/krb425/rd_req.c | 48 +++++++++++++++++++------------------- src/lib/krb425/realmhost.c | 10 ++++++-- 5 files changed, 39 insertions(+), 30 deletions(-) diff --git a/src/lib/krb425/425data.c b/src/lib/krb425/425data.c index 796fad3e3..b3b4fcd4a 100644 --- a/src/lib/krb425/425data.c +++ b/src/lib/krb425/425data.c @@ -18,7 +18,7 @@ static char rcsid_425data_c[] = #include #include "krb425.h" -char _krb425_local_realm[REALM_SZ+1] = { 0 }; +char *krb425_local_realm = 0; krb5_ccache _krb425_ccache = 0; int _krb425_error_init = 0; diff --git a/src/lib/krb425/kntoln.c b/src/lib/krb425/kntoln.c index 2a4c8c2f9..250368ca6 100644 --- a/src/lib/krb425/kntoln.c +++ b/src/lib/krb425/kntoln.c @@ -23,8 +23,11 @@ krb_kntoln(ad,lname) AUTH_DAT *ad; char *lname; { - if (!_krb425_local_realm[0]) - krb5_get_default_realm(REALM_SZ, _krb425_local_realm); + krb5_error_code retval; + + if (!_krb425_local_realm) + if (retval = krb5_get_default_realm(&_krb425_local_realm)) + return(krb425error(retval)); if (strcmp(ad->pinst,"")) return(KFAILURE); diff --git a/src/lib/krb425/krb425.h b/src/lib/krb425/krb425.h index 0d3939f07..0b5d6f9b9 100644 --- a/src/lib/krb425/krb425.h +++ b/src/lib/krb425/krb425.h @@ -46,7 +46,7 @@ str[0] = 0; \ } -extern char _krb425_local_realm[REALM_SZ+1]; +extern char *_krb425_local_realm; extern krb5_ccache _krb425_ccache; extern int _krb425_error_init; diff --git a/src/lib/krb425/rd_req.c b/src/lib/krb425/rd_req.c index f34156bb4..6403ad13f 100644 --- a/src/lib/krb425/rd_req.c +++ b/src/lib/krb425/rd_req.c @@ -28,7 +28,7 @@ AUTH_DAT *ad; char *fn; { krb5_address peer; - krb5_tkt_authent authd; + krb5_tkt_authent *authdat; char addr[4]; krb5_data *server[4]; krb5_data srvdata[3]; @@ -44,8 +44,9 @@ char *fn; memcpy(addr, (char *)&from_addr + (sizeof(from_addr) - 4), 4); } - if (!_krb425_local_realm[0]) - krb5_get_default_realm(REALM_SZ, _krb425_local_realm); + if (!_krb425_local_realm) + if (r = krb5_get_default_realm(&_krb425_local_realm)) + return(krb425error(r)); if (!strcmp(instance, "*")) { static char hostname[64] = { 0 }; @@ -111,7 +112,7 @@ char *fn; if (r = krb5_rd_req(&authe, (krb5_principal)server, from_addr ? &peer : 0, - fn, 0, 0, 0, &authd)) { + fn, 0, 0, 0, &authdat)) { #ifdef EBUG ERROR(r) #endif @@ -122,52 +123,51 @@ char *fn; #ifdef EBUG r = 0; - while (authd.authenticator->client[r]) { - EPRINT "Client[%d]: ", r); show5((*authd.authenticator->client[r])); ENEWLINE + while (authdat->authenticator->client[r]) { + EPRINT "Client[%d]: ", r); show5((*authdat->authenticator->client[r])); ENEWLINE ++r; } r = 0; - while (authd.ticket->server[r]) { - EPRINT "Server[%d]: ", r); show5((*authd.ticket->server[r])); ENEWLINE + while (authdat->ticket->server[r]) { + EPRINT "Server[%d]: ", r); show5((*authdat->ticket->server[r])); ENEWLINE ++r; } r = 0; #endif - set_string(ad->pname, ANAME_SZ, authd.authenticator->client[1]); - set_string(ad->pinst, INST_SZ, authd.authenticator->client[2]); - set_string(ad->prealm, REALM_SZ, authd.authenticator->client[0]); + set_string(ad->pname, ANAME_SZ, authdat->authenticator->client[1]); + set_string(ad->pinst, INST_SZ, authdat->authenticator->client[2]); + set_string(ad->prealm, REALM_SZ, authdat->authenticator->client[0]); - ad->checksum = *(long *)authd.authenticator->checksum->contents; + ad->checksum = *(long *)authdat->authenticator->checksum->contents; - if (authd.ticket->enc_part2->session->keytype != KEYTYPE_DES) { + if (authdat->ticket->enc_part2->session->keytype != KEYTYPE_DES) { r = KFAILURE; goto out; } else memcpy((char*)ad->session, - (char*)authd.ticket->enc_part2->session->contents, + (char*)authdat->ticket->enc_part2->session->contents, sizeof(C_Block)); - ad->life = authd.ticket->enc_part2->times.endtime; - ad->time_sec = authd.authenticator->ctime; + ad->life = authdat->ticket->enc_part2->times.endtime; + ad->time_sec = authdat->authenticator->ctime; ad->address = 0; - if (authd.ticket->enc_part2->caddrs[0]->addrtype != ADDRTYPE_INET) { + if (authdat->ticket->enc_part2->caddrs[0]->addrtype != ADDRTYPE_INET) { r = KFAILURE; goto out; } else memcpy((char*)&ad->address + sizeof(ad->address) - 4, - (char*)authd.ticket->enc_part2->caddrs[0]->contents, 4); + (char*)authdat->ticket->enc_part2->caddrs[0]->contents, 4); - if (authd.ticket->enc_part2->authorization_data && - authd.ticket->enc_part2->authorization_data[0]) { - ad->reply.length = authd.ticket->enc_part2->authorization_data[0]->length; + if (authdat->ticket->enc_part2->authorization_data && + authdat->ticket->enc_part2->authorization_data[0]) { + ad->reply.length = authdat->ticket->enc_part2->authorization_data[0]->length; memcpy((char*)ad->reply.dat, - (char*)authd.ticket->enc_part2->authorization_data[0]->contents, + (char*)authdat->ticket->enc_part2->authorization_data[0]->contents, min(ad->reply.length, MAX_KTXT_LEN)); ad->reply.mbz = 0; } out: - krb5_free_ticket(authd.ticket); - krb5_free_authenticator(authd.authenticator); + krb5_free_tkt_authent(authdat); return(r); } diff --git a/src/lib/krb425/realmhost.c b/src/lib/krb425/realmhost.c index 2f600c6eb..d7d2f9eff 100644 --- a/src/lib/krb425/realmhost.c +++ b/src/lib/krb425/realmhost.c @@ -40,8 +40,14 @@ char *host; if (islower(*cp)) *cp = toupper(*cp); } else { - if (krb5_get_default_realm(REALM_SZ, ret_realm)) - ret_realm[0] = 0; + if (!_krb425_local_realm && + krb5_get_default_realm(&_krb425_local_realm)) + _krb425_local_realm = NULL; + + if (_krb425_local_realm) { + strncpy(ret_realm, _krb425_local_realm, REALM_SZ); + ret_realm[REALM_SZ-1] = 0; + } } if (krb5_get_host_realm(host, &realms)) { -- 2.26.2