(enviroment_changed): return non-zero if enviroment that will
determine default krb5cc name has changed. (krb5_cc_default_name): also check if cached value is uptodate. git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@21426 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -338,6 +338,35 @@ _krb5_expand_default_cc_name(krb5_context context, const char *str, char **res)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return non-zero if enviroment that will determine default krb5cc
|
||||||
|
* name has changed.
|
||||||
|
*/
|
||||||
|
|
||||||
|
static int
|
||||||
|
enviroment_changed(krb5_context context)
|
||||||
|
{
|
||||||
|
const char *e;
|
||||||
|
|
||||||
|
if(issuid())
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
e = getenv("KRB5CCNAME");
|
||||||
|
if (e == NULL) {
|
||||||
|
if (context->default_cc_name_env) {
|
||||||
|
free(context->default_cc_name_env);
|
||||||
|
context->default_cc_name_env = NULL;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (context->default_cc_name_env == NULL)
|
||||||
|
return 1;
|
||||||
|
if (strcmp(e, context->default_cc_name_env) != 0)
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set the default cc name for `context' to `name'.
|
* Set the default cc name for `context' to `name'.
|
||||||
*/
|
*/
|
||||||
@@ -353,8 +382,12 @@ krb5_cc_set_default_name(krb5_context context, const char *name)
|
|||||||
|
|
||||||
if(!issuid()) {
|
if(!issuid()) {
|
||||||
e = getenv("KRB5CCNAME");
|
e = getenv("KRB5CCNAME");
|
||||||
if (e)
|
if (e) {
|
||||||
p = strdup(e);
|
p = strdup(e);
|
||||||
|
if (context->default_cc_name_env)
|
||||||
|
free(context->default_cc_name_env);
|
||||||
|
context->default_cc_name_env = strdup(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (e == NULL) {
|
if (e == NULL) {
|
||||||
e = krb5_config_get_string(context, NULL, "libdefaults",
|
e = krb5_config_get_string(context, NULL, "libdefaults",
|
||||||
@@ -389,7 +422,7 @@ krb5_cc_set_default_name(krb5_context context, const char *name)
|
|||||||
const char* KRB5_LIB_FUNCTION
|
const char* KRB5_LIB_FUNCTION
|
||||||
krb5_cc_default_name(krb5_context context)
|
krb5_cc_default_name(krb5_context context)
|
||||||
{
|
{
|
||||||
if (context->default_cc_name == NULL)
|
if (context->default_cc_name == NULL || enviroment_changed(context))
|
||||||
krb5_cc_set_default_name(context, NULL);
|
krb5_cc_set_default_name(context, NULL);
|
||||||
|
|
||||||
return context->default_cc_name;
|
return context->default_cc_name;
|
||||||
|
Reference in New Issue
Block a user