Use start_realm in cc lifetime
This commit is contained in:

committed by
Nicolas Williams

parent
f93947672d
commit
f973a9f397
@@ -1697,6 +1697,8 @@ krb5_cc_set_friendly_name(krb5_context context,
|
|||||||
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
|
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
|
||||||
krb5_cc_get_lifetime(krb5_context context, krb5_ccache id, time_t *t)
|
krb5_cc_get_lifetime(krb5_context context, krb5_ccache id, time_t *t)
|
||||||
{
|
{
|
||||||
|
krb5_data config_start_realm;
|
||||||
|
char *start_realm;
|
||||||
krb5_cc_cursor cursor;
|
krb5_cc_cursor cursor;
|
||||||
krb5_error_code ret;
|
krb5_error_code ret;
|
||||||
krb5_creds cred;
|
krb5_creds cred;
|
||||||
@@ -1705,20 +1707,32 @@ krb5_cc_get_lifetime(krb5_context context, krb5_ccache id, time_t *t)
|
|||||||
*t = 0;
|
*t = 0;
|
||||||
now = time(NULL);
|
now = time(NULL);
|
||||||
|
|
||||||
|
ret = krb5_cc_get_config(context, id, NULL, "start_realm", &config_start_realm);
|
||||||
|
if (ret == 0) {
|
||||||
|
start_realm = strndup(config_start_realm.data, config_start_realm.length);
|
||||||
|
krb5_data_free(&config_start_realm);
|
||||||
|
} else {
|
||||||
|
krb5_principal client;
|
||||||
|
|
||||||
|
ret = krb5_cc_get_principal(context, id, &client);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
start_realm = strdup(krb5_principal_get_realm(context, client));
|
||||||
|
krb5_free_principal(context, client);
|
||||||
|
}
|
||||||
|
if (start_realm == NULL)
|
||||||
|
return krb5_enomem(context);
|
||||||
|
|
||||||
ret = krb5_cc_start_seq_get(context, id, &cursor);
|
ret = krb5_cc_start_seq_get(context, id, &cursor);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
while ((ret = krb5_cc_next_cred(context, id, &cursor, &cred)) == 0) {
|
while ((ret = krb5_cc_next_cred(context, id, &cursor, &cred)) == 0) {
|
||||||
/**
|
/**
|
||||||
* If we find a krbtgt in the cache, use that as the lifespan.
|
* If we find the start krbtgt in the cache, use that as the lifespan.
|
||||||
*/
|
*/
|
||||||
/*
|
if (krb5_principal_is_root_krbtgt(context, cred.server) &&
|
||||||
* FIXME We should try to find the start_realm cc config and
|
strcmp(cred.server->realm, start_realm) == 0) {
|
||||||
* look for root TGTs for that realm instead of any random
|
|
||||||
* (first) root TGT.
|
|
||||||
*/
|
|
||||||
if (krb5_principal_is_root_krbtgt(context, cred.server)) {
|
|
||||||
if (now < cred.times.endtime)
|
if (now < cred.times.endtime)
|
||||||
endtime = cred.times.endtime;
|
endtime = cred.times.endtime;
|
||||||
krb5_free_cred_contents(context, &cred);
|
krb5_free_cred_contents(context, &cred);
|
||||||
@@ -1740,6 +1754,7 @@ krb5_cc_get_lifetime(krb5_context context, krb5_ccache id, time_t *t)
|
|||||||
endtime = cred.times.endtime;
|
endtime = cred.times.endtime;
|
||||||
krb5_free_cred_contents(context, &cred);
|
krb5_free_cred_contents(context, &cred);
|
||||||
}
|
}
|
||||||
|
free(start_realm);
|
||||||
|
|
||||||
/* if we found an endtime use that */
|
/* if we found an endtime use that */
|
||||||
if (endtime) {
|
if (endtime) {
|
||||||
|
Reference in New Issue
Block a user