summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/winbindd/winbindd.c12
-rw-r--r--source3/winbindd/winbindd_proto.h3
-rw-r--r--source3/winbindd/winbindd_util.c31
3 files changed, 20 insertions, 26 deletions
diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c
index 65c52e4292..fd467e2f13 100644
--- a/source3/winbindd/winbindd.c
+++ b/source3/winbindd/winbindd.c
@@ -1014,6 +1014,7 @@ int main(int argc, char **argv, char **envp)
poptContext pc;
int opt;
TALLOC_CTX *frame = talloc_stackframe();
+ struct tevent_timer *te;
/* glibc (?) likes to print "User defined signal 1" and exit if a
SIGUSR[12] is received before a handler is installed */
@@ -1260,15 +1261,18 @@ int main(int argc, char **argv, char **envp)
exit(1);
}
+ te = tevent_add_timer(winbind_event_context(), NULL, timeval_zero(),
+ rescan_trusted_domains, NULL);
+ if (te == NULL) {
+ DEBUG(0, ("Could not trigger rescan_trusted_domains()\n"));
+ exit(1);
+ }
+
TALLOC_FREE(frame);
/* Loop waiting for requests */
while (1) {
frame = talloc_stackframe();
- /* refresh the trusted domain cache */
-
- rescan_trusted_domains();
-
process_loop();
TALLOC_FREE(frame);
diff --git a/source3/winbindd/winbindd_proto.h b/source3/winbindd/winbindd_proto.h
index ac0f71e148..35863e930e 100644
--- a/source3/winbindd/winbindd_proto.h
+++ b/source3/winbindd/winbindd_proto.h
@@ -506,7 +506,8 @@ void winbindd_list_users(struct winbindd_cli_state *state);
struct winbindd_domain *domain_list(void);
void free_domain_list(void);
-void rescan_trusted_domains( void );
+void rescan_trusted_domains(struct tevent_context *ev, struct tevent_timer *te,
+ struct timeval now, void *private_data);
enum winbindd_result winbindd_dual_init_connection(struct winbindd_domain *domain,
struct winbindd_cli_state *state);
bool init_domain_list(void);
diff --git a/source3/winbindd/winbindd_util.c b/source3/winbindd/winbindd_util.c
index 7aceca39c4..8302ec752b 100644
--- a/source3/winbindd/winbindd_util.c
+++ b/source3/winbindd/winbindd_util.c
@@ -45,14 +45,6 @@ extern struct winbindd_methods sam_passdb_methods;
static struct winbindd_domain *_domain_list = NULL;
-/**
- When was the last scan of trusted domains done?
-
- 0 == not ever
-*/
-
-static time_t last_trustdom_scan;
-
struct winbindd_domain *domain_list(void)
{
/* Initialise list */
@@ -535,19 +527,10 @@ static void rescan_forest_trusts( void )
(c) ask the a DC in any Win2003 trusted forests
*********************************************************************/
-void rescan_trusted_domains( void )
+void rescan_trusted_domains(struct tevent_context *ev, struct tevent_timer *te,
+ struct timeval now, void *private_data)
{
- time_t now = time(NULL);
-
- /* Check that we allow trusted domains at all */
- if (!lp_allow_trusted_domains())
- return;
-
- /* see if the time has come... */
-
- if ((now >= last_trustdom_scan) &&
- ((now-last_trustdom_scan) < WINBINDD_RESCAN_FREQ) )
- return;
+ TALLOC_FREE(te);
/* I use to clear the cache here and start over but that
caused problems in child processes that needed the
@@ -562,7 +545,13 @@ void rescan_trusted_domains( void )
add_trusted_domains( find_our_domain() );
- last_trustdom_scan = now;
+ te = tevent_add_timer(
+ ev, NULL, timeval_current_ofs(WINBINDD_RESCAN_FREQ, 0),
+ rescan_trusted_domains, NULL);
+ /*
+ * If te == NULL, there's not much we can do here. Don't fail, the
+ * only thing we miss is new trusted domains.
+ */
return;
}