Index: source/nsswitch/winbindd.c =================================================================== --- source/nsswitch/winbindd.c (revision 9268) +++ source/nsswitch/winbindd.c (revision 9334) @@ -27,7 +27,6 @@ #include "winbindd.h" BOOL opt_nocache = False; -BOOL opt_dual_daemon = True; static BOOL interactive = False; extern BOOL override_logfile; @@ -139,12 +138,6 @@ static void flush_caches(void) { -#if 0 - /* Clear cached user and group enumation info */ - if (!opt_dual_daemon) /* Until we have coherent cache flush. */ - wcache_flush_cache(); -#endif - /* We need to invalidate cached user list entries on a SIGHUP otherwise cached access denied errors due to restrict anonymous hang around until the sequence number changes. */ @@ -569,7 +562,7 @@ } if (*(uint32 *)(&state->request) != sizeof(state->request)) { - DEBUG(0,("process_loop: Invalid request size received: %d\n", + DEBUG(0,("request_len_recv: Invalid request size received: %d\n", *(uint32 *)(&state->request))); state->finished = True; return; @@ -692,30 +685,6 @@ return False; } -/* Process a complete received packet from a client */ - -void winbind_process_packet(struct winbindd_cli_state *state) -{ - /* Process request */ - - /* Ensure null termination of entire request */ - state->request.null_term = '\0'; - - state->pid = state->request.pid; - - process_request(state); - - /* Update client state */ - - state->read_buf_len = 0; - state->write_buf_len = sizeof(struct winbindd_response); - - /* we might need to send it to the dual daemon */ - if (opt_dual_daemon) { - dual_send_request(state); - } -} - /* Process incoming clients on listen_sock. We use a tricky non-blocking, non-forking, non-threaded model which allows us to handle many simultaneous connections while remaining impervious to many denial of @@ -764,10 +733,6 @@ timeout.tv_sec = WINBINDD_ESTABLISH_LOOP; timeout.tv_usec = 0; - if (opt_dual_daemon) { - maxfd = dual_select_setup(&w_fds, maxfd); - } - /* Set up client readers and writers */ state = winbindd_client_list(); @@ -811,12 +776,6 @@ exit(1); } - /* Create a new connection if listen_sock readable */ - - if (opt_dual_daemon) { - dual_select(&w_fds); - } - ev = fd_events; while (ev != NULL) { struct fd_event *next = ev->next; @@ -917,7 +876,6 @@ { "stdout", 'S', POPT_ARG_VAL, &log_stdout, True, "Log to stdout" }, { "foreground", 'F', POPT_ARG_VAL, &Fork, False, "Daemon in foreground mode" }, { "interactive", 'i', POPT_ARG_NONE, NULL, 'i', "Interactive mode" }, - { "single-daemon", 'Y', POPT_ARG_VAL, &opt_dual_daemon, False, "Single daemon mode" }, { "no-caching", 'n', POPT_ARG_VAL, &opt_nocache, True, "Disable caching" }, POPT_COMMON_SAMBA POPT_TABLEEND @@ -1048,10 +1006,6 @@ setpgid( (pid_t)0, (pid_t)0); #endif - if (opt_dual_daemon) { - do_dual_daemon(); - } - /* Initialise messaging system */ if (!message_init()) { Index: source/nsswitch/winbindd_dual.c =================================================================== --- source/nsswitch/winbindd_dual.c (revision 9268) +++ source/nsswitch/winbindd_dual.c (revision 9334) @@ -36,22 +36,6 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_WINBIND -extern BOOL opt_dual_daemon; -BOOL background_process = False; -int dual_daemon_pipe = -1; - - -/* a list of requests ready to be sent to the dual daemon */ -struct dual_list { - struct dual_list *next; - char *data; - int length; - int offset; -}; - -static struct dual_list *dual_list; -static struct dual_list *dual_list_end; - /* Read some data from a client connection */ static void dual_client_read(struct winbindd_cli_state *state) @@ -86,167 +70,6 @@ } /* - setup a select() including the dual daemon pipe - */ -int dual_select_setup(fd_set *fds, int maxfd) -{ - if (dual_daemon_pipe == -1 || - !dual_list) { - return maxfd; - } - - FD_SET(dual_daemon_pipe, fds); - if (dual_daemon_pipe > maxfd) { - maxfd = dual_daemon_pipe; - } - return maxfd; -} - - -/* - a hook called from the main winbindd select() loop to handle writes - to the dual daemon pipe -*/ -void dual_select(fd_set *fds) -{ - int n; - - if (dual_daemon_pipe == -1 || - !dual_list || - !FD_ISSET(dual_daemon_pipe, fds)) { - return; - } - - n = sys_write(dual_daemon_pipe, - &dual_list->data[dual_list->offset], - dual_list->length - dual_list->offset); - - if (n <= 0) { - /* the pipe is dead! fall back to normal operation */ - dual_daemon_pipe = -1; - return; - } - - dual_list->offset += n; - - if (dual_list->offset == dual_list->length) { - struct dual_list *next; - next = dual_list->next; - free(dual_list->data); - free(dual_list); - dual_list = next; - if (!dual_list) { - dual_list_end = NULL; - } - } -} - -/* - send a request to the background daemon - this is called for stale cached entries -*/ -void dual_send_request(struct winbindd_cli_state *state) -{ - struct dual_list *list; - - if (!background_process) return; - - list = SMB_MALLOC_P(struct dual_list); - if (!list) return; - - list->next = NULL; - list->data = memdup(&state->request, sizeof(state->request)); - list->length = sizeof(state->request); - list->offset = 0; - - if (!dual_list_end) { - dual_list = list; - dual_list_end = list; - } else { - dual_list_end->next = list; - dual_list_end = list; - } - - background_process = False; -} - - -/* -the main dual daemon -*/ -void do_dual_daemon(void) -{ - int fdpair[2]; - struct winbindd_cli_state state; - - if (pipe(fdpair) != 0) { - return; - } - - ZERO_STRUCT(state); - state.pid = getpid(); - - dual_daemon_pipe = fdpair[1]; - state.sock = fdpair[0]; - - if (sys_fork() != 0) { - close(fdpair[0]); - return; - } - close(fdpair[1]); - - /* tdb needs special fork handling */ - if (tdb_reopen_all() == -1) { - DEBUG(0,("tdb_reopen_all failed.\n")); - _exit(0); - } - - dual_daemon_pipe = -1; - opt_dual_daemon = False; - - while (1) { - /* free up any talloc memory */ - lp_talloc_free(); - main_loop_talloc_free(); - - /* fetch a request from the main daemon */ - dual_client_read(&state); - - if (state.finished) { - /* we lost contact with our parent */ - exit(0); - } - - /* process full rquests */ - if (state.read_buf_len == sizeof(state.request)) { - DEBUG(4,("dual daemon request %d\n", (int)state.request.cmd)); - - /* special handling for the stateful requests */ - switch (state.request.cmd) { - case WINBINDD_GETPWENT: - winbindd_setpwent(&state); - break; - - case WINBINDD_GETGRENT: - case WINBINDD_GETGRLST: - winbindd_setgrent(&state); - break; - default: - break; - } - - winbind_process_packet(&state); - SAFE_FREE(state.response.extra_data); - - free_getent_state(state.getpwent_state); - free_getent_state(state.getgrent_state); - state.getpwent_state = NULL; - state.getgrent_state = NULL; - } - } -} - -/* * Machinery for async requests sent to children. You set up a * winbindd_request, select a child to query, and issue a async_request * call. When the request is completed, the callback function you specified is @@ -645,9 +468,6 @@ reopen_logs(); } - dual_daemon_pipe = -1; - opt_dual_daemon = False; - while (1) { /* free up any talloc memory */ lp_talloc_free(); Index: source/nsswitch/winbindd_cache.c =================================================================== --- source/nsswitch/winbindd_cache.c (revision 9268) +++ source/nsswitch/winbindd_cache.c (revision 9334) @@ -101,6 +101,11 @@ { struct winbind_cache *ret = wcache; + /* we have to know what type of domain we are dealing with first */ + + if ( !domain->initialized ) + set_dc_type_and_flags( domain ); + if (!domain->backend) { extern struct winbindd_methods reconnect_methods; switch (lp_security()) { @@ -365,9 +370,6 @@ /* important! make sure that we know if this is a native mode domain or not */ - if ( !domain->initialized ) - set_dc_type_and_flags( domain ); - status = domain->backend->sequence_number(domain, &domain->sequence_number); if (!NT_STATUS_IS_OK(status)) { @@ -467,21 +469,12 @@ centry->sequence_number = centry_uint32(centry); if (centry_expired(domain, kstr, centry)) { - extern BOOL opt_dual_daemon; - DEBUG(10,("wcache_fetch: entry %s expired for domain %s\n", kstr, domain->name )); - if (opt_dual_daemon) { - extern BOOL background_process; - background_process = True; - DEBUG(10,("wcache_fetch: background processing expired entry %s for domain %s\n", - kstr, domain->name )); - } else { - centry_free(centry); - free(kstr); - return NULL; - } + centry_free(centry); + free(kstr); + return NULL; } DEBUG(10,("wcache_fetch: returning entry %s for domain %s\n",