r23040: Activate the winbindd cache validation code in the
[sfrench/samba-autobuild/.git] / source / nsswitch / winbindd.c
index dc62a8563a831361d7262304a2ba7fcf8a79682e..790d59c08656bf6a7c81c82ae1261cd9eee685d5 100644 (file)
@@ -7,6 +7,7 @@
    Copyright (C) Andrew Tridgell 2002
    Copyright (C) Jelmer Vernooij 2003
    Copyright (C) Volker Lendecke 2004
+   Copyright (C) James Peach 2007
    
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
 #include "includes.h"
 #include "winbindd.h"
 
+#undef DBGC_CLASS
+#define DBGC_CLASS DBGC_WINBIND
+
 BOOL opt_nocache = False;
-static BOOL interactive = False;
 
 extern BOOL override_logfile;
 
+struct event_context *winbind_event_context(void)
+{
+       static struct event_context *ctx;
+
+       if (!ctx && !(ctx = event_context_init(NULL))) {
+               smb_panic("Could not init winbind event context\n");
+       }
+       return ctx;
+}
+
+struct messaging_context *winbind_messaging_context(void)
+{
+       static struct messaging_context *ctx;
+
+       if (!ctx && !(ctx = messaging_init(NULL, server_id_self(),
+                                          winbind_event_context()))) {
+               smb_panic("Could not init winbind messaging context\n");
+       }
+       return ctx;
+}
+
 /* Reload configuration */
 
 static BOOL reload_services_file(void)
@@ -56,55 +80,13 @@ static BOOL reload_services_file(void)
 }
 
 
-#if DUMP_CORE
-
-/**************************************************************************** **
- Prepare to dump a core file - carefully!
- **************************************************************************** */
-
-static BOOL dump_core(void)
-{
-       char *p;
-       pstring dname;
-       pstrcpy( dname, lp_logfile() );
-       if ((p=strrchr(dname,'/')))
-               *p=0;
-       pstrcat( dname, "/corefiles" );
-       mkdir( dname, 0700 );
-       sys_chown( dname, getuid(), getgid() );
-       chmod( dname, 0700 );
-       if ( chdir(dname) )
-               return( False );
-       umask( ~(0700) );
-#ifdef HAVE_GETRLIMIT
-#ifdef RLIMIT_CORE
-       {
-               struct rlimit rlp;
-               getrlimit( RLIMIT_CORE, &rlp );
-               rlp.rlim_cur = MAX( 4*1024*1024, rlp.rlim_cur );
-               setrlimit( RLIMIT_CORE, &rlp );
-               getrlimit( RLIMIT_CORE, &rlp );
-               DEBUG( 3, ( "Core limits now %d %d\n", (int)rlp.rlim_cur, (int)rlp.rlim_max ) );
-       }
-#endif
-#endif
-       DEBUG(0,("Dumping core in %s\n",dname));
-       abort();
-       return( True );
-} /* dump_core */
-#endif
-
 /**************************************************************************** **
  Handle a fault..
  **************************************************************************** */
 
 static void fault_quit(void)
 {
-#if DUMP_CORE
        dump_core();
-#endif
 }
 
 static void winbindd_status(void)
