From 21bf3ec39d32b10ffc1d0544629a950c00c9488d Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 30 May 2002 19:40:53 +0000 Subject: [PATCH] fix for CR-636. Kill connection to NETLOGON cli_connection in winbindd_kill_connection(). Otherwise an invalid cli_state* might get reused. --- source/nsswitch/winbindd_util.c | 13 +++++++++++++ source/rpc_client/cli_connect.c | 20 +------------------- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/source/nsswitch/winbindd_util.c b/source/nsswitch/winbindd_util.c index 65d3376475f..a1e6e83907d 100644 --- a/source/nsswitch/winbindd_util.c +++ b/source/nsswitch/winbindd_util.c @@ -236,6 +236,8 @@ BOOL domain_handles_open(struct winbindd_domain *domain) void winbindd_kill_connections(struct winbindd_domain *domain) { + struct cli_connection *con = NULL; + /* Kill all connections */ if (!domain) { @@ -259,10 +261,18 @@ void winbindd_kill_connections(struct winbindd_domain *domain) debug_conn_state(); + /* Kill NETLOGON connection as well */ + + if (cli_connection_getsrv(domain->controller, PIPE_NETLOGON, &con)) { + DEBUG(2,("Closing NETLOGON pipe...\n")); + cli_connection_free(con); + } + /* Close LSA connections if we are killing connections to the dc that has them open. */ if (strequal(domain->name, lp_workgroup())) { + DEBUG(2,("closing LSARPC pipe....\n")); server_state.pwdb_initialised = False; server_state.lsa_handle_open = False; lsa_close(&server_state.lsa_handle); @@ -273,11 +283,13 @@ void winbindd_kill_connections(struct winbindd_domain *domain) will be reopened later. */ if (domain->sam_dom_handle_open) { + DEBUG(2,("closing sam_dom_handle_open...\n")); samr_close(&domain->sam_dom_handle); domain->sam_dom_handle_open = False; } if (domain->sam_handle_open) { + DEBUG(2,("closing sam_handle_open...\n")); samr_close(&domain->sam_handle); domain->sam_handle_open = False; } @@ -344,6 +356,7 @@ void establish_connections(BOOL force_reestablish) if (server_state.pwdb_initialised && server_state.lsa_handle_open && !rpc_hnd_ok(&server_state.lsa_handle)) { + DEBUG(2,("establish_connections: Killiong old connections first!\n")); winbindd_kill_connections(NULL); } diff --git a/source/rpc_client/cli_connect.c b/source/rpc_client/cli_connect.c index 0cf887bc70c..2714a59397a 100644 --- a/source/rpc_client/cli_connect.c +++ b/source/rpc_client/cli_connect.c @@ -377,31 +377,13 @@ BOOL cli_connection_getsrv(const char *srv_name, const char *pipe_name, && (*con)->msrpc.smb->smb && (*con)->msrpc.smb->smb->fd == -1) { - struct cli_state *cli = (*con)->msrpc.smb->smb; - int j; - /* remove this connection and force us to reestablish */ - DEBUG(3,("cli_connection_getsrv: fd == -1 ! Closing cli_connection to [%s:%s]!\n", + DEBUG(2,("cli_connection_getsrv: fd == -1 ! Closing cli_connection to [%s:%s]!\n", (*con)->srv_name, (*con)->pipe_name)); con_list[i] = NULL; cli_connection_free(*con); *con = NULL; - /* Sanity check for dangling pointers */ - - for (j = 0; j < num_cons; j++) - { - if (con_list[j] - && (con_list[j]->type == MSRPC_SMB) - && (con_list[j]->msrpc.smb) - && (con_list[j]->msrpc.smb->smb == cli)) - { - DEBUG(3,("cli_connection_getsrv: cli_state pointer reused on [%s:%s]!\n", - con_list[j]->srv_name, con_list[j]->pipe_name)); - con_list[j]->msrpc.smb->smb = NULL; - } - } - return False; } } -- 2.11.4.GIT