[29585] in CVS-changelog-for-Kerberos-V5

home help back first fref pref prev next nref lref last post

krb5 commit: Use krb5_expand_hostname() to get admin service

daemon@ATHENA.MIT.EDU (Greg Hudson)
Wed Aug 24 12:45:01 2016

Date: Wed, 24 Aug 2016 12:44:57 -0400
From: Greg Hudson <ghudson@mit.edu>
Message-Id: <201608241644.u7OGivkd001289@drugstore.mit.edu>
To: cvs-krb5@mit.edu
Reply-To: krbdev@mit.edu
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: cvs-krb5-bounces@mit.edu

https://github.com/krb5/krb5/commit/7b2cb7ed41e48e0fc28f106438f628f30ef86764
commit 7b2cb7ed41e48e0fc28f106438f628f30ef86764
Author: Greg Hudson <ghudson@mit.edu>
Date:   Thu Nov 19 19:32:11 2015 -0500

    Use krb5_expand_hostname() to get admin service
    
    In libkadm5's kadm5_get_admin_service_name(), use
    krb5_expand_hostname() instead of custom canonicalization code to
    canonicalize the hostname.  There are some minor behavior differences;
    in addition to the changes listed in the previous commit, the old code
    did not downcase the result of the getaddrinfo() lookup, while the new
    code does.
    
    ticket: 8278

 src/lib/kadm5/alt_prof.c |   22 +++++++---------------
 1 files changed, 7 insertions(+), 15 deletions(-)

diff --git a/src/lib/kadm5/alt_prof.c b/src/lib/kadm5/alt_prof.c
index 34f8c56..ec6290e 100644
--- a/src/lib/kadm5/alt_prof.c
+++ b/src/lib/kadm5/alt_prof.c
@@ -836,8 +836,7 @@ kadm5_get_admin_service_name(krb5_context ctx, char *realm_in,
 {
     krb5_error_code ret;
     kadm5_config_params params_in, params_out;
-    struct addrinfo hint, *ai = NULL;
-    int err;
+    char *canonhost = NULL;
 
     memset(&params_in, 0, sizeof(params_in));
     memset(&params_out, 0, sizeof(params_out));
@@ -853,25 +852,18 @@ kadm5_get_admin_service_name(krb5_context ctx, char *realm_in,
         goto err_params;
     }
 
-    memset(&hint, 0, sizeof(hint));
-    hint.ai_flags = AI_CANONNAME | AI_ADDRCONFIG;
-    err = getaddrinfo(params_out.admin_server, NULL, &hint, &ai);
-    if (err != 0) {
-        ret = KADM5_CANT_RESOLVE;
-        k5_setmsg(ctx, ret,
-                  _("Cannot resolve address of admin server \"%s\" for realm "
-                    "\"%s\""), params_out.admin_server, realm_in);
+    ret = krb5_expand_hostname(ctx, params_out.admin_server, &canonhost);
+    if (ret)
         goto err_params;
-    }
-    if (strlen(ai->ai_canonname) + sizeof("kadmin/") > maxlen) {
+
+    if (strlen(canonhost) + sizeof("kadmin/") > maxlen) {
         ret = ENOMEM;
         goto err_params;
     }
-    snprintf(admin_name, maxlen, "kadmin/%s", ai->ai_canonname);
+    snprintf(admin_name, maxlen, "kadmin/%s", canonhost);
 
 err_params:
-    if (ai != NULL)
-        freeaddrinfo(ai);
+    krb5_free_string(ctx, canonhost);
     kadm5_free_config_params(ctx, &params_out);
     return ret;
 }
_______________________________________________
cvs-krb5 mailing list
cvs-krb5@mit.edu
https://mailman.mit.edu/mailman/listinfo/cvs-krb5

home help back first fref pref prev next nref lref last post