From ecf6ff7b2ced890529a6c2dbc265ed3940cdf7c9 Mon Sep 17 00:00:00 2001 From: Derrick Brashear Date: Sat, 5 Jan 2008 17:01:24 +0000 Subject: [PATCH] DEVEL15-windows-aklog-referrals-20080105 LICENSE IPL10 If the realm name of the requested ticket is the empty string, decode the actual service ticket to determine the actual realm. Obtaining the actual realm prevents unnecessary pts registration failures. (cherry picked from commit 8e3940c461f29483dcd71a5ba7cc59db89ea38e1) --- src/WINNT/aklog/aklog.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/WINNT/aklog/aklog.c b/src/WINNT/aklog/aklog.c index f3d01ac75..d71471435 100644 --- a/src/WINNT/aklog/aklog.c +++ b/src/WINNT/aklog/aklog.c @@ -701,6 +701,31 @@ static int auth_to_cell(krb5_context context, char *cell, char *realm) NULL, #endif &v5cred); + + if (status == 0 && strcmp(realm_of_cell, "") == 0) { + krb5_error_code code; + krb5_ticket *ticket; + + code = krb5_decode_ticket(&v5cred->ticket, &ticket); + + if (code != 0) { + fprintf(stderr, + "%s: Couldn't decode ticket to determine realm for " + "cell %s.\n", + progname, cell_to_use); + } else { + int len = krb5_princ_realm(context, ticket->server)->length; + /* This really shouldn't happen. */ + if (len > REALM_SZ-1) + len = REALM_SZ-1; + + strncpy(realm_of_cell, krb5_princ_realm(context, ticket->server)->data, len); + realm_of_cell[len] = 0; + + krb5_free_ticket(context, ticket); + } + } + if (status == KRB5_ERR_HOST_REALM_UNKNOWN) { realm_fallback = 1; goto try_v5; -- 2.39.5