(krb5_sname_to_principal): implement different nametypes. Also free

memory.


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@2797 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Assar Westerlund
1997-08-08 03:55:24 +00:00
parent d5b74e06b0
commit ca0a2548a3

View File

@@ -528,11 +528,41 @@ krb5_sname_to_principal (krb5_context context,
if (ret)
return ret;
return krb5_build_principal (context,
ret_princ,
strlen(r[0]),
r[0],
sname,
hostname,
0);
if (type == KRB5_NT_SRV_HST) {
struct hostent *hostent;
char *h;
hostent = gethostbyname (hostname);
if (hostent != NULL)
hostname = hostent->h_name;
h = strdup (hostname);
if (h == NULL) {
krb5_free_host_realm (context, r);
return ENOMEM;
}
strlwr (h);
ret = krb5_build_principal (context,
ret_princ,
strlen(r[0]),
r[0],
sname,
h,
NULL);
krb5_free_host_realm (context, r);
free (h);
return ret;
} else if (type == KRB5_NT_UNKNOWNN) {
ret = krb5_build_principal (context,
ret_princ,
strlen(r[0]),
r[0],
sname,
hostname,
NULL);
krb5_free_host_realm (context, r);
return ret;
} else {
krb5_free_host_realm (context, r);
return KRB5_SNAME_UNSUPP_NAMETYPE;
}
}