From f1a63ec8ef4edb3b0dc31fe6aa3cb87dd2fd6c07 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 17 Nov 2017 11:35:19 +0100 Subject: [PATCH 1/4] winbind: Replace winbind_event_context with server_event_context There's no point in having two global event contexts BUG: https://bugzilla.samba.org/show_bug.cgi?id=13150 Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison (cherry picked from commit 7e83d1489406cd53d72097e40bf02295c88ea61e) --- source3/winbindd/idmap_ldap.c | 2 +- source3/winbindd/idmap_rfc2307.c | 2 +- source3/winbindd/winbindd.c | 58 +++++++++++----------- source3/winbindd/winbindd_cm.c | 4 +- source3/winbindd/winbindd_cred_cache.c | 14 +++--- source3/winbindd/winbindd_dual.c | 16 +++--- source3/winbindd/winbindd_irpc.c | 10 ++-- source3/winbindd/winbindd_misc.c | 2 +- source3/winbindd/winbindd_pam_auth.c | 2 +- source3/winbindd/winbindd_pam_auth_crap.c | 2 +- source3/winbindd/winbindd_pam_chauthtok.c | 2 +- .../winbindd/winbindd_pam_chng_pswd_auth_crap.c | 2 +- source3/winbindd/winbindd_pam_logoff.c | 2 +- source3/winbindd/winbindd_util.c | 2 +- 14 files changed, 60 insertions(+), 60 deletions(-) diff --git a/source3/winbindd/idmap_ldap.c b/source3/winbindd/idmap_ldap.c index 39aa8330735..6765dfc217a 100644 --- a/source3/winbindd/idmap_ldap.c +++ b/source3/winbindd/idmap_ldap.c @@ -455,7 +455,7 @@ static NTSTATUS idmap_ldap_db_init(struct idmap_domain *dom) /* get_credentials deals with setting up creds */ - ret = smbldap_init(ctx, winbind_event_context(), ctx->url, + ret = smbldap_init(ctx, server_event_context(), ctx->url, false, NULL, NULL, &ctx->smbldap_state); if (!NT_STATUS_IS_OK(ret)) { DEBUG(1, ("ERROR: smbldap_init (%s) failed!\n", ctx->url)); diff --git a/source3/winbindd/idmap_rfc2307.c b/source3/winbindd/idmap_rfc2307.c index 668a7a4e28e..264ccb034fb 100644 --- a/source3/winbindd/idmap_rfc2307.c +++ b/source3/winbindd/idmap_rfc2307.c @@ -193,7 +193,7 @@ static NTSTATUS idmap_rfc2307_init_ldap(struct idmap_rfc2307_context *ctx, } /* assume anonymous if we don't have a specified user */ - ret = smbldap_init(mem_ctx, winbind_event_context(), url, + ret = smbldap_init(mem_ctx, server_event_context(), url, (user_dn == NULL), user_dn, secret, &ctx->smbldap_state); SAFE_FREE(secret); diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c index f24451649b6..981888068c1 100644 --- a/source3/winbindd/winbindd.c +++ b/source3/winbindd/winbindd.c @@ -91,7 +91,7 @@ struct messaging_context *winbind_messaging_context(void) * Note we MUST use the NULL context here, not the autofree context, * to avoid side effects in forked children exiting. */ - msg = messaging_init(NULL, winbind_event_context()); + msg = messaging_init(NULL, server_event_context()); if (msg == NULL) { smb_panic("Could not init winbindd's messaging context.\n"); } @@ -124,7 +124,7 @@ struct imessaging_context *winbind_imessaging_context(void) * Note we MUST use the NULL context here, not the autofree context, * to avoid side effects in forked children exiting. */ - msg = imessaging_init(NULL, lp_ctx, myself, winbind_event_context()); + msg = imessaging_init(NULL, lp_ctx, myself, server_event_context()); talloc_unlink(NULL, lp_ctx); if (msg == NULL) { @@ -307,14 +307,14 @@ bool winbindd_setup_sig_term_handler(bool parent) struct tevent_signal *se; bool *is_parent; - is_parent = talloc(winbind_event_context(), bool); + is_parent = talloc(server_event_context(), bool); if (!is_parent) { return false; } *is_parent = parent; - se = tevent_add_signal(winbind_event_context(), + se = tevent_add_signal(server_event_context(), is_parent, SIGTERM, 0, winbindd_sig_term_handler, @@ -325,7 +325,7 @@ bool winbindd_setup_sig_term_handler(bool parent) return false; } - se = tevent_add_signal(winbind_event_context(), + se = tevent_add_signal(server_event_context(), is_parent, SIGINT, 0, winbindd_sig_term_handler, @@ -336,7 +336,7 @@ bool winbindd_setup_sig_term_handler(bool parent) return false; } - se = tevent_add_signal(winbind_event_context(), + se = tevent_add_signal(server_event_context(), is_parent, SIGQUIT, 0, winbindd_sig_term_handler, @@ -357,7 +357,7 @@ bool winbindd_setup_stdin_handler(bool parent, bool foreground) if (foreground) { struct stat st; - is_parent = talloc(winbind_event_context(), bool); + is_parent = talloc(server_event_context(), bool); if (!is_parent) { return false; } @@ -373,7 +373,7 @@ bool winbindd_setup_stdin_handler(bool parent, bool foreground) return false; } if (S_ISFIFO(st.st_mode) || S_ISSOCK(st.st_mode)) { - tevent_add_fd(winbind_event_context(), + tevent_add_fd(server_event_context(), is_parent, 0, TEVENT_FD_READ, @@ -405,15 +405,15 @@ bool winbindd_setup_sig_hup_handler(const char *lfile) char *file = NULL; if (lfile) { - file = talloc_strdup(winbind_event_context(), + file = talloc_strdup(server_event_context(), lfile); if (!file) { return false; } } - se = tevent_add_signal(winbind_event_context(), - winbind_event_context(), + se = tevent_add_signal(server_event_context(), + server_event_context(), SIGHUP, 0, winbindd_sig_hup_handler, file); @@ -442,8 +442,8 @@ static bool winbindd_setup_sig_chld_handler(void) { struct tevent_signal *se; - se = tevent_add_signal(winbind_event_context(), - winbind_event_context(), + se = tevent_add_signal(server_event_context(), + server_event_context(), SIGCHLD, 0, winbindd_sig_chld_handler, NULL); @@ -468,8 +468,8 @@ static bool winbindd_setup_sig_usr2_handler(void) { struct tevent_signal *se; - se = tevent_add_signal(winbind_event_context(), - winbind_event_context(), + se = tevent_add_signal(server_event_context(), + server_event_context(), SIGUSR2, 0, winbindd_sig_usr2_handler, NULL); @@ -734,7 +734,7 @@ static void process_request(struct winbindd_cli_state *state) 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(), + req = atable->send_req(state->mem_ctx, server_event_context(), state, state->request); if (req == NULL) { DEBUG(0, ("process_request: atable->send failed for " @@ -828,7 +828,7 @@ static void request_finished(struct winbindd_cli_state *state) TALLOC_FREE(state->request); - req = wb_resp_write_send(state, winbind_event_context(), + req = wb_resp_write_send(state, server_event_context(), state->out_queue, state->sock, state->response); if (req == NULL) { @@ -869,7 +869,7 @@ static void winbind_client_response_written(struct tevent_req *req) state->cmd_name = "no request"; state->recv_fn = NULL; - req = wb_req_read_send(state, winbind_event_context(), state->sock, + req = wb_req_read_send(state, server_event_context(), state->sock, WINBINDD_MAX_EXTRA_DATA); if (req == NULL) { remove_client(state); @@ -937,7 +937,7 @@ static void new_connection(int listen_sock, bool privileged) state->privileged = privileged; - req = wb_req_read_send(state, winbind_event_context(), state->sock, + req = wb_req_read_send(state, server_event_context(), state->sock, WINBINDD_MAX_EXTRA_DATA); if (req == NULL) { TALLOC_FREE(state); @@ -977,7 +977,7 @@ static void winbind_client_request_read(struct tevent_req *req) return; } - req = wait_for_read_send(state, winbind_event_context(), state->sock, + req = wait_for_read_send(state, server_event_context(), state->sock, true); if (req == NULL) { DEBUG(0, ("winbind_client_request_read[%d:%s]:" @@ -1239,7 +1239,7 @@ static bool winbindd_setup_listeners(void) int rc; char *socket_path; - pub_state = talloc(winbind_event_context(), + pub_state = talloc(server_event_context(), struct winbindd_listen_state); if (!pub_state) { goto failed; @@ -1256,7 +1256,7 @@ static bool winbindd_setup_listeners(void) goto failed; } - fde = tevent_add_fd(winbind_event_context(), pub_state, pub_state->fd, + fde = tevent_add_fd(server_event_context(), pub_state, pub_state->fd, TEVENT_FD_READ, winbindd_listen_fde_handler, pub_state); if (fde == NULL) { @@ -1265,7 +1265,7 @@ static bool winbindd_setup_listeners(void) } tevent_fd_set_auto_close(fde); - priv_state = talloc(winbind_event_context(), + priv_state = talloc(server_event_context(), struct winbindd_listen_state); if (!priv_state) { goto failed; @@ -1288,7 +1288,7 @@ static bool winbindd_setup_listeners(void) goto failed; } - fde = tevent_add_fd(winbind_event_context(), priv_state, + fde = tevent_add_fd(server_event_context(), priv_state, priv_state->fd, TEVENT_FD_READ, winbindd_listen_fde_handler, priv_state); if (fde == NULL) { @@ -1297,7 +1297,7 @@ static bool winbindd_setup_listeners(void) } tevent_fd_set_auto_close(fde); - winbindd_scrub_clients_handler(winbind_event_context(), NULL, + winbindd_scrub_clients_handler(server_event_context(), NULL, timeval_current(), NULL); return true; failed: @@ -1412,7 +1412,7 @@ static void winbindd_register_handlers(struct messaging_context *msg_ctx, smb_nscd_flush_group_cache(); if (lp_allow_trusted_domains()) { - if (tevent_add_timer(winbind_event_context(), NULL, timeval_zero(), + if (tevent_add_timer(server_event_context(), NULL, timeval_zero(), rescan_trusted_domains, NULL) == NULL) { DEBUG(0, ("Could not trigger rescan_trusted_domains()\n")); exit(1); @@ -1777,7 +1777,7 @@ int main(int argc, const char **argv) */ status = reinit_after_fork(winbind_messaging_context(), - winbind_event_context(), + server_event_context(), false, NULL); if (!NT_STATUS_IS_OK(status)) { exit_daemon("Winbindd reinit_after_fork() failed", map_errno_from_nt_status(status)); @@ -1807,7 +1807,7 @@ int main(int argc, const char **argv) rpc_lsarpc_init(NULL); rpc_samr_init(NULL); - winbindd_init_addrchange(NULL, winbind_event_context(), + winbindd_init_addrchange(NULL, server_event_context(), winbind_messaging_context()); /* setup listen sockets */ @@ -1828,7 +1828,7 @@ int main(int argc, const char **argv) while (1) { frame = talloc_stackframe(); - if (tevent_loop_once(winbind_event_context()) == -1) { + if (tevent_loop_once(server_event_context()) == -1) { DEBUG(1, ("tevent_loop_once() failed: %s\n", strerror(errno))); return 1; diff --git a/source3/winbindd/winbindd_cm.c b/source3/winbindd/winbindd_cm.c index b24a5f253f7..a97401a5250 100644 --- a/source3/winbindd/winbindd_cm.c +++ b/source3/winbindd/winbindd_cm.c @@ -428,7 +428,7 @@ void set_domain_offline(struct winbindd_domain *domain) calc_new_online_timeout_check(domain); - domain->check_online_event = tevent_add_timer(winbind_event_context(), + domain->check_online_event = tevent_add_timer(server_event_context(), NULL, timeval_current_ofs(domain->check_online_timeout,0), check_domain_online_handler, @@ -604,7 +604,7 @@ void set_domain_online_request(struct winbindd_domain *domain) TALLOC_FREE(domain->check_online_event); - domain->check_online_event = tevent_add_timer(winbind_event_context(), + domain->check_online_event = tevent_add_timer(server_event_context(), NULL, tev, check_domain_online_handler, diff --git a/source3/winbindd/winbindd_cred_cache.c b/source3/winbindd/winbindd_cred_cache.c index 20b4d55fb80..7cd7a4c9f23 100644 --- a/source3/winbindd/winbindd_cred_cache.c +++ b/source3/winbindd/winbindd_cred_cache.c @@ -285,7 +285,7 @@ done: if (entry->refresh_time == 0) { entry->refresh_time = new_start; } - entry->event = tevent_add_timer(winbind_event_context(), entry, + entry->event = tevent_add_timer(server_event_context(), entry, timeval_set(new_start, 0), krb5_ticket_refresh_handler, entry); @@ -385,7 +385,7 @@ static void krb5_ticket_gain_handler(struct tevent_context *event_ctx, if (entry->refresh_time == 0) { entry->refresh_time = t.tv_sec; } - entry->event = tevent_add_timer(winbind_event_context(), + entry->event = tevent_add_timer(server_event_context(), entry, t, krb5_ticket_refresh_handler, @@ -404,7 +404,7 @@ static void add_krb5_ticket_gain_handler_event(struct WINBINDD_CCACHE_ENTRY *ent struct timeval t) { entry->refresh_time = 0; - entry->event = tevent_add_timer(winbind_event_context(), + entry->event = tevent_add_timer(server_event_context(), entry, t, krb5_ticket_gain_handler, @@ -424,13 +424,13 @@ void ccache_regain_all_now(void) * the event has the krb5_ticket_gain_handler */ if (cur->refresh_time == 0) { - new_event = tevent_add_timer(winbind_event_context(), + new_event = tevent_add_timer(server_event_context(), cur, t, krb5_ticket_gain_handler, cur); } else { - new_event = tevent_add_timer(winbind_event_context(), + new_event = tevent_add_timer(server_event_context(), cur, t, krb5_ticket_refresh_handler, @@ -547,7 +547,7 @@ NTSTATUS add_ccache_to_list(const char *princ_name, if (!entry->refresh_time) { entry->refresh_time = t.tv_sec; } - entry->event = tevent_add_timer(winbind_event_context(), + entry->event = tevent_add_timer(server_event_context(), entry, t, krb5_ticket_refresh_handler, @@ -645,7 +645,7 @@ NTSTATUS add_ccache_to_list(const char *princ_name, if (entry->refresh_time == 0) { entry->refresh_time = t.tv_sec; } - entry->event = tevent_add_timer(winbind_event_context(), + entry->event = tevent_add_timer(server_event_context(), entry, t, krb5_ticket_refresh_handler, diff --git a/source3/winbindd/winbindd_dual.c b/source3/winbindd/winbindd_dual.c index 8636ccd7e0a..0b98a8368e4 100644 --- a/source3/winbindd/winbindd_dual.c +++ b/source3/winbindd/winbindd_dual.c @@ -175,7 +175,7 @@ static void wb_child_request_trigger(struct tevent_req *req, return; } - subreq = wb_simple_trans_send(state, winbind_event_context(), NULL, + subreq = wb_simple_trans_send(state, server_event_context(), NULL, state->child->sock, state->request); if (tevent_req_nomem(subreq, req)) { return; @@ -968,7 +968,7 @@ static void account_lockout_policy_handler(struct tevent_context *ctx, nt_errstr(result))); } - child->lockout_policy_event = tevent_add_timer(winbind_event_context(), NULL, + child->lockout_policy_event = tevent_add_timer(server_event_context(), NULL, timeval_current_ofs(3600, 0), account_lockout_policy_handler, child); @@ -1130,7 +1130,7 @@ static void machine_password_change_handler(struct tevent_context *ctx, } done: - child->machine_password_change_event = tevent_add_timer(winbind_event_context(), NULL, + child->machine_password_change_event = tevent_add_timer(server_event_context(), NULL, next_change, machine_password_change_handler, child); @@ -1251,7 +1251,7 @@ NTSTATUS winbindd_reinit_after_fork(const struct winbindd_child *myself, status = reinit_after_fork( winbind_messaging_context(), - winbind_event_context(), + server_event_context(), true, NULL); if (!NT_STATUS_IS_OK(status)) { DEBUG(0,("reinit_after_fork() failed\n")); @@ -1556,7 +1556,7 @@ static bool fork_domain_child(struct winbindd_child *child) } child->lockout_policy_event = tevent_add_timer( - winbind_event_context(), NULL, timeval_zero(), + server_event_context(), NULL, timeval_zero(), account_lockout_policy_handler, child); } @@ -1570,13 +1570,13 @@ static bool fork_domain_child(struct winbindd_child *child) if (calculate_next_machine_pwd_change(child->domain->name, &next_change)) { child->machine_password_change_event = tevent_add_timer( - winbind_event_context(), NULL, next_change, + server_event_context(), NULL, next_change, machine_password_change_handler, child); } } - fde = tevent_add_fd(winbind_event_context(), NULL, state.cli.sock, + fde = tevent_add_fd(server_event_context(), NULL, state.cli.sock, TEVENT_FD_READ, child_handler, &state); if (fde == NULL) { DEBUG(1, ("tevent_add_fd failed\n")); @@ -1588,7 +1588,7 @@ static bool fork_domain_child(struct winbindd_child *child) int ret; TALLOC_CTX *frame = talloc_stackframe(); - ret = tevent_loop_once(winbind_event_context()); + ret = tevent_loop_once(server_event_context()); if (ret != 0) { DEBUG(1, ("tevent_loop_once failed: %s\n", strerror(errno))); diff --git a/source3/winbindd/winbindd_irpc.c b/source3/winbindd/winbindd_irpc.c index c6c786c8be1..0f63b652603 100644 --- a/source3/winbindd/winbindd_irpc.c +++ b/source3/winbindd/winbindd_irpc.c @@ -123,7 +123,7 @@ static NTSTATUS wb_irpc_DsrUpdateReadOnlyServerDnsRecords(struct irpc_message *m DEBUG(5, ("wb_irpc_DsrUpdateReadOnlyServerDnsRecords called\n")); return wb_irpc_forward_rpc_call(msg, msg, - winbind_event_context(), + server_event_context(), req, NDR_WINBIND_DSRUPDATEREADONLYSERVERDNSRECORDS, "winbind_DsrUpdateReadOnlyServerDnsRecords", domain, IRPC_CALL_TIMEOUT); @@ -149,7 +149,7 @@ static NTSTATUS wb_irpc_SamLogon(struct irpc_message *msg, DEBUG(5, ("wb_irpc_SamLogon called\n")); return wb_irpc_forward_rpc_call(msg, msg, - winbind_event_context(), + server_event_context(), req, NDR_WINBIND_SAMLOGON, "winbind_SamLogon", domain, IRPC_CALL_TIMEOUT); @@ -209,7 +209,7 @@ static NTSTATUS wb_irpc_LogonControl(struct irpc_message *msg, TALLOC_FREE(frame); return wb_irpc_forward_rpc_call(msg, msg, - winbind_event_context(), + server_event_context(), req, NDR_WINBIND_LOGONCONTROL, "winbind_LogonControl", domain, 45 /* timeout */); @@ -249,7 +249,7 @@ static NTSTATUS wb_irpc_GetForestTrustInformation(struct irpc_message *msg, DEBUG(5, ("wb_irpc_GetForestTrustInformation called\n")); return wb_irpc_forward_rpc_call(msg, msg, - winbind_event_context(), + server_event_context(), req, NDR_WINBIND_GETFORESTTRUSTINFORMATION, "winbind_GetForestTrustInformation", domain, 45 /* timeout */); @@ -267,7 +267,7 @@ static NTSTATUS wb_irpc_SendToSam(struct irpc_message *msg, DEBUG(5, ("wb_irpc_SendToSam called\n")); return wb_irpc_forward_rpc_call(msg, msg, - winbind_event_context(), + server_event_context(), req, NDR_WINBIND_SENDTOSAM, "winbind_SendToSam", domain, IRPC_CALL_TIMEOUT); diff --git a/source3/winbindd/winbindd_misc.c b/source3/winbindd/winbindd_misc.c index 30730dcec12..6cf33420768 100644 --- a/source3/winbindd/winbindd_misc.c +++ b/source3/winbindd/winbindd_misc.c @@ -277,7 +277,7 @@ void winbindd_domain_info(struct winbindd_cli_state *cli) * Send a ping down. This implicitly initializes the domain. */ - req = wb_domain_request_send(state, winbind_event_context(), + req = wb_domain_request_send(state, server_event_context(), domain, &state->ping_request); if (req == NULL) { DEBUG(3, ("wb_domain_request_send failed\n")); diff --git a/source3/winbindd/winbindd_pam_auth.c b/source3/winbindd/winbindd_pam_auth.c index 4f963a32818..7ff44888975 100644 --- a/source3/winbindd/winbindd_pam_auth.c +++ b/source3/winbindd/winbindd_pam_auth.c @@ -81,7 +81,7 @@ struct tevent_req *winbindd_pam_auth_send(TALLOC_CTX *mem_ctx, return tevent_req_post(req, ev); } - subreq = wb_domain_request_send(state, winbind_event_context(), domain, + subreq = wb_domain_request_send(state, server_event_context(), domain, request); if (tevent_req_nomem(subreq, req)) { return tevent_req_post(req, ev); diff --git a/source3/winbindd/winbindd_pam_auth_crap.c b/source3/winbindd/winbindd_pam_auth_crap.c index e6a47c86785..cfeafbcfda8 100644 --- a/source3/winbindd/winbindd_pam_auth_crap.c +++ b/source3/winbindd/winbindd_pam_auth_crap.c @@ -93,7 +93,7 @@ struct tevent_req *winbindd_pam_auth_crap_send( fstrcpy(request->data.auth_crap.workstation, lp_netbios_name()); } - subreq = wb_domain_request_send(state, winbind_event_context(), domain, + subreq = wb_domain_request_send(state, server_event_context(), domain, request); if (tevent_req_nomem(subreq, req)) { return tevent_req_post(req, ev); diff --git a/source3/winbindd/winbindd_pam_chauthtok.c b/source3/winbindd/winbindd_pam_chauthtok.c index 8ffbc29b973..0d749fbcecd 100644 --- a/source3/winbindd/winbindd_pam_chauthtok.c +++ b/source3/winbindd/winbindd_pam_chauthtok.c @@ -79,7 +79,7 @@ struct tevent_req *winbindd_pam_chauthtok_send( return tevent_req_post(req, ev); } - subreq = wb_domain_request_send(state, winbind_event_context(), + subreq = wb_domain_request_send(state, server_event_context(), contact_domain, request); if (tevent_req_nomem(subreq, req)) { return tevent_req_post(req, ev); diff --git a/source3/winbindd/winbindd_pam_chng_pswd_auth_crap.c b/source3/winbindd/winbindd_pam_chng_pswd_auth_crap.c index 9133a91fa50..e9ee0ab63ce 100644 --- a/source3/winbindd/winbindd_pam_chng_pswd_auth_crap.c +++ b/source3/winbindd/winbindd_pam_chng_pswd_auth_crap.c @@ -73,7 +73,7 @@ struct tevent_req *winbindd_pam_chng_pswd_auth_crap_send( return tevent_req_post(req, ev); } - subreq = wb_domain_request_send(state, winbind_event_context(), + subreq = wb_domain_request_send(state, server_event_context(), domain, request); if (tevent_req_nomem(subreq, req)) { return tevent_req_post(req, ev); diff --git a/source3/winbindd/winbindd_pam_logoff.c b/source3/winbindd/winbindd_pam_logoff.c index b3c60adf857..b5b7840f99c 100644 --- a/source3/winbindd/winbindd_pam_logoff.c +++ b/source3/winbindd/winbindd_pam_logoff.c @@ -94,7 +94,7 @@ struct tevent_req *winbindd_pam_logoff_send(TALLOC_CTX *mem_ctx, break; } - subreq = wb_domain_request_send(state, winbind_event_context(), domain, + subreq = wb_domain_request_send(state, server_event_context(), domain, request); if (tevent_req_nomem(subreq, req)) { return tevent_req_post(req, ev); diff --git a/source3/winbindd/winbindd_util.c b/source3/winbindd/winbindd_util.c index d2a091ad1dd..2615192881c 100644 --- a/source3/winbindd/winbindd_util.c +++ b/source3/winbindd/winbindd_util.c @@ -321,7 +321,7 @@ static void add_trusted_domains( struct winbindd_domain *domain ) state->request.length = sizeof(state->request); state->request.cmd = WINBINDD_LIST_TRUSTDOM; - req = wb_domain_request_send(state, winbind_event_context(), + req = wb_domain_request_send(state, server_event_context(), domain, &state->request); if (req == NULL) { DEBUG(1, ("wb_domain_request_send failed\n")); -- 2.15.0.448.gf294e3d99a-goog From d74e33f9bd05ff3f66990a834bb9d62f97484bc2 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 17 Nov 2017 11:37:30 +0100 Subject: [PATCH 2/4] winbind: Remove winbind_event_context BUG: https://bugzilla.samba.org/show_bug.cgi?id=13150 Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison (cherry picked from commit e1f12acc13a3cc004518ac3460c6000ea0b95115) --- source3/torture/torture.c | 9 --------- source3/winbindd/winbindd.c | 19 ------------------- source3/winbindd/winbindd_proto.h | 1 - 3 files changed, 29 deletions(-) diff --git a/source3/torture/torture.c b/source3/torture/torture.c index 1d89041b784..72efcb2f333 100644 --- a/source3/torture/torture.c +++ b/source3/torture/torture.c @@ -11697,15 +11697,6 @@ static struct { { "qpathinfo-bufsize", run_qpathinfo_bufsize, 0 }, {NULL, NULL, 0}}; -/* - * dummy function to satisfy linker dependency - */ -struct tevent_context *winbind_event_context(void); -struct tevent_context *winbind_event_context(void) -{ - return NULL; -} - /**************************************************************************** run a specified test or "ALL" ****************************************************************************/ diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c index 981888068c1..75f9dbb142e 100644 --- a/source3/winbindd/winbindd.c +++ b/source3/winbindd/winbindd.c @@ -60,25 +60,6 @@ static bool interactive = False; extern bool override_logfile; -struct tevent_context *winbind_event_context(void) -{ - static struct tevent_context *ev = NULL; - - if (ev != NULL) { - return ev; - } - - /* - * Note we MUST use the NULL context here, not the autofree context, - * to avoid side effects in forked children exiting. - */ - ev = samba_tevent_context_init(NULL); - if (ev == NULL) { - smb_panic("Could not init winbindd's messaging context.\n"); - } - return ev; -} - struct messaging_context *winbind_messaging_context(void) { static struct messaging_context *msg = NULL; diff --git a/source3/winbindd/winbindd_proto.h b/source3/winbindd/winbindd_proto.h index 6d6fafcb72f..af576b5862b 100644 --- a/source3/winbindd/winbindd_proto.h +++ b/source3/winbindd/winbindd_proto.h @@ -34,7 +34,6 @@ bool winbindd_setup_sig_hup_handler(const char *lfile); bool winbindd_use_idmap_cache(void); bool winbindd_use_cache(void); char *get_winbind_priv_pipe_dir(void); -struct tevent_context *winbind_event_context(void); /* The following definitions come from winbindd/winbindd_ads.c */ -- 2.15.0.448.gf294e3d99a-goog From 4f9738d620b2955f313eb383487501b0838dfa74 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 17 Nov 2017 11:42:34 +0100 Subject: [PATCH 3/4] winbind: winbind_messaging_context -> server_messaging_context Don't use winbind_messaging_context anymore. This fixes a bug analysed by Peter Somogyi : If a parent winbind forks, it only called reinit_after_fork on winbind_messaging_context. On the other hand, deep in dbwrap_open we use server_messaging_context(). This is not reinitialized by winbind_reinit_after fork, so the parent and child share a ctdb connection. This is invalid, because replies from ctdb end up in the wrong process. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13150 Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison (cherry picked from commit d8a01d09c13728f36107f6eb94ecb7653706a4db) --- source3/winbindd/winbindd.c | 16 ++++++++-------- source3/winbindd/winbindd_cm.c | 32 ++++++++++++++++---------------- source3/winbindd/winbindd_dual.c | 34 +++++++++++++++++----------------- source3/winbindd/winbindd_dual_srv.c | 6 +++--- 4 files changed, 44 insertions(+), 44 deletions(-) diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c index 75f9dbb142e..679faefe2fd 100644 --- a/source3/winbindd/winbindd.c +++ b/source3/winbindd/winbindd.c @@ -240,7 +240,7 @@ static void terminate(bool is_parent) #endif if (is_parent) { - struct messaging_context *msg = winbind_messaging_context(); + struct messaging_context *msg = server_messaging_context(); struct server_id self = messaging_server_id(msg); serverid_deregister(self); pidfile_unlink(lp_pid_directory(), "winbindd"); @@ -1350,9 +1350,9 @@ static void winbindd_register_handlers(struct messaging_context *msg_ctx, MSG_WINBIND_ONLINESTATUS, winbind_msg_onlinestatus); /* Handle domain online/offline messages for domains */ - messaging_register(winbind_messaging_context(), NULL, + messaging_register(server_messaging_context(), NULL, MSG_WINBIND_DOMAIN_OFFLINE, winbind_msg_domain_offline); - messaging_register(winbind_messaging_context(), NULL, + messaging_register(server_messaging_context(), NULL, MSG_WINBIND_DOMAIN_ONLINE, winbind_msg_domain_online); messaging_register(msg_ctx, NULL, @@ -1663,7 +1663,7 @@ int main(int argc, const char **argv) /* Initialise messaging system */ - if (winbind_messaging_context() == NULL) { + if (server_messaging_context() == NULL) { exit(1); } @@ -1757,7 +1757,7 @@ int main(int argc, const char **argv) * winbindd-specific resources we must free yet. JRA. */ - status = reinit_after_fork(winbind_messaging_context(), + status = reinit_after_fork(server_messaging_context(), server_event_context(), false, NULL); if (!NT_STATUS_IS_OK(status)) { @@ -1774,9 +1774,9 @@ int main(int argc, const char **argv) exit_daemon(nt_errstr(status), map_errno_from_nt_status(status)); } - winbindd_register_handlers(winbind_messaging_context(), !Fork); + winbindd_register_handlers(server_messaging_context(), !Fork); - if (!messaging_parent_dgm_cleanup_init(winbind_messaging_context())) { + if (!messaging_parent_dgm_cleanup_init(server_messaging_context())) { exit(1); } @@ -1789,7 +1789,7 @@ int main(int argc, const char **argv) rpc_samr_init(NULL); winbindd_init_addrchange(NULL, server_event_context(), - winbind_messaging_context()); + server_messaging_context()); /* setup listen sockets */ diff --git a/source3/winbindd/winbindd_cm.c b/source3/winbindd/winbindd_cm.c index a97401a5250..ee168fc3e4b 100644 --- a/source3/winbindd/winbindd_cm.c +++ b/source3/winbindd/winbindd_cm.c @@ -223,10 +223,10 @@ static bool fork_child_dc_connect(struct winbindd_domain *domain) if (domain->dc_probe_pid != (pid_t)0) { /* Parent */ - messaging_register(winbind_messaging_context(), NULL, + messaging_register(server_messaging_context(), NULL, MSG_WINBIND_TRY_TO_GO_ONLINE, msg_try_to_go_online); - messaging_register(winbind_messaging_context(), NULL, + messaging_register(server_messaging_context(), NULL, MSG_WINBIND_FAILED_TO_GO_ONLINE, msg_failed_to_go_online); return True; @@ -247,7 +247,7 @@ static bool fork_child_dc_connect(struct winbindd_domain *domain) if (!NT_STATUS_IS_OK(status)) { DEBUG(1, ("winbindd_reinit_after_fork failed: %s\n", nt_errstr(status))); - messaging_send_buf(winbind_messaging_context(), + messaging_send_buf(server_messaging_context(), pid_to_procid(parent_pid), MSG_WINBIND_FAILED_TO_GO_ONLINE, (const uint8_t *)domain->name, @@ -259,7 +259,7 @@ static bool fork_child_dc_connect(struct winbindd_domain *domain) mem_ctx = talloc_init("fork_child_dc_connect"); if (!mem_ctx) { DEBUG(0,("talloc_init failed.\n")); - messaging_send_buf(winbind_messaging_context(), + messaging_send_buf(server_messaging_context(), pid_to_procid(parent_pid), MSG_WINBIND_FAILED_TO_GO_ONLINE, (const uint8_t *)domain->name, @@ -269,7 +269,7 @@ static bool fork_child_dc_connect(struct winbindd_domain *domain) if ((!get_dcs(mem_ctx, domain, &dcs, &num_dcs, 0)) || (num_dcs == 0)) { /* Still offline ? Can't find DC's. */ - messaging_send_buf(winbind_messaging_context(), + messaging_send_buf(server_messaging_context(), pid_to_procid(parent_pid), MSG_WINBIND_FAILED_TO_GO_ONLINE, (const uint8_t *)domain->name, @@ -280,7 +280,7 @@ static bool fork_child_dc_connect(struct winbindd_domain *domain) /* We got a DC. Send a message to our parent to get it to try and do the same. */ - messaging_send_buf(winbind_messaging_context(), + messaging_send_buf(server_messaging_context(), pid_to_procid(parent_pid), MSG_WINBIND_TRY_TO_GO_ONLINE, (const uint8_t *)domain->name, @@ -444,7 +444,7 @@ void set_domain_offline(struct winbindd_domain *domain) /* Send a message to the parent that the domain is offline. */ if (parent_pid > 1 && !domain->internal) { - messaging_send_buf(winbind_messaging_context(), + messaging_send_buf(server_messaging_context(), pid_to_procid(parent_pid), MSG_WINBIND_DOMAIN_OFFLINE, (uint8_t *)domain->name, @@ -458,7 +458,7 @@ void set_domain_offline(struct winbindd_domain *domain) struct winbindd_child *idmap = idmap_child(); if ( idmap->pid != 0 ) { - messaging_send_buf(winbind_messaging_context(), + messaging_send_buf(server_messaging_context(), pid_to_procid(idmap->pid), MSG_WINBIND_OFFLINE, (const uint8_t *)domain->name, @@ -521,16 +521,16 @@ static void set_domain_online(struct winbindd_domain *domain) TALLOC_FREE(domain->check_online_event); /* Ensure we ignore any pending child messages. */ - messaging_deregister(winbind_messaging_context(), + messaging_deregister(server_messaging_context(), MSG_WINBIND_TRY_TO_GO_ONLINE, NULL); - messaging_deregister(winbind_messaging_context(), + messaging_deregister(server_messaging_context(), MSG_WINBIND_FAILED_TO_GO_ONLINE, NULL); domain->online = True; /* Send a message to the parent that the domain is online. */ if (parent_pid > 1 && !domain->internal) { - messaging_send_buf(winbind_messaging_context(), + messaging_send_buf(server_messaging_context(), pid_to_procid(parent_pid), MSG_WINBIND_DOMAIN_ONLINE, (uint8_t *)domain->name, @@ -544,7 +544,7 @@ static void set_domain_online(struct winbindd_domain *domain) struct winbindd_child *idmap = idmap_child(); if ( idmap->pid != 0 ) { - messaging_send_buf(winbind_messaging_context(), + messaging_send_buf(server_messaging_context(), pid_to_procid(idmap->pid), MSG_WINBIND_ONLINE, (const uint8_t *)domain->name, @@ -1420,7 +1420,7 @@ static bool dcip_check_name(TALLOC_CTX *mem_ctx, } #endif - status = nbt_getdc(winbind_messaging_context(), 10, pss, domain->name, + status = nbt_getdc(server_messaging_context(), 10, pss, domain->name, &domain->sid, nt_version, mem_ctx, &nt_version, &dc_name, NULL); if (NT_STATUS_IS_OK(status)) { @@ -1789,7 +1789,7 @@ NTSTATUS wb_open_internal_pipe(TALLOC_CTX *mem_ctx, session_info, NULL, NULL, - winbind_messaging_context(), + server_messaging_context(), &cli); } else { status = rpc_pipe_open_internal(mem_ctx, @@ -1797,7 +1797,7 @@ NTSTATUS wb_open_internal_pipe(TALLOC_CTX *mem_ctx, session_info, NULL, NULL, - winbind_messaging_context(), + server_messaging_context(), &cli); } if (!NT_STATUS_IS_OK(status)) { @@ -3213,7 +3213,7 @@ static NTSTATUS cm_connect_netlogon_transport(struct winbindd_domain *domain, enum dcerpc_transport_t transport, struct rpc_pipe_client **cli) { - struct messaging_context *msg_ctx = winbind_messaging_context(); + struct messaging_context *msg_ctx = server_messaging_context(); struct winbindd_cm_conn *conn; NTSTATUS result; enum netr_SchannelType sec_chan_type; diff --git a/source3/winbindd/winbindd_dual.c b/source3/winbindd/winbindd_dual.c index 0b98a8368e4..eaa7d9f26f9 100644 --- a/source3/winbindd/winbindd_dual.c +++ b/source3/winbindd/winbindd_dual.c @@ -1051,7 +1051,7 @@ static void machine_password_change_handler(struct tevent_context *ctx, struct timeval now, void *private_data) { - struct messaging_context *msg_ctx = winbind_messaging_context(); + struct messaging_context *msg_ctx = server_messaging_context(); struct winbindd_child *child = (struct winbindd_child *)private_data; struct rpc_pipe_client *netlogon_pipe = NULL; @@ -1250,7 +1250,7 @@ NTSTATUS winbindd_reinit_after_fork(const struct winbindd_child *myself, NTSTATUS status; status = reinit_after_fork( - winbind_messaging_context(), + server_messaging_context(), server_event_context(), true, NULL); if (!NT_STATUS_IS_OK(status)) { @@ -1275,26 +1275,26 @@ NTSTATUS winbindd_reinit_after_fork(const struct winbindd_child *myself, CatchChild(); /* Don't handle the same messages as our parent. */ - messaging_deregister(winbind_messaging_context(), + messaging_deregister(server_messaging_context(), MSG_SMB_CONF_UPDATED, NULL); - messaging_deregister(winbind_messaging_context(), + messaging_deregister(server_messaging_context(), MSG_SHUTDOWN, NULL); - messaging_deregister(winbind_messaging_context(), + messaging_deregister(server_messaging_context(), MSG_WINBIND_OFFLINE, NULL); - messaging_deregister(winbind_messaging_context(), + messaging_deregister(server_messaging_context(), MSG_WINBIND_ONLINE, NULL); - messaging_deregister(winbind_messaging_context(), + messaging_deregister(server_messaging_context(), MSG_WINBIND_ONLINESTATUS, NULL); - messaging_deregister(winbind_messaging_context(), + messaging_deregister(server_messaging_context(), MSG_DUMP_EVENT_LIST, NULL); - messaging_deregister(winbind_messaging_context(), + messaging_deregister(server_messaging_context(), MSG_WINBIND_DUMP_DOMAIN_LIST, NULL); - messaging_deregister(winbind_messaging_context(), + messaging_deregister(server_messaging_context(), MSG_DEBUG, NULL); - messaging_deregister(winbind_messaging_context(), + messaging_deregister(server_messaging_context(), MSG_WINBIND_DOMAIN_OFFLINE, NULL); - messaging_deregister(winbind_messaging_context(), + messaging_deregister(server_messaging_context(), MSG_WINBIND_DOMAIN_ONLINE, NULL); /* We have destroyed all events in the winbindd_event_context @@ -1492,15 +1492,15 @@ static bool fork_domain_child(struct winbindd_child *child) } /* Handle online/offline messages. */ - messaging_register(winbind_messaging_context(), NULL, + messaging_register(server_messaging_context(), NULL, MSG_WINBIND_OFFLINE, child_msg_offline); - messaging_register(winbind_messaging_context(), NULL, + messaging_register(server_messaging_context(), NULL, MSG_WINBIND_ONLINE, child_msg_online); - messaging_register(winbind_messaging_context(), NULL, + messaging_register(server_messaging_context(), NULL, MSG_DUMP_EVENT_LIST, child_msg_dump_event_list); - messaging_register(winbind_messaging_context(), NULL, + messaging_register(server_messaging_context(), NULL, MSG_DEBUG, debug_message); - messaging_register(winbind_messaging_context(), NULL, + messaging_register(server_messaging_context(), NULL, MSG_WINBIND_IP_DROPPED, winbind_msg_ip_dropped); diff --git a/source3/winbindd/winbindd_dual_srv.c b/source3/winbindd/winbindd_dual_srv.c index 5e953e7c3c6..e1f1f240832 100644 --- a/source3/winbindd/winbindd_dual_srv.c +++ b/source3/winbindd/winbindd_dual_srv.c @@ -522,7 +522,7 @@ NTSTATUS _wbint_DsGetDcName(struct pipes_struct *p, struct wbint_DsGetDcName *r) struct dcerpc_binding_handle *b; if (domain == NULL) { - return dsgetdcname(p->mem_ctx, winbind_messaging_context(), + return dsgetdcname(p->mem_ctx, server_messaging_context(), r->in.domain_name, r->in.domain_guid, r->in.site_name ? r->in.site_name : "", r->in.flags, @@ -714,7 +714,7 @@ again: NTSTATUS _wbint_ChangeMachineAccount(struct pipes_struct *p, struct wbint_ChangeMachineAccount *r) { - struct messaging_context *msg_ctx = winbind_messaging_context(); + struct messaging_context *msg_ctx = server_messaging_context(); struct winbindd_domain *domain; NTSTATUS status; struct rpc_pipe_client *netlogon_pipe; @@ -1363,7 +1363,7 @@ static WERROR _winbind_LogonControl_CHANGE_PASSWORD(struct pipes_struct *p, struct winbindd_domain *domain, struct winbind_LogonControl *r) { - struct messaging_context *msg_ctx = winbind_messaging_context(); + struct messaging_context *msg_ctx = server_messaging_context(); NTSTATUS status; struct rpc_pipe_client *netlogon_pipe; struct cli_credentials *creds = NULL; -- 2.15.0.448.gf294e3d99a-goog From 431ca3990099691a01f52afc773fbbbccb9e6a33 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 17 Nov 2017 11:47:37 +0100 Subject: [PATCH 4/4] winbind: Remove winbind_messaging_context BUG: https://bugzilla.samba.org/show_bug.cgi?id=13150 Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison Autobuild-User(master): Jeremy Allison Autobuild-Date(master): Sat Nov 18 04:07:24 CET 2017 on sn-devel-144 (cherry picked from commit 050ca45dc7fc5bbab6e1c60b919ac0b1e9661e27) --- source3/winbindd/winbindd.c | 19 ------------------- source3/winbindd/winbindd_proto.h | 1 - 2 files changed, 20 deletions(-) diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c index 679faefe2fd..ceb131e9b32 100644 --- a/source3/winbindd/winbindd.c +++ b/source3/winbindd/winbindd.c @@ -60,25 +60,6 @@ static bool interactive = False; extern bool override_logfile; -struct messaging_context *winbind_messaging_context(void) -{ - static struct messaging_context *msg = NULL; - - if (msg != NULL) { - return msg; - } - - /* - * Note we MUST use the NULL context here, not the autofree context, - * to avoid side effects in forked children exiting. - */ - msg = messaging_init(NULL, server_event_context()); - if (msg == NULL) { - smb_panic("Could not init winbindd's messaging context.\n"); - } - return msg; -} - struct imessaging_context *winbind_imessaging_context(void) { static struct imessaging_context *msg = NULL; diff --git a/source3/winbindd/winbindd_proto.h b/source3/winbindd/winbindd_proto.h index af576b5862b..26101145a51 100644 --- a/source3/winbindd/winbindd_proto.h +++ b/source3/winbindd/winbindd_proto.h @@ -24,7 +24,6 @@ #define _WINBINDD_PROTO_H_ /* The following definitions come from winbindd/winbindd.c */ -struct messaging_context *winbind_messaging_context(void); struct imessaging_context *winbind_imessaging_context(void); void request_error(struct winbindd_cli_state *state); void request_ok(struct winbindd_cli_state *state); -- 2.15.0.448.gf294e3d99a-goog