diff options
Diffstat (limited to 'source3/nsswitch/winbindd.c')
-rw-r--r-- | source3/nsswitch/winbindd.c | 60 |
1 files changed, 22 insertions, 38 deletions
diff --git a/source3/nsswitch/winbindd.c b/source3/nsswitch/winbindd.c index 5b9c5418a1..7dbdca97ee 100644 --- a/source3/nsswitch/winbindd.c +++ b/source3/nsswitch/winbindd.c @@ -23,10 +23,6 @@ #include "winbindd.h" -/* List of all connected clients */ - -static struct winbindd_cli_state *client_list; -static int num_clients; BOOL opt_nocache = False; BOOL opt_dual_daemon = False; @@ -121,11 +117,11 @@ static void winbindd_status(void) /* Print client state information */ - DEBUG(0, ("\t%d clients currently active\n", num_clients)); + DEBUG(0, ("\t%d clients currently active\n", winbindd_num_clients())); - if (DEBUGLEVEL >= 2 && num_clients) { + if (DEBUGLEVEL >= 2 && winbindd_num_clients()) { DEBUG(2, ("\tclient list:\n")); - for(tmp = client_list; tmp; tmp = tmp->next) { + for(tmp = winbindd_client_list(); tmp; tmp = tmp->next) { DEBUG(2, ("\t\tpid %d, sock %d, rbl %d, wbl %d\n", tmp->pid, tmp->sock, tmp->read_buf_len, tmp->write_buf_len)); @@ -189,14 +185,6 @@ static void sighup_handler(int signum) sys_select_signal(); } -/* Create winbindd socket */ - -static int create_sock(void) -{ - return create_pipe_sock( WINBINDD_SOCKET_DIR, - WINBINDD_SOCKET_NAME, 0755); -} - struct dispatch_table { enum winbindd_cmd cmd; enum winbindd_result (*fn)(struct winbindd_cli_state *state); @@ -303,7 +291,7 @@ static void process_request(struct winbindd_cli_state *state) /* Process a new connection by adding it to the client connection list */ -static void new_connection(int accept_sock) +static void new_connection(int listen_sock) { struct sockaddr_un sunaddr; struct winbindd_cli_state *state; @@ -315,7 +303,7 @@ static void new_connection(int accept_sock) len = sizeof(sunaddr); do { - sock = accept(accept_sock, (struct sockaddr *)&sunaddr, &len); + sock = accept(listen_sock, (struct sockaddr *)&sunaddr, &len); } while (sock == -1 && errno == EINTR); if (sock == -1) @@ -334,8 +322,7 @@ static void new_connection(int accept_sock) /* Add to connection list */ - DLIST_ADD(client_list, state); - num_clients++; + winbindd_add_client(state); } /* Remove a client connection from client connection list */ @@ -362,9 +349,8 @@ static void remove_client(struct winbindd_cli_state *state) /* Remove from list and free */ - DLIST_REMOVE(client_list, state); + winbindd_remove_client(state); SAFE_FREE(state); - num_clients--; } } @@ -507,14 +493,14 @@ static void client_write(struct winbindd_cli_state *state) simultaneous connections while remaining impervious to many denial of service attacks. */ -static void process_loop(int accept_sock) +static void process_loop(void) { /* We'll be doing this a lot */ while (1) { struct winbindd_cli_state *state; fd_set r_fds, w_fds; - int maxfd = accept_sock, selret; + int maxfd, listen_sock, selret; struct timeval timeout; /* Handle messages */ @@ -532,9 +518,12 @@ static void process_loop(int accept_sock) /* Initialise fd lists for select() */ + listen_sock = open_winbindd_socket(); + maxfd = listen_sock; + FD_ZERO(&r_fds); FD_ZERO(&w_fds); - FD_SET(accept_sock, &r_fds); + FD_SET(listen_sock, &r_fds); timeout.tv_sec = WINBINDD_ESTABLISH_LOOP; timeout.tv_usec = 0; @@ -545,7 +534,7 @@ static void process_loop(int accept_sock) /* Set up client readers and writers */ - state = client_list; + state = winbindd_client_list(); while (state) { @@ -601,12 +590,13 @@ static void process_loop(int accept_sock) dual_select(&w_fds); } - if (FD_ISSET(accept_sock, &r_fds)) - new_connection(accept_sock); + if (FD_ISSET(listen_sock, &r_fds)) + new_connection(listen_sock); /* Process activity on client connections */ - for (state = client_list; state; state = state->next) { + for (state = winbindd_client_list(); state; + state = state->next) { /* Data available for reading */ @@ -660,7 +650,9 @@ static void process_loop(int accept_sock) if (do_sighup) { - /* Flush winbindd cache */ + DEBUG(3, ("got SIGHUP\n")); + + /* Flush various caches */ flush_caches(); reload_services_file(True); @@ -755,7 +747,6 @@ static void usage(void) extern fstring global_myworkgroup; extern BOOL append_log; pstring logfile; - int accept_sock; BOOL interactive = False; int opt; @@ -883,16 +874,9 @@ static void usage(void) register_msg_pool_usage(); - /* Create UNIX domain socket */ - - if ((accept_sock = create_sock()) == -1) { - DEBUG(0, ("failed to create socket\n")); - return 1; - } - /* Loop waiting for requests */ - process_loop(accept_sock); + process_loop(); uni_group_cache_shutdown(); return 0; |