winbindd: Free is_parent before we terminate
[samba.git] / source3 / winbindd / winbindd.c
index fc7c1691873f76195531bcd4f004a7e45ed6ef8a..6e3df1f18a8ecaedb041270ce64452a887e04afe 100644 (file)
@@ -233,11 +233,14 @@ static void winbindd_sig_term_handler(struct tevent_context *ev,
                                      void *siginfo,
                                      void *private_data)
 {
-       bool *is_parent = talloc_get_type_abort(private_data, bool);
+       bool *p = talloc_get_type_abort(private_data, bool);
+       bool is_parent = *p;
+
+       TALLOC_FREE(p);
 
        DEBUG(0,("Got sig[%d] terminate (is_parent=%d)\n",
-                signum, (int)*is_parent));
-       terminate(*is_parent);
+                signum, is_parent));
+       terminate(is_parent);
 }
 
 /*
@@ -508,6 +511,8 @@ static void winbind_msg_validate_cache(struct messaging_context *msg_ctx,
        /* install default SIGCHLD handler: validation code uses fork/waitpid */
        CatchSignal(SIGCHLD, SIG_DFL);
 
+       setproctitle("validate cache child");
+
        ret = (uint8_t)winbindd_validate_cache_nobackup();
        DEBUG(10, ("winbindd_msg_validata_cache: got return value %d\n", ret));
        messaging_send_buf(msg_ctx, server_id, MSG_WINBIND_VALIDATE_CACHE, &ret,
@@ -1278,6 +1283,7 @@ bool winbindd_use_cache(void)
 static void winbindd_register_handlers(struct messaging_context *msg_ctx,
                                       bool foreground)
 {
+       bool scan_trusts = true;
        NTSTATUS status;
        /* Setup signal handlers */
 
@@ -1360,7 +1366,19 @@ static void winbindd_register_handlers(struct messaging_context *msg_ctx,
        smb_nscd_flush_user_cache();
        smb_nscd_flush_group_cache();
 
-       if (lp_allow_trusted_domains()) {
+       if (!lp_winbind_scan_trusted_domains()) {
+               scan_trusts = false;
+       }
+
+       if (!lp_allow_trusted_domains()) {
+               scan_trusts = false;
+       }
+
+       if (IS_DC) {
+               scan_trusts = false;
+       }
+
+       if (scan_trusts) {
                if (tevent_add_timer(server_event_context(), NULL, timeval_zero(),
                              rescan_trusted_domains, NULL) == NULL) {
                        DEBUG(0, ("Could not trigger rescan_trusted_domains()\n"));
@@ -1491,6 +1509,8 @@ int main(int argc, const char **argv)
        NTSTATUS status;
        bool ok;
 
+       setproctitle_init(argc, discard_const(argv), environ);
+
        /*
         * Do this before any other talloc operation
         */
@@ -1773,6 +1793,8 @@ int main(int argc, const char **argv)
                daemon_ready("winbindd");
        }
 
+       gpupdate_init();
+
        /* Loop waiting for requests */
        while (1) {
                frame = talloc_stackframe();