summaryrefslogtreecommitdiffstats
path: root/source3/winbindd/winbindd_cred_cache.c
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2008-12-30 09:56:36 +0100
committerStefan Metzmacher <metze@samba.org>2009-01-05 15:07:33 +0100
commit492d0e351760458e06452ce948d33f346b3fbb52 (patch)
tree46c56ef638fb65cd0e6393046684aed3e0f75c58 /source3/winbindd/winbindd_cred_cache.c
parent94c4376b497445435edc3e02292b1326a05d1d1e (diff)
downloadsamba-492d0e351760458e06452ce948d33f346b3fbb52.tar.gz
samba-492d0e351760458e06452ce948d33f346b3fbb52.tar.xz
samba-492d0e351760458e06452ce948d33f346b3fbb52.zip
s3:winbindd: regain tickets for all ccache entries, when we go online
set_event_dispatch_time() is stupid by design and only handles the first event with a given name. metze
Diffstat (limited to 'source3/winbindd/winbindd_cred_cache.c')
-rw-r--r--source3/winbindd/winbindd_cred_cache.c50
1 files changed, 50 insertions, 0 deletions
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,