From e2857ae5575f42be082beedf012baf6061d722b0 Mon Sep 17 00:00:00 2001 From: Theodore Tso Date: Wed, 15 Dec 1993 18:09:04 +0000 Subject: [PATCH] Preprend "FILE:" when converting from V4 ticket file name to V5 credentials cache name. Fixed bug in conversion of Kerberos V5 to V4 principals names. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@3179 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/krb425/get_cred.c | 14 +++++++++----- src/lib/krb425/rd_req.c | 28 +++++++++++++++++++++++----- 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/src/lib/krb425/get_cred.c b/src/lib/krb425/get_cred.c index 1307f10d4..e0153b229 100644 --- a/src/lib/krb425/get_cred.c +++ b/src/lib/krb425/get_cred.c @@ -93,12 +93,16 @@ CREDENTIALS *c; } } #endif - set_string(c->pname, ANAME_SZ, krb5_princ_component(creds.client, 1)); - set_string(c->pinst, INST_SZ, krb5_princ_component(creds.client, 2)); - + set_string(c->pname, ANAME_SZ, krb5_princ_component(creds.client, 0)); + if (creds.client->length > 1) { + set_string(c->pinst, INST_SZ, krb5_princ_component(creds.client, 1)); + } + else { + c->pinst[0] = '\0'; + } set_string(c->realm, REALM_SZ, krb5_princ_realm(creds.server)); - set_string(c->service, REALM_SZ, krb5_princ_component(creds.server, 1)); - set_string(c->instance, REALM_SZ, krb5_princ_component(creds.server, 2)); + set_string(c->service, ANAME_SZ, krb5_princ_component(creds.server, 0)); +* set_string(c->instance, INST_SZ, krb5_princ_component(creds.server, 1)); c->ticket_st.length = creds.ticket.length; memcpy((char *)c->ticket_st.dat, diff --git a/src/lib/krb425/rd_req.c b/src/lib/krb425/rd_req.c index 54b3ad981..64b0850eb 100644 --- a/src/lib/krb425/rd_req.c +++ b/src/lib/krb425/rd_req.c @@ -31,6 +31,7 @@ static char rcsid_rd_req_c[] = #endif /* !lint & !SABER */ #include "krb425.h" +#include static krb5_error_code setkey_key_proc(DECLARG(krb5_pointer,arg), @@ -62,6 +63,8 @@ char *fn; krb5_data authe; extern int gethostname(); int use_set_key = 0; + char file_name[MAXPATHLEN]; + int tmp; if (from_addr) { peer.addrtype = ADDRTYPE_INET; @@ -108,8 +111,15 @@ char *fn; if (!fn) { use_set_key = 1; fn = (char *)0; - } else if (!*fn) + } else if (!*fn) { fn = (char *)0; + } else { + strcpy(file_name, "FILE:"); + strncpy(file_name + 5, fn, MAXPATHLEN-5); + file_name[sizeof(file_name)-1] = '\0'; + fn = file_name; + } + #ifdef EBUG EPRINT "Calling krb5_rd_req with:\n"); @@ -175,12 +185,20 @@ char *fn; r = 0; #endif set_string(ad->pname, ANAME_SZ, - krb5_princ_component(authdat->authenticator->client, 1)); - set_string(ad->pinst, INST_SZ, - krb5_princ_component(authdat->authenticator->client, 2)); - set_string(ad->prealm, REALM_SZ, krb5_princ_component(authdat->authenticator->client, 0)); + if (authdat->authenticator->client->length > 1) { + set_string(ad->pinst, INST_SZ, + krb5_princ_component(authdat->authenticator->client, + 1)); + } + else { + ad->pinst[0] = '\0'; + } + + set_string(ad->prealm, REALM_SZ, + krb5_princ_realm(authdat->authenticator->client)); + ad->checksum = *(long *)authdat->authenticator->checksum->contents; if (authdat->ticket->enc_part2->session->keytype != KEYTYPE_DES) { -- 2.26.2