(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:
@@ -528,11 +528,41 @@ krb5_sname_to_principal (krb5_context context,
|
|||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
return krb5_build_principal (context,
|
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,
|
ret_princ,
|
||||||
strlen(r[0]),
|
strlen(r[0]),
|
||||||
r[0],
|
r[0],
|
||||||
sname,
|
sname,
|
||||||
hostname,
|
hostname,
|
||||||
0);
|
NULL);
|
||||||
|
krb5_free_host_realm (context, r);
|
||||||
|
return ret;
|
||||||
|
} else {
|
||||||
|
krb5_free_host_realm (context, r);
|
||||||
|
return KRB5_SNAME_UNSUPP_NAMETYPE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user