lib/krb5: krb5_cc_set_default_name Windows MSLSA:

If there is no default credential cache obtained from the registry
or from configuration files, then check to see if there is a valid
principal available from the MSLSA: credential cache.  If so, use
"MSLSA:" as the default credential cache.  This will simply configuration
for users on domain joined Windows machines when logged in using a
domain account.

Change-Id: I4c4392e0fdcec89aff3d258ce1b753e6458e3eec
This commit is contained in:
Jeffrey Altman
2016-03-31 11:44:01 -05:00
parent 338b4a1fba
commit 1b95a70e4f

View File

@@ -513,6 +513,7 @@ krb5_cc_set_default_name(krb5_context context, const char *name)
krb5_error_code ret = 0;
char *p = NULL, *exp_p = NULL;
int filepath;
const krb5_cc_ops *ops = KRB5_DEFAULT_CCTYPE;
if (name == NULL) {
const char *e = NULL;
@@ -542,7 +543,6 @@ krb5_cc_set_default_name(krb5_context context, const char *name)
}
}
if (p == NULL) {
const krb5_cc_ops *ops = KRB5_DEFAULT_CCTYPE;
e = krb5_config_get_string(context, NULL, "libdefaults",
"default_cc_type", NULL);
if (e) {
@@ -555,6 +555,27 @@ krb5_cc_set_default_name(krb5_context context, const char *name)
return KRB5_CC_UNKNOWN_TYPE;
}
}
}
#ifdef _WIN32
if (p == NULL) {
/*
* If the MSLSA ccache type has a principal name,
* use it as the default.
*/
krb5_ccache id;
ret = krb5_cc_resolve(context, "MSLSA:", &id);
if (ret == 0) {
krb5_principal princ;
ret = krb5_cc_get_principal(context, id, &princ);
if (ret == 0) {
krb5_free_principal(context, princ);
p = strdup("MSLSA:");
}
krb5_cc_close(context, id);
}
}
#endif
if (p == NULL) {
ret = (*ops->get_default_name)(context, &p);
if (ret)
return ret;
@@ -562,12 +583,11 @@ krb5_cc_set_default_name(krb5_context context, const char *name)
context->default_cc_name_set = 0;
} else {
p = strdup(name);
if (p == NULL)
return krb5_enomem(context);
context->default_cc_name_set = 1;
}
if (p == NULL)
return krb5_enomem(context);
filepath = (strncmp("FILE:", p, 5) == 0
|| strncmp("DIR:", p, 4) == 0
|| strncmp("SCC:", p, 4) == 0);