(krb5_425_conv_principal_ext): add some comments. add fall-back on
adding the realm name in lower case. git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@8083 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -540,11 +540,20 @@ struct v4_name_convert {
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
/*
|
||||
* return the converted instance name of `name' in `realm'.
|
||||
* look in the configuration file and then in the default set above.
|
||||
* return NULL if no conversion is appropriate.
|
||||
*/
|
||||
|
||||
static const char*
|
||||
get_name_conversion(krb5_context context, const char *realm, const char *name)
|
||||
get_name_conversion(krb5_context context,
|
||||
const char *realm,
|
||||
const char *name)
|
||||
{
|
||||
struct v4_name_convert *q;
|
||||
const char *p;
|
||||
|
||||
p = krb5_config_get_string(context, NULL, "realms", realm,
|
||||
"v4_name_convert", "host", name, NULL);
|
||||
if(p == NULL)
|
||||
@@ -577,6 +586,12 @@ get_name_conversion(krb5_context context, const char *realm, const char *name)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* convert the v4 principal `name.instance@realm' to a v5 principal in `princ'.
|
||||
* if `resolve', use DNS.
|
||||
* if `func', use that function for validating the conversion
|
||||
*/
|
||||
|
||||
krb5_error_code
|
||||
krb5_425_conv_principal_ext(krb5_context context,
|
||||
const char *name,
|
||||
@@ -590,6 +605,7 @@ krb5_425_conv_principal_ext(krb5_context context,
|
||||
krb5_error_code ret;
|
||||
krb5_principal pr;
|
||||
char host[128];
|
||||
char *low_realm = NULL;
|
||||
|
||||
/* do the following: if the name is found in the
|
||||
`v4_name_convert:host' part, is is assumed to be a `host' type
|
||||
@@ -673,15 +689,19 @@ krb5_425_conv_principal_ext(krb5_context context,
|
||||
p = krb5_config_get_string(context, NULL, "realms", realm,
|
||||
"default_domain", NULL);
|
||||
if(p == NULL){
|
||||
/* should this be an error or should it silently
|
||||
succeed? */
|
||||
return HEIM_ERR_V4_PRINC_NO_CONV;
|
||||
low_realm = strdup (realm);
|
||||
if (low_realm == NULL)
|
||||
return ENOMEM;
|
||||
strlwr (low_realm);
|
||||
p = low_realm;
|
||||
}
|
||||
|
||||
if (*p == '.')
|
||||
++p;
|
||||
snprintf(host, sizeof(host), "%s.%s", instance, p);
|
||||
ret = krb5_make_principal(context, &pr, realm, name, host, NULL);
|
||||
if (low_realm)
|
||||
free (low_realm);
|
||||
if(func == NULL || (*func)(context, pr)){
|
||||
*princ = pr;
|
||||
return 0;
|
||||
|
Reference in New Issue
Block a user