(krb5_sname_to_principal): use getaddrinfo

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@7490 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Assar Westerlund
1999-12-04 17:59:35 +00:00
parent 861698f953
commit 032cf94b5b

View File

@@ -876,23 +876,21 @@ krb5_sname_to_principal (krb5_context context,
sname = "host"; sname = "host";
if(type == KRB5_NT_SRV_HST) { if(type == KRB5_NT_SRV_HST) {
int error; int error;
struct addrinfo hints, *res;
char *host;
#ifdef HAVE_IPV6 memset (&hints, 0, sizeof(hints));
if (hp == NULL) hints.ai_flags = AI_CANONNAME;
hp = getipnodebyname (hostname, AF_INET6, 0, &error);
#endif error = getaddrinfo (hostname, NULL, &hints, &res);
if (hp == NULL) if (error == 0) {
hp = getipnodebyname (hostname, AF_INET, 0, &error); host = strdup (res->ai_canonname);
if(hp != NULL) freeaddrinfo (res);
hostname = hp->h_name; } else {
} host = strdup (hostname);
if(type == KRB5_NT_SRV_HST) {
host = strdup(hostname);
if(host == NULL){
if (hp != NULL)
freehostent (hp);
return ENOMEM;
} }
if (host == NULL)
return ENOMEM;
strlwr(host); strlwr(host);
hostname = host; hostname = host;
} }