@@ -148,14 +130,11 @@ static void flush_caches(void)
 
 static void terminate(void)
 {
-       pstring path;
 
+       winbindd_release_sockets();
        idmap_close();
        
-       /* Remove socket file */
-       pstr_sprintf(path, "%s/%s", 
-                WINBINDD_SOCKET_DIR, WINBINDD_SOCKET_NAME);
-       unlink(path);
+       trustdom_cache_shutdown();
 
 #if 0
        if (interactive) {
@@ -203,7 +182,11 @@ static void sigchld_handler(int signum)
 }
 
 /* React on 'smbcontrol winbindd reload-config' in the same way as on SIGHUP*/
-static void msg_reload_services(int msg_type, struct process_id src, void *buf, size_t len)
+static void msg_reload_services(struct messaging_context *msg,
+                               void *private_data,
+                               uint32_t msg_type,
+                               struct server_id server_id,
+                               DATA_BLOB *data)
 {
         /* Flush various caches */
        flush_caches();
@@ -211,7 +194,11 @@ static void msg_reload_services(int msg_type, struct process_id src, void *buf,
 }
 
 /* React on 'smbcontrol winbindd shutdown' in the same way as on SIGTERM*/
-static void msg_shutdown(int msg_type, struct process_id src, void *buf, size_t len)
+static void msg_shutdown(struct messaging_context *msg,
+                        void *private_data,
+                        uint32_t msg_type,
+                        struct server_id server_id,
+                        DATA_BLOB *data)
 {
        do_sigterm = True;
 }
@@ -251,6 +238,7 @@ static struct winbindd_dispatch_table {
        { WINBINDD_PAM_AUTH_CRAP, winbindd_pam_auth_crap, "AUTH_CRAP" },
        { WINBINDD_PAM_CHAUTHTOK, winbindd_pam_chauthtok, "CHAUTHTOK" },
        { WINBINDD_PAM_LOGOFF, winbindd_pam_logoff, "PAM_LOGOFF" },
+       { WINBINDD_PAM_CHNG_PSWD_AUTH_CRAP, winbindd_pam_chng_pswd_auth_crap, "CHNG_PSWD_AUTH_CRAP" },
 
        /* Enumeration functions */
 
@@ -264,6 +252,7 @@ static struct winbindd_dispatch_table {
 
        { WINBINDD_LOOKUPSID, winbindd_lookupsid, "LOOKUPSID" },
        { WINBINDD_LOOKUPNAME, winbindd_lookupname, "LOOKUPNAME" },
+       { WINBINDD_LOOKUPRIDS, winbindd_lookuprids, "LOOKUPRIDS" },
 
        /* Lookup related functions */
 
@@ -271,11 +260,18 @@ static struct winbindd_dispatch_table {
        { WINBINDD_SID_TO_GID, winbindd_sid_to_gid, "SID_TO_GID" },
        { WINBINDD_UID_TO_SID, winbindd_uid_to_sid, "UID_TO_SID" },
        { WINBINDD_GID_TO_SID, winbindd_gid_to_sid, "GID_TO_SID" },
+#if 0   /* DISABLED until we fix the interface in Samba 3.0.26 --jerry */
+       { WINBINDD_SIDS_TO_XIDS, winbindd_sids_to_unixids, "SIDS_TO_XIDS" },
+#endif  /* end DISABLED */
        { WINBINDD_ALLOCATE_UID, winbindd_allocate_uid, "ALLOCATE_UID" },
-       { WINBINDD_ALLOCATE_GID, winbindd_allocate_uid, "ALLOCATE_GID" },
+       { WINBINDD_ALLOCATE_GID, winbindd_allocate_gid, "ALLOCATE_GID" },
+       { WINBINDD_SET_MAPPING, winbindd_set_mapping, "SET_MAPPING" },
+       { WINBINDD_SET_HWM, winbindd_set_hwm, "SET_HWMS" },
 
        /* Miscellaneous */
 
+       { WINBINDD_DUMP_MAPS, winbindd_dump_maps, "DUMP_MAPS" },
+
        { WINBINDD_CHECK_MACHACC, winbindd_check_machine_acct, "CHECK_MACHACC" },
        { WINBINDD_PING, winbindd_ping, "PING" },
        { WINBINDD_INFO, winbindd_info, "INFO" },
@@ -288,6 +284,9 @@ static struct winbindd_dispatch_table {
          "WINBINDD_PRIV_PIPE_DIR" },
        { WINBINDD_GETDCNAME, winbindd_getdcname, "GETDCNAME" },
 
+       /* Credential cache access */
+       { WINBINDD_CCACHE_NTLMAUTH, winbindd_ccache_ntlm_auth, "NTLMAUTH" },
+
        /* WINS functions */
 
        { WINBINDD_WINS_BYNAME, winbindd_wins_byname, "WINS_BYNAME" },
@@ -305,7 +304,7 @@ static void process_request(struct winbindd_cli_state *state)
        /* Free response data - we may be interrupted and receive another
           command before being able to send this data off. */
 
-       SAFE_FREE(state->response.extra_data);  
+       SAFE_FREE(state->response.extra_data.data);  
 
        ZERO_STRUCT(state->response);
 
@@ -475,8 +474,8 @@ static void response_extra_sent(void *private_data, BOOL success)
                return;
        }
 
-       SAFE_FREE(state->request.extra_data);
-       SAFE_FREE(state->response.extra_data);
+       SAFE_FREE(state->request.extra_data.data);
+       SAFE_FREE(state->response.extra_data.data);
 
        setup_async_read(&state->fd_event, &state->request, sizeof(uint32),
                         request_len_recv, state);
@@ -503,7 +502,7 @@ static void response_main_sent(void *private_data, BOOL success)
                return;
        }
 
-       setup_async_write(&state->fd_event, state->response.extra_data,
+       setup_async_write(&state->fd_event, state->response.extra_data.data,
                          state->response.length - sizeof(state->response),
                          response_extra_sent, state);
 }
@@ -572,7 +571,7 @@ static void request_main_recv(void *private_data, BOOL success)
        }
 
        if (state->request.extra_len == 0) {
-               state->request.extra_data = NULL;
+               state->request.extra_data.data = NULL;
                request_recv(state, True);
                return;
        }
@@ -581,24 +580,24 @@ static void request_main_recv(void *private_data, BOOL success)
            (state->request.extra_len > WINBINDD_MAX_EXTRA_DATA)) {
                DEBUG(3, ("Got request with %d bytes extra data on "
                          "unprivileged socket\n", (int)state->request.extra_len));
-               state->request.extra_data = NULL;
+               state->request.extra_data.data = NULL;
                state->finished = True;
                return;
        }
 
-       state->request.extra_data =
+       state->request.extra_data.data =
                SMB_MALLOC_ARRAY(char, state->request.extra_len + 1);
 
-       if (state->request.extra_data == NULL) {
+       if (state->request.extra_data.data == NULL) {
                DEBUG(0, ("malloc failed\n"));
                state->finished = True;
                return;
        }
 
        /* Ensure null termination */
-       state->request.extra_data[state->request.extra_len] = '\0';
+       state->request.extra_data.data[state->request.extra_len] = '\0';
 
-       setup_async_read(&state->fd_event, state->request.extra_data,
+       setup_async_read(&state->fd_event, state->request.extra_data.data,
                         state->request.extra_len, request_recv, state);
 }
 
@@ -639,8 +638,10 @@ static void new_connection(int listen_sock, BOOL privileged)
        
        /* Create new connection structure */
        
-       if ((state = TALLOC_ZERO_P(NULL, struct winbindd_cli_state)) == NULL)
+       if ((state = TALLOC_ZERO_P(NULL, struct winbindd_cli_state)) == NULL) {
+               close(sock);
                return;
+       }
        
        state->sock = sock;
 
@@ -666,37 +667,37 @@ static void remove_client(struct winbindd_cli_state *state)
 {
        /* It's a dead client - hold a funeral */
        
-       if (state != NULL) {
+       if (state == NULL) {
+               return;
+       }
                
-               /* Close socket */
+       /* Close socket */
                
-               close(state->sock);
+       close(state->sock);
                
-               /* Free any getent state */
+       /* Free any getent state */
                
-               free_getent_state(state->getpwent_state);
-               free_getent_state(state->getgrent_state);
+       free_getent_state(state->getpwent_state);
+       free_getent_state(state->getgrent_state);
                
-               /* We may have some extra data that was not freed if the
-                  client was killed unexpectedly */
+       /* We may have some extra data that was not freed if the client was
+          killed unexpectedly */
 
-               SAFE_FREE(state->response.extra_data);
+       SAFE_FREE(state->response.extra_data.data);
 
-               if (state->mem_ctx != NULL) {
-                       talloc_destroy(state->mem_ctx);
-                       state->mem_ctx = NULL;
-               }
+       if (state->mem_ctx != NULL) {
+               talloc_destroy(state->mem_ctx);
+               state->mem_ctx = NULL;
+       }
 
-               remove_fd_event(&state->fd_event);
+       remove_fd_event(&state->fd_event);
                
-               /* Remove from list and free */
+       /* Remove from list and free */
                
-               winbindd_remove_client(state);
-               TALLOC_FREE(state);
-       }
+       winbindd_remove_client(state);
+       TALLOC_FREE(state);
 }
 
-
 /* Shutdown client connection which has been idle for the longest time */
 
 static BOOL remove_idle_client(void)
@@ -731,13 +732,13 @@ static BOOL remove_idle_client(void)
    simultaneous connections while remaining impervious to many denial of
    service attacks. */
 
-static void process_loop(void)
+static int process_loop(int listen_sock, int listen_priv_sock)
 {
        struct winbindd_cli_state *state;
        struct fd_event *ev;
        fd_set r_fds, w_fds;
-       int maxfd, listen_sock, listen_priv_sock, selret;
-       struct timeval timeout;
+       int maxfd, selret;
+       struct timeval timeout, ev_timeout;
 
        /* We'll be doing this a lot */
 
@@ -745,8 +746,10 @@ static void process_loop(void)
 
        message_dispatch();
 
+       run_events(winbind_event_context(), 0, NULL, NULL);
+
        /* refresh the trusted domain cache */
-                  
+
        rescan_trusted_domains();
 
        /* Free up temporary memory */
@@ -756,14 +759,6 @@ static void process_loop(void)
 
        /* Initialise fd lists for select() */
 
-       listen_sock = open_winbindd_socket();
-       listen_priv_sock = open_winbindd_priv_socket();
-
-       if (listen_sock == -1 || listen_priv_sock == -1) {
-               perror("open_winbind_socket");
-               exit(1);
-       }
-
        maxfd = MAX(listen_sock, listen_priv_sock);
 
        FD_ZERO(&r_fds);
@@ -774,6 +769,11 @@ static void process_loop(void)
        timeout.tv_sec = WINBINDD_ESTABLISH_LOOP;
        timeout.tv_usec = 0;
 
+       /* Check for any event timeouts. */
+       if (get_timed_events_timeout(winbind_event_context(), &ev_timeout)) {
+               timeout = timeval_min(&timeout, &ev_timeout);
+       }
+
        /* Set up client readers and writers */
 
        state = winbindd_client_list();
@@ -806,10 +806,14 @@ static void process_loop(void)
         
        selret = sys_select(maxfd + 1, &r_fds, &w_fds, NULL, &timeout);
 
-       if (selret == 0)
+       if (selret == 0) {
                goto no_fds_ready;
+       }
 
-       if ((selret == -1 && errno != EINTR) || selret == 0) {
+       if (selret == -1) {
+               if (errno == EINTR) {
+                       goto no_fds_ready;
+               }
 
                /* Select error, something is badly wrong */
 
@@ -817,6 +821,8 @@ static void process_loop(void)
                exit(1);
        }
 
+       /* selret > 0 */
+
        ev = fd_events;
        while (ev != NULL) {
                struct fd_event *next = ev->next;
@@ -883,7 +889,9 @@ static void process_loop(void)
 
                DEBUG(3, ("got SIGHUP\n"));
 
-               msg_reload_services(MSG_SMB_CONF_UPDATED, pid_to_procid(0), NULL, 0);
+               flush_caches();
+               reload_services_file();
+
                do_sighup = False;
        }
 
@@ -901,22 +909,73 @@ static void process_loop(void)
                        winbind_child_died(pid);
                }
        }
+
+
+       return winbindd_num_clients();
 }
 
-/* Main function */
+static void winbindd_process_loop(enum smb_server_mode server_mode)
+{
+       int idle_timeout_sec;
+       struct timeval starttime;
+       int listen_public, listen_priv;
+
+       errno = 0;
+       if (!winbindd_init_sockets(&listen_public, &listen_priv,
+                                   &idle_timeout_sec)) {
+               terminate();
+       }
+
+       starttime = timeval_current();
+
+       if (listen_public == -1 || listen_priv == -1) {
+               DEBUG(0, ("failed to open winbindd pipes: %s\n",
+                           errno ? strerror(errno) : "unknown error"));
+               terminate();
+       }
+
+       for (;;) {
+               int clients = process_loop(listen_public, listen_priv);
+
+               /* Don't bother figuring out the idle time if we won't be
+                * timing out anyway.
+                */
+               if (idle_timeout_sec < 0) {
+                       continue;
+               }
+
+               if (clients == 0 && server_mode == SERVER_MODE_FOREGROUND) {
+                       struct timeval now;
+
+                       now = timeval_current();
+                       if (timeval_elapsed2(&starttime, &now) >
+                               (double)idle_timeout_sec) {
+                               DEBUG(0, ("idle for %d secs, exitting\n",
+                                           idle_timeout_sec));
+                               terminate();
+                       }
+               } else {
+                       starttime = timeval_current();
+               }
+       }
+}
 
-struct winbindd_state server_state;   /* Server state information */
+/* Main function */
 
-int main(int argc, char **argv)
+int main(int argc, char **argv, char **envp)
 {
        pstring logfile;
-       static BOOL Fork = True;
-       static BOOL log_stdout = False;
+       BOOL log_stdout = False;
+       BOOL no_process_group = False;
+
+       enum smb_server_mode server_mode = SERVER_MODE_DAEMON;
+
        struct poptOption long_options[] = {
                POPT_AUTOHELP
                { "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" },
+               { "foreground", 'F', POPT_ARG_VAL, &server_mode, SERVER_MODE_FOREGROUND, "Daemon in foreground mode" },
+               { "no-process-group", 0, POPT_ARG_VAL, &no_process_group, True, "Don't create a new process group" },
+               { "interactive", 'i', POPT_ARG_VAL, &server_mode, SERVER_MODE_INTERACTIVE, "Interactive mode" },
                { "no-caching", 'n', POPT_ARG_VAL, &opt_nocache, True, "Disable caching" },
                POPT_COMMON_SAMBA
                POPT_TABLEEND
@@ -931,6 +990,7 @@ int main(int argc, char **argv)
        CatchSignal(SIGUSR2, SIG_IGN);
 
        fault_setup((void (*)(void *))fault_quit );
+       dump_core_setup("winbindd");
 
        load_case_tables();
 
@@ -943,27 +1003,27 @@ int main(int argc, char **argv)
        /* Set environment variable so we don't recursively call ourselves.
           This may also be useful interactively. */
 
-       setenv(WINBINDD_DONT_ENV, "1", 1);
+       if ( !winbind_off() ) {
+               DEBUG(0,("Failed to disable recusive winbindd calls.  Exiting.\n"));
+               exit(1);
+       }
 
        /* Initialise samba/rpc client stuff */
 
        pc = poptGetContext("winbindd", argc, (const char **)argv, long_options,
                                                POPT_CONTEXT_KEEP_FIRST);
 
-       while ((opt = poptGetNextOpt(pc)) != -1) {
-               switch (opt) {
-                       /* Don't become a daemon */
-               case 'i':
-                       interactive = True;
-                       log_stdout = True;
-                       Fork = False;
-                       break;
+       while ((opt = poptGetNextOpt(pc)) != -1) {}
+
+       if (server_mode == SERVER_MODE_INTERACTIVE) {
+               log_stdout = True;
+               if (DEBUGLEVEL >= 9) {
+                       talloc_enable_leak_report();
                }
        }
 
-
-       if (log_stdout && Fork) {
-               printf("Can't log to stdout (-S) unless daemon is in foreground +(-F) or interactive (-i)\n");
+       if (log_stdout && server_mode == SERVER_MODE_DAEMON) {
+               printf("Can't log to stdout (-S) unless daemon is in foreground (-F) or interactive (-i)\n");
                poptPrintUsage(pc, stderr, 0);
                exit(1);
        }
@@ -975,14 +1035,19 @@ int main(int argc, char **argv)
        setup_logging("winbindd", log_stdout);
        reopen_logs();
 
-       DEBUG(1, ("winbindd version %s started.\n", SAMBA_VERSION_STRING) );
-       DEBUGADD( 1, ( "Copyright The Samba Team 2000-2004\n" ) );
+       DEBUG(1, ("winbindd version %s started.\n%s\n", 
+                 SAMBA_VERSION_STRING, 
+                 COPYRIGHT_STARTUP_MESSAGE) );
 
        if (!reload_services_file()) {
                DEBUG(0, ("error opening config file\n"));
                exit(1);
        }
 
+       if (!directory_exist(lp_lockdir(), NULL)) {
+               mkdir(lp_lockdir(), 0755);
+       }
+
        /* Setup names. */
 
        if (!init_names())
@@ -1000,16 +1065,10 @@ int main(int argc, char **argv)
 
        namecache_enable();
 
-       /* Check winbindd parameters are valid */
-
-       ZERO_STRUCT(server_state);
-
        /* Winbind daemon initialisation */
 
-       if ( (!winbindd_param_init()) || (!winbindd_upgrade_idmap()) ||
-            (!idmap_init(lp_idmap_backend())) ) {
-               DEBUG(1, ("Could not init idmap -- netlogon proxy only\n"));
-               idmap_set_proxyonly();
+       if ( ! NT_STATUS_IS_OK(idmap_init_cache()) ) {
+               DEBUG(1, ("Could not init idmap cache!\n"));            
        }
 
        /* Unblock all signals we are interested in as they may have been
@@ -1035,42 +1094,76 @@ int main(int argc, char **argv)
        CatchSignal(SIGUSR2, sigusr2_handler);         /* Debugging sigs */
        CatchSignal(SIGHUP, sighup_handler);
 
-       if (!interactive)
-               become_daemon(Fork);
+       if (server_mode == SERVER_MODE_DAEMON) {
+               DEBUG( 3, ( "Becoming a daemon.\n" ) );
+               become_daemon(True, no_process_group);
+       } else if (server_mode == SERVER_MODE_FOREGROUND) {
+               become_daemon(False, no_process_group);
+       }
 
        pidfile_create("winbindd");
 
+       /* Ensure all cache and idmap caches are consistent
+          before we startup. */
+
+       if (winbindd_validate_cache()) {
+               /* We have a bad cache, but luckily we
+                  just deleted it. Restart ourselves */
+               int i;
+               /* Ensure we have no open low fd's. */
+               for (i = 3; i < 100; i++) {
+                       close(i);
+               }
+               return execve(argv[0], argv, envp);
+       }
+
 #if HAVE_SETPGID
        /*
         * If we're interactive we want to set our own process group for
         * signal management.
         */
-       if (interactive)
+       if (server_mode == SERVER_MODE_INTERACTIVE && !no_process_group) {
                setpgid( (pid_t)0, (pid_t)0);
+       }
 #endif
 
        TimeInit();
 
        /* Initialise messaging system */
 
-       if (!message_init()) {
+       if (winbind_messaging_context() == NULL) {
                DEBUG(0, ("unable to initialize messaging system\n"));
                exit(1);
        }
        
+       /* Initialize cache (ensure version is correct). */
+       if (!initialize_winbindd_cache()) {
+               exit(1);
+       }
+
        /* React on 'smbcontrol winbindd reload-config' in the same way
           as to SIGHUP signal */
-       message_register(MSG_SMB_CONF_UPDATED, msg_reload_services);
-       message_register(MSG_SHUTDOWN, msg_shutdown);
+       messaging_register(winbind_messaging_context(), NULL,
+                          MSG_SMB_CONF_UPDATED, msg_reload_services);
+       messaging_register(winbind_messaging_context(), NULL,
+                          MSG_SHUTDOWN, msg_shutdown);
 
        /* Handle online/offline messages. */
-       message_register(MSG_WINBIND_OFFLINE,winbind_msg_offline);
-       message_register(MSG_WINBIND_ONLINE,winbind_msg_online);
+       messaging_register(winbind_messaging_context(), NULL,
+                          MSG_WINBIND_OFFLINE, winbind_msg_offline);
+       messaging_register(winbind_messaging_context(), NULL,
+                          MSG_WINBIND_ONLINE, winbind_msg_online);
+       messaging_register(winbind_messaging_context(), NULL,
+                          MSG_WINBIND_ONLINESTATUS, winbind_msg_onlinestatus);
 
        poptFreeContext(pc);
 
        netsamlogon_cache_init(); /* Non-critical */
        
+       /* clear the cached list of trusted domains */
+
+       wcache_tdc_clear();     
+       
        if (!init_domain_list()) {
                DEBUG(0,("unable to initalize domain list\n"));
                exit(1);
@@ -1078,14 +1171,11 @@ int main(int argc, char **argv)
 
        init_idmap_child();
 
-       winbindd_flush_nscd_cache();
+       smb_nscd_flush_user_cache();
+       smb_nscd_flush_group_cache();
 
        /* Loop waiting for requests */
-
-       while (1)
-               process_loop();
-
-       trustdom_cache_shutdown();
+       winbindd_process_loop(server_mode);
 
        return 0;
 }