1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-26 21:57:41 +03:00

winbind: winbind_messaging_context -> server_messaging_context

Don't use winbind_messaging_context anymore.

This fixes a bug analysed by Peter Somogyi <PSOMOGYI@hu.ibm.com>: 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 <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
Volker Lendecke 2017-11-17 11:42:34 +01:00 committed by Jeremy Allison
parent e1f12acc13
commit d8a01d09c1
4 changed files with 44 additions and 44 deletions

View File

@ -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 */

View File

@ -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)) {
@ -3211,7 +3211,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;
struct cli_credentials *creds = NULL;

View File

@ -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);

View File

@ -523,7 +523,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,
@ -715,7 +715,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;
@ -1364,7 +1364,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;