Clean up krb5_get_fallback_host_realm in two respects:
authorGreg Hudson <ghudson@mit.edu>
Wed, 24 Dec 2008 18:48:00 +0000 (18:48 +0000)
committerGreg Hudson <ghudson@mit.edu>
Wed, 24 Dec 2008 18:48:00 +0000 (18:48 +0000)
1. It isn't exported from libkrb5 (and no one seems to complain about
that).  So give it a krb5int_ name and move its declaration to
k5-int.h.  Also stop exporting it from the collected client lib.

2. It returned a list of realms, but its only caller assumes that the
list contains exactly one realm.  So just make it return a single
realm.

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@21589 dc483132-0cff-0310-8789-dd5450dbe970

src/include/k5-int.h
src/include/krb5/krb5.hin
src/lib/krb5/krb/gc_frm_kdc.c
src/lib/krb5/os/hst_realm.c
src/util/collected-client-lib/libcollected.exports

index 883de3e1881890bc1c7f751a131f1a5639346988..611bddff8bdb9c8f66884c86d8e97b585c4f748e 100644 (file)
@@ -538,6 +538,10 @@ krb5int_locate_server (krb5_context, const krb5_data *realm,
                       struct addrlist *, enum locate_service_type svc,
                       int sockettype, int family);
 
+krb5_error_code
+krb5int_get_fallback_host_realm (krb5_context, krb5_data *hdata,
+                                char **realmp);
+
 /* new encryption provider api */
 
 struct krb5_enc_provider {
index accde60fcaed4b51a0aedc1f5681b3c58d370c97..4848178d00636ae312f121e635c1fc5c9cde3b18 100644 (file)
@@ -2099,10 +2099,6 @@ krb5_error_code KRB5_CALLCONV krb5_get_host_realm
        (krb5_context,
                const char *,
                char *** );
-krb5_error_code KRB5_CALLCONV krb5_get_fallback_host_realm
-       (krb5_context,
-               krb5_data *,
-               char *** );
 krb5_error_code KRB5_CALLCONV krb5_free_host_realm
        (krb5_context,
                char * const * );
index 90a49d6a6e5561bd54a35b0e9a445fe303bfa945..801ea9f8a420b10be62647f3c6488415f1a50c97 100644 (file)
@@ -787,7 +787,7 @@ krb5_get_cred_from_kdc_opt(krb5_context context, krb5_ccache ccache,
     krb5_principal client, server, supplied_server, out_supplied_server;
     krb5_creds tgtq, cc_tgt, *tgtptr, *referral_tgts[KRB5_REFERRAL_MAXHOPS];
     krb5_boolean old_use_conf_ktypes;
-    char **hrealms;
+    char *hrealm;
     unsigned int referral_count, i;
 
     /* 
@@ -1021,23 +1021,22 @@ krb5_get_cred_from_kdc_opt(krb5_context context, krb5_ccache ccache,
      */
     if (krb5_is_referral_realm(&supplied_server->realm)) {
         if (server->length >= 2) {
-           retval=krb5_get_fallback_host_realm(context, &server->data[1],
-                                               &hrealms);
+           retval=krb5int_get_fallback_host_realm(context, &server->data[1],
+                                                  &hrealm);
            if (retval) goto cleanup;
 #if 0
            DPRINTF(("gc_from_kdc: using fallback realm of %s\n",
-                    hrealms[0]));
+                    hrealm));
 #endif
            krb5_free_data_contents(context,&in_cred->server->realm);
-           server->realm.data=hrealms[0];
-           server->realm.length=strlen(hrealms[0]);
-           free(hrealms);
+           server->realm.data=hrealm;
+           server->realm.length=strlen(hrealm);
        }
        else {
            /*
             * Problem case: Realm tagged for referral but apparently not
             * in a <type>/<host> format that
-            * krb5_get_fallback_host_realm can deal with.
+            * krb5int_get_fallback_host_realm can deal with.
             */
            DPRINTF(("gc_from_kdc: referral specified "
                     "but no fallback realm avaiable!\n"));
index 36c0e48608c1ad1df001b3bf577a0558765af1be..a97ca6d9859ee929fba17d7dcd7d6de568113e17 100644 (file)
@@ -335,9 +335,9 @@ krb5int_translate_gai_error (int num)
  */
 
 krb5_error_code KRB5_CALLCONV
-krb5_get_fallback_host_realm(krb5_context context, krb5_data *hdata, char ***realmsp)
+krb5int_get_fallback_host_realm(krb5_context context, krb5_data *hdata,
+                               char **realmp)
 {
-    char **retrealms;
     char *realm, *cp;
     krb5_error_code retval;
     char local_host[MAXDNAME+1], host[MAXDNAME+1];
@@ -417,16 +417,7 @@ krb5_get_fallback_host_realm(krb5_context context, krb5_data *hdata, char ***rea
            return retval;
     }
 
-    if (!(retrealms = (char **)calloc(2, sizeof(*retrealms)))) {
-       if (realm != (char *)NULL)
-           free(realm);
-       return ENOMEM;
-    }
-
-    retrealms[0] = realm;
-    retrealms[1] = 0;
-    
-    *realmsp = retrealms;
+    *realmp = realm;
     return 0;
 }
 
index fb91133fbb3bb10e57759f1cac49654285634fa7..8c124d186e4e6415356a43b7fce5da2273c88ebd 100644 (file)
@@ -177,7 +177,6 @@ krb5_auth_con_getauthenticator
 krb5_read_password
 krb5_aname_to_localname
 krb5_get_host_realm
-krb5_get_fallback_host_realm
 krb5_free_host_realm
 krb5_auth_con_genaddrs
 krb5_set_real_time