pull up r18975 from trunk
authorTom Yu <tlyu@mit.edu>
Tue, 19 Dec 2006 05:05:37 +0000 (05:05 +0000)
committerTom Yu <tlyu@mit.edu>
Tue, 19 Dec 2006 05:05:37 +0000 (05:05 +0000)
 r18975@cathode-dark-space:  raeburn | 2006-12-18 20:31:11 -0500
 ticket: 5121
 tags: pullup

 ktfns.c (krb5_kt_get_entry): If the supplied server principal has an empty
 realm name, replace it with the default realm, in a private copy.

ticket: 5121

git-svn-id: svn://anonsvn.mit.edu/krb5/branches/krb5-1-6@18979 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/krb5/keytab/ktfns.c

index 70da40695470d33f57e97ce0c07256765fdf32b3..63fa6399b66fd19162e86e46b1d70dcb0a2c4939 100644 (file)
@@ -54,7 +54,24 @@ krb5_kt_get_entry(krb5_context context, krb5_keytab keytab,
                  krb5_const_principal principal, krb5_kvno vno,
                  krb5_enctype enctype, krb5_keytab_entry *entry)
 {
-    return krb5_x((keytab)->ops->get,(context, keytab, principal, vno, enctype, entry));
+    krb5_error_code err;
+    krb5_principal_data princ_data;
+
+    if (krb5_is_referral_realm(&principal->realm)) {
+       char *realm;
+       princ_data = *principal;
+       principal = &princ_data;
+       err = krb5_get_default_realm(context, &realm);
+       if (err)
+           return err;
+       princ_data.realm.data = realm;
+       princ_data.realm.length = strlen(realm);
+    }
+    err = krb5_x((keytab)->ops->get,(context, keytab, principal, vno, enctype,
+                                    entry));
+    if (principal == &princ_data)
+       krb5_free_default_realm(context, princ_data.realm.data);
+    return err;
 }
 
 krb5_error_code KRB5_CALLCONV