[SCM] Samba Shared Repository - branch v3-3-test updated - release-3-2-0pre2-4788-ge1f794a

Jeremy Allison jra at samba.org
Tue Jan 6 04:54:57 GMT 2009


The branch, v3-3-test has been updated
       via  e1f794a246feab1f100abd961e0e576f0b85453a (commit)
      from  d605077effaf265ea4df66fcaf9007004db61acc (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-3-test


- Log -----------------------------------------------------------------
commit e1f794a246feab1f100abd961e0e576f0b85453a
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Jan 5 20:54:03 2009 -0800

    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

-----------------------------------------------------------------------

Summary of changes:
 source/winbindd/winbindd_cm.c         |    8 +----
 source/winbindd/winbindd_cred_cache.c |   50 +++++++++++++++++++++++++++++++++
 source/winbindd/winbindd_proto.h      |    1 +
 3 files changed, 52 insertions(+), 7 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/winbindd/winbindd_cm.c b/source/winbindd/winbindd_cm.c
index 1e7ae2f..c22beb4 100644
--- a/source/winbindd/winbindd_cm.c
+++ b/source/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/source/winbindd/winbindd_cred_cache.c b/source/winbindd/winbindd_cred_cache.c
index fcb3d03..c869544 100644
--- a/source/winbindd/winbindd_cred_cache.c
+++ b/source/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/source/winbindd/winbindd_proto.h b/source/winbindd/winbindd_proto.h
index 5629733..c5ffbac 100644
--- a/source/winbindd/winbindd_proto.h
+++ b/source/winbindd/winbindd_proto.h
@@ -225,6 +225,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,


-- 
Samba Shared Repository


More information about the samba-cvs mailing list