krb5 commit: Use krb5_expand_hostname() to get admin service
Greg Hudson
ghudson at mit.edu
Wed Aug 24 12:44:57 EDT 2016
https://github.com/krb5/krb5/commit/7b2cb7ed41e48e0fc28f106438f628f30ef86764
commit 7b2cb7ed41e48e0fc28f106438f628f30ef86764
Author: Greg Hudson <ghudson at 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(¶ms_in, 0, sizeof(params_in));
memset(¶ms_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, ¶ms_out);
return ret;
}
More information about the cvs-krb5
mailing list