bool ret;
if (lp_loaded()) {
- const char *fname = lp_configfile();
+ char *fname = lp_configfile();
if (file_exist(fname) && !strcsequal(fname,get_dyn_CONFIGFILE())) {
set_dyn_CONFIGFILE(fname);
}
+ TALLOC_FREE(fname);
}
/* if this is a child, restore the logfile to the special
{
uint8 ret;
pid_t child_pid;
- struct sigaction act;
- struct sigaction oldact;
DEBUG(10, ("winbindd_msg_validate_cache: got validate-cache "
"message.\n"));
* so we don't block the main winbindd and the validation
* code can safely use fork/waitpid...
*/
- CatchChild();
child_pid = sys_fork();
if (child_pid == -1) {
/* child */
+ if (!winbindd_reinit_after_fork(NULL)) {
+ _exit(0);
+ }
+
/* install default SIGCHLD handler: validation code uses fork/waitpid */
- ZERO_STRUCT(act);
- act.sa_handler = SIG_DFL;
-#ifdef SA_RESTART
- /* We *want* SIGALRM to interrupt a system call. */
- act.sa_flags = SA_RESTART;
-#endif
- sigemptyset(&act.sa_mask);
- sigaddset(&act.sa_mask,SIGCHLD);
- sigaction(SIGCHLD,&act,&oldact);
+ CatchSignal(SIGCHLD, SIG_DFL);
ret = (uint8)winbindd_validate_cache_nobackup();
DEBUG(10, ("winbindd_msg_validata_cache: got return value %d\n", ret));
{ WINBINDD_LIST_TRUSTDOM, winbindd_list_trusted_domains,
"LIST_TRUSTDOM" },
- /* Lookup related functions */
-
- { WINBINDD_SET_HWM, winbindd_set_hwm, "SET_HWMS" },
-
/* Miscellaneous */
{ WINBINDD_INFO, winbindd_info, "INFO" },
/* Credential cache access */
{ WINBINDD_CCACHE_NTLMAUTH, winbindd_ccache_ntlm_auth, "NTLMAUTH" },
+ { WINBINDD_CCACHE_SAVE, winbindd_ccache_save, "CCACHE_SAVE" },
/* WINS functions */
winbindd_list_groups_send, winbindd_list_groups_recv },
{ WINBINDD_CHECK_MACHACC, "CHECK_MACHACC",
winbindd_check_machine_acct_send, winbindd_check_machine_acct_recv },
+ { WINBINDD_PING_DC, "PING_DC",
+ winbindd_ping_dc_send, winbindd_ping_dc_recv },
{ 0, NULL, NULL, NULL }
};
winbindd_set_mapping_send, winbindd_set_mapping_recv },
{ WINBINDD_REMOVE_MAPPING, "SET_MAPPING",
winbindd_remove_mapping_send, winbindd_remove_mapping_recv },
+ { WINBINDD_SET_HWM, "SET_HWM",
+ winbindd_set_hwm_send, winbindd_set_hwm_recv },
+ { WINBINDD_CHANGE_MACHACC, "CHANGE_MACHACC",
+ winbindd_change_machine_acct_send, winbindd_change_machine_acct_recv },
{ 0, NULL, NULL, NULL }
};
/* Remember who asked us. */
state->pid = state->request->pid;
+ state->cmd_name = "unknown request";
+ state->recv_fn = NULL;
+
/* Process command */
for (atable = async_nonpriv_table; atable->send_req; atable += 1) {
if (atable->send_req != NULL) {
struct tevent_req *req;
- DEBUG(10, ("process_request: Handling async request %s\n",
- atable->cmd_name));
+ state->cmd_name = atable->cmd_name;
+ state->recv_fn = atable->recv_req;
+
+ DEBUG(10, ("process_request: Handling async request %d:%s\n",
+ (int)state->pid, state->cmd_name));
req = atable->send_req(state->mem_ctx, winbind_event_context(),
state, state->request);
return;
}
tevent_req_set_callback(req, wb_request_done, state);
- state->recv_fn = atable->recv_req;
return;
}
if (state->request->cmd == table->cmd) {
DEBUG(10,("process_request: request fn %s\n",
table->winbindd_cmd_name ));
+ state->cmd_name = table->winbindd_cmd_name;
table->fn(state);
break;
}
req, struct winbindd_cli_state);
NTSTATUS status;
- state->response = talloc_zero(state, struct winbindd_response);
+ state->response = talloc_zero(state->mem_ctx,
+ struct winbindd_response);
if (state->response == NULL) {
+ DEBUG(0, ("wb_request_done[%d:%s]: talloc_zero failed - removing client\n",
+ (int)state->pid, state->cmd_name));
remove_client(state);
return;
}
status = state->recv_fn(req, state->response);
TALLOC_FREE(req);
+
+ DEBUG(10,("wb_request_done[%d:%s]: %s\n",
+ (int)state->pid, state->cmd_name, nt_errstr(status)));
+
if (!NT_STATUS_IS_OK(status)) {
- DEBUG(10, ("returning %s\n", nt_errstr(status)));
request_error(state);
return;
}
state->out_queue, state->sock,
state->response);
if (req == NULL) {
+ DEBUG(10,("request_finished[%d:%s]: wb_resp_write_send() failed\n",
+ (int)state->pid, state->cmd_name));
remove_client(state);
return;
}
ret = wb_resp_write_recv(req, &err);
TALLOC_FREE(req);
if (ret == -1) {
- DEBUG(2, ("Could not write response to client: %s\n",
- strerror(err)));
+ close(state->sock);
+ state->sock = -1;
+ DEBUG(2, ("Could not write response[%d:%s] to client: %s\n",
+ (int)state->pid, state->cmd_name, strerror(err)));
remove_client(state);
return;
}
+ DEBUG(10,("winbind_client_response_written[%d:%s]: deliverd response to client\n",
+ (int)state->pid, state->cmd_name));
+
TALLOC_FREE(state->mem_ctx);
state->response = NULL;
+ state->cmd_name = "no request";
+ state->recv_fn = NULL;
req = wb_req_read_send(state, winbind_event_context(), state->sock,
WINBINDD_MAX_EXTRA_DATA);
ret = wb_req_read_recv(req, state, &state->request, &err);
TALLOC_FREE(req);
if (ret == -1) {
- DEBUG(2, ("Could not read client request: %s\n",
- strerror(err)));
+ if (err == EPIPE) {
+ DEBUG(6, ("closing socket %d, client exited\n",
+ state->sock));
+ } else {
+ DEBUG(2, ("Could not read client request from fd %d: "
+ "%s\n", state->sock, strerror(err)));
+ }
+ close(state->sock);
+ state->sock = -1;
remove_client(state);
return;
}
return;
}
- /* tell client, we are closing ... */
- nwritten = write(state->sock, &c, sizeof(c));
- if (nwritten == -1) {
- /*
- * ignore EPIPE error here, because the other end might
- * have already closed the socket.
- */
- if (errno != EPIPE) {
+ if (state->sock != -1) {
+ /* tell client, we are closing ... */
+ nwritten = write(state->sock, &c, sizeof(c));
+ if (nwritten == -1) {
DEBUG(2, ("final write to client failed: %s\n",
- strerror(errno)));
+ strerror(errno)));
}
- }
-
- /* Close socket */
-
- close(state->sock);
- /* Free any getent state */
+ /* Close socket */
- free_getent_state(state->getgrent_state);
+ close(state->sock);
+ state->sock = -1;
+ }
TALLOC_FREE(state->mem_ctx);
for (state = winbindd_client_list(); state; state = state->next) {
if (state->response == NULL &&
- !state->pwent_state && !state->getgrent_state) {
+ !state->pwent_state && !state->grent_state) {
nidle++;
if (!last_access || state->last_access < last_access) {
last_access = state->last_access;
struct winbindd_listen_state *s = talloc_get_type_abort(private_data,
struct winbindd_listen_state);
- while (winbindd_num_clients() >
- WINBINDD_MAX_SIMULTANEOUS_CLIENTS - 1) {
+ while (winbindd_num_clients() > lp_winbind_max_clients() - 1) {
DEBUG(5,("winbindd: Exceeding %d client "
"connections, removing idle "
- "connection.\n",
- WINBINDD_MAX_SIMULTANEOUS_CLIENTS));
+ "connection.\n", lp_winbind_max_clients()));
if (!remove_idle_client()) {
DEBUG(0,("winbindd: Exceeding %d "
"client connections, no idle "
"connection found\n",
- WINBINDD_MAX_SIMULTANEOUS_CLIENTS));
+ lp_winbind_max_clients()));
break;
}
}
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 */
}
}
+ /* We call dump_core_setup one more time because the command line can
+ * set the log file or the log-basename and this will influence where
+ * cores are stored. Without this call get_dyn_LOGFILEBASE will be
+ * the default value derived from build's prefix. For EOM this value
+ * is often not related to the path where winbindd is actually run
+ * in production.
+ */
+ dump_core_setup("winbindd");
+
if (is_daemon && interactive) {
d_fprintf(stderr,"\nERROR: "
"Option -i|--interactive is not allowed together with -D|--daemon\n\n");
DEBUG(0, ("error opening config file\n"));
exit(1);
}
+ /* After parsing the configuration file we setup the core path one more time
+ * as the log file might have been set in the configuration and cores's
+ * path is by default basename(lp_logfile()).
+ */
+ dump_core_setup("winbindd");
/* Initialise messaging system */
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);
+ if (lp_allow_trusted_domains()) {
+ if (tevent_add_timer(winbind_event_context(), NULL, timeval_zero(),
+ rescan_trusted_domains, NULL) == NULL) {
+ DEBUG(0, ("Could not trigger rescan_trusted_domains()\n"));
+ exit(1);
+ }
}
TALLOC_FREE(frame);