diff options
Diffstat (limited to 'source3/winbindd')
-rw-r--r-- | source3/winbindd/winbindd_cm.c | 8 | ||||
-rw-r--r-- | source3/winbindd/winbindd_cred_cache.c | 50 | ||||
-rw-r--r-- | source3/winbindd/winbindd_proto.h | 1 |
3 files changed, 52 insertions, 7 deletions
diff --git a/source3/winbindd/winbindd_cm.c b/source3/winbindd/winbindd_cm.c index 8aaa850201..b2b7628873 100644 --- a/source3/winbindd/winbindd_cm.c +++ b/source3/winbindd/winbindd_cm.c @@ -403,8 +403,6 @@ void set_domain_offline(struct winbindd_domain *domain) static void set_domain_online(struct winbindd_domain *domain) { - struct timeval now; - DEBUG(10,("set_domain_online: called for domain %s\n", domain->name )); @@ -423,11 +421,7 @@ static void set_domain_online(struct winbindd_domain *domain) winbindd_set_locator_kdc_envs(domain); /* If we are waiting to get a krb5 ticket, trigger immediately. */ - GetTimeOfDay(&now); - set_event_dispatch_time(winbind_event_context(), - "krb5_ticket_gain_handler", now); - set_event_dispatch_time(winbind_event_context(), - "krb5_ticket_refresh_handler", now); + ccache_regain_all_now(); /* Ok, we're out of any startup mode now... */ domain->startup = False; diff --git a/source3/winbindd/winbindd_cred_cache.c b/source3/winbindd/winbindd_cred_cache.c index fcb3d033a6..c869544048 100644 --- a/source3/winbindd/winbindd_cred_cache.c +++ b/source3/winbindd/winbindd_cred_cache.c @@ -281,6 +281,9 @@ done: return; } + if (entry->refresh_time == 0) { + entry->refresh_time = new_start; + } entry->event = event_add_timed(winbind_event_context(), entry, timeval_set(new_start, 0), "krb5_ticket_refresh_handler", @@ -368,6 +371,7 @@ static void krb5_ticket_gain_handler(struct event_context *event_ctx, t = timeval_current_ofs(MAX(30, lp_winbind_cache_time()), 0); #endif + entry->refresh_time = 0; entry->event = event_add_timed(winbind_event_context(), entry, t, @@ -385,6 +389,9 @@ static void krb5_ticket_gain_handler(struct event_context *event_ctx, t = timeval_set(KRB5_EVENT_REFRESH_TIME(entry->refresh_time), 0); #endif + if (entry->refresh_time == 0) { + entry->refresh_time = t.tv_sec; + } entry->event = event_add_timed(winbind_event_context(), entry, t, @@ -396,6 +403,45 @@ static void krb5_ticket_gain_handler(struct event_context *event_ctx, #endif } +void ccache_regain_all_now(void) +{ + struct WINBINDD_CCACHE_ENTRY *cur; + struct timeval t = timeval_current(); + + for (cur = ccache_list; cur; cur = cur->next) { + struct timed_event *new_event; + + /* + * if refresh_time is 0, we know that the + * the event has the krb5_ticket_gain_handler + */ + if (cur->refresh_time == 0) { + new_event = event_add_timed(winbind_event_context(), + cur, + t, + "krb5_ticket_gain_handler", + krb5_ticket_gain_handler, + cur); + } else { + new_event = event_add_timed(winbind_event_context(), + cur, + t, + "krb5_ticket_refresh_handler", + krb5_ticket_refresh_handler, + cur); + } + + if (!new_event) { + continue; + } + + TALLOC_FREE(cur->event); + cur->event = new_event; + } + + return; +} + /**************************************************************** Check if an ccache entry exists. ****************************************************************/ @@ -594,6 +640,7 @@ NTSTATUS add_ccache_to_list(const char *princ_name, if (postponed_request) { t = timeval_current_ofs(MAX(30, lp_winbind_cache_time()), 0); + entry->refresh_time = 0; entry->event = event_add_timed(winbind_event_context(), entry, t, @@ -607,6 +654,9 @@ NTSTATUS add_ccache_to_list(const char *princ_name, #else t = timeval_set(KRB5_EVENT_REFRESH_TIME(ticket_end), 0); #endif + if (entry->refresh_time == 0) { + entry->refresh_time = t.tv_sec; + } entry->event = event_add_timed(winbind_event_context(), entry, t, diff --git a/source3/winbindd/winbindd_proto.h b/source3/winbindd/winbindd_proto.h index 8b0943423d..32f057ad61 100644 --- a/source3/winbindd/winbindd_proto.h +++ b/source3/winbindd/winbindd_proto.h @@ -244,6 +244,7 @@ bool ccache_entry_identical(const char *username, uid_t uid, const char *ccname); void ccache_remove_all_after_fork(void); +void ccache_regain_all_now(void); NTSTATUS add_ccache_to_list(const char *princ_name, const char *ccname, const char *service, |