From: Volker Lendecke Date: Fri, 25 Apr 2008 14:33:35 +0000 (+0200) Subject: Revert "Replace cli_rpc_pipe_close by a talloc destructor on rpc_pipe_struct" X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=cee2119701ec0b4ead3049d2ae3a3a2fb4ab9e54;p=thirdparty%2Fsamba.git Revert "Replace cli_rpc_pipe_close by a talloc destructor on rpc_pipe_struct" This reverts commit 99fc3283c4ecc791f5a242bd1983b4352ce3e6cf. --- diff --git a/source/client/client.c b/source/client/client.c index b4e1985a837..1c9c21e979f 100644 --- a/source/client/client.c +++ b/source/client/client.c @@ -3658,7 +3658,7 @@ static bool browse_host_rpc(bool sort) &werr); if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(werr)) { - TALLOC_FREE(pipe_hnd); + cli_rpc_pipe_close(pipe_hnd); TALLOC_FREE(frame); return false; } @@ -3668,7 +3668,7 @@ static bool browse_host_rpc(bool sort) browse_fn(info.name, info.type, info.comment, NULL); } - TALLOC_FREE(pipe_hnd); + cli_rpc_pipe_close(pipe_hnd); TALLOC_FREE(frame); return true; } diff --git a/source/libnet/libnet_join.c b/source/libnet/libnet_join.c index 7e348e25a57..370509840a5 100644 --- a/source/libnet/libnet_join.c +++ b/source/libnet/libnet_join.c @@ -706,7 +706,7 @@ static NTSTATUS libnet_join_lookup_dc_rpc(TALLOC_CTX *mem_ctx, } rpccli_lsa_Close(pipe_hnd, mem_ctx, &lsa_pol); - TALLOC_FREE(pipe_hnd); + cli_rpc_pipe_close(pipe_hnd); done: return status; @@ -951,7 +951,7 @@ static NTSTATUS libnet_join_joindomain_rpc(TALLOC_CTX *mem_ctx, if (is_valid_policy_hnd(&user_pol)) { rpccli_samr_Close(pipe_hnd, mem_ctx, &user_pol); } - TALLOC_FREE(pipe_hnd); + cli_rpc_pipe_close(pipe_hnd); return status; } @@ -1217,7 +1217,7 @@ done: if (pipe_hnd) { rpccli_samr_Close(pipe_hnd, mem_ctx, &domain_pol); rpccli_samr_Close(pipe_hnd, mem_ctx, &sam_pol); - TALLOC_FREE(pipe_hnd); + cli_rpc_pipe_close(pipe_hnd); } if (cli) { diff --git a/source/libsmb/clientgen.c b/source/libsmb/clientgen.c index e64b6fa278a..ef2c2639cd5 100644 --- a/source/libsmb/clientgen.c +++ b/source/libsmb/clientgen.c @@ -616,17 +616,55 @@ struct cli_state *cli_initialise(void) return NULL; } +/**************************************************************************** + External interface. + Close an open named pipe over SMB. Free any authentication data. + Returns false if the cli_close call failed. + ****************************************************************************/ + +bool cli_rpc_pipe_close(struct rpc_pipe_client *cli) +{ + bool ret; + + if (!cli) { + return false; + } + + ret = cli_close(cli->cli, cli->fnum); + + if (!ret) { + DEBUG(1,("cli_rpc_pipe_close: cli_close failed on pipe %s, " + "fnum 0x%x " + "to machine %s. Error was %s\n", + cli->pipe_name, + (int) cli->fnum, + cli->desthost, + cli_errstr(cli->cli))); + } + + if (cli->auth.cli_auth_data_free_func) { + (*cli->auth.cli_auth_data_free_func)(&cli->auth); + } + + DEBUG(10,("cli_rpc_pipe_close: closed pipe %s to machine %s\n", + cli->pipe_name, cli->desthost )); + + DLIST_REMOVE(cli->cli->pipe_list, cli); + talloc_destroy(cli); + return ret; +} + /**************************************************************************** Close all pipes open on this session. ****************************************************************************/ void cli_nt_pipes_close(struct cli_state *cli) { - while (cli->pipe_list != NULL) { - /* - * No TALLOC_FREE here! - */ - talloc_free(cli->pipe_list); + struct rpc_pipe_client *cp, *next; + + for (cp = cli->pipe_list; cp; cp = next) { + next = cp->next; + cli_rpc_pipe_close(cp); } } diff --git a/source/libsmb/libsmb_dir.c b/source/libsmb/libsmb_dir.c index aea4f103b6f..612a8772c0e 100644 --- a/source/libsmb/libsmb_dir.c +++ b/source/libsmb/libsmb_dir.c @@ -319,7 +319,7 @@ net_share_enum_rpc(struct cli_state *cli, done: /* Close the server service pipe */ - TALLOC_FREE(pipe_hnd); + cli_rpc_pipe_close(pipe_hnd); /* Tell 'em if it worked */ return W_ERROR_IS_OK(result) ? 0 : -1; diff --git a/source/libsmb/passchange.c b/source/libsmb/passchange.c index 8f7cbf265e9..2f9a87dee4a 100644 --- a/source/libsmb/passchange.c +++ b/source/libsmb/passchange.c @@ -196,7 +196,7 @@ NTSTATUS remote_password_change(const char *remote_machine, const char *user_nam } /* OK, that failed, so try again... */ - TALLOC_FREE(pipe_hnd); + cli_rpc_pipe_close(pipe_hnd); /* Try anonymous NTLMSSP... */ cli_init_creds(cli, "", "", NULL); diff --git a/source/rpc_client/cli_pipe.c b/source/rpc_client/cli_pipe.c index b0d6f8eafd6..3e03887bfdb 100644 --- a/source/rpc_client/cli_pipe.c +++ b/source/rpc_client/cli_pipe.c @@ -1066,10 +1066,7 @@ static NTSTATUS create_schannel_auth_rpc_bind_req( struct rpc_pipe_client *cli, /* Use lp_workgroup() if domain not specified */ if (!cli->domain || !cli->domain[0]) { - cli->domain = talloc_strdup(cli, lp_workgroup()); - if (cli->domain == NULL) { - return NT_STATUS_NO_MEMORY; - } + cli->domain = lp_workgroup(); } init_rpc_auth_schannel_neg(&schannel_neg, cli->domain, global_myname()); @@ -2140,30 +2137,6 @@ bool rpccli_is_pipe_idx(struct rpc_pipe_client *cli, int pipe_idx) return (cli->abstract_syntax == pipe_names[pipe_idx].abstr_syntax); } -static int rpc_pipe_destructor(struct rpc_pipe_client *p) -{ - bool ret; - - ret = cli_close(p->cli, p->fnum); - if (!ret) { - DEBUG(1, ("rpc_pipe_destructor: cli_close failed on pipe %s, " - "fnum 0x%x to machine %s. Error was %s\n", - p->pipe_name, (int) p->fnum, - p->desthost, cli_errstr(p->cli))); - } - - if (p->auth.cli_auth_data_free_func) { - (*p->auth.cli_auth_data_free_func)(&p->auth); - } - - DEBUG(10, ("rpc_pipe_destructor: closed pipe %s to machine %s\n", - p->pipe_name, p->desthost )); - - DLIST_REMOVE(p->cli->pipe_list, p); - - return ret ? -1 : 0; -} - /**************************************************************************** Open a named pipe over SMB to a remote server. * @@ -2247,8 +2220,6 @@ static struct rpc_pipe_client *cli_rpc_pipe_open(struct cli_state *cli, int pipe result->fnum = fnum; DLIST_ADD(cli->pipe_list, result); - talloc_set_destructor(result, rpc_pipe_destructor); - *perr = NT_STATUS_OK; return result; @@ -2277,7 +2248,7 @@ struct rpc_pipe_client *cli_rpc_pipe_open_noauth(struct cli_state *cli, int pipe } DEBUG(lvl, ("cli_rpc_pipe_open_noauth: rpc_pipe_bind for pipe %s failed with error %s\n", cli_get_pipe_name(pipe_idx), nt_errstr(*perr) )); - TALLOC_FREE(result); + cli_rpc_pipe_close(result); return NULL; } @@ -2389,7 +2360,7 @@ static struct rpc_pipe_client *cli_rpc_pipe_open_ntlmssp_internal(struct cli_sta err: - TALLOC_FREE(result); + cli_rpc_pipe_close(result); return NULL; } @@ -2510,7 +2481,7 @@ struct rpc_pipe_client *get_schannel_session_key(struct cli_state *cli, if (!get_schannel_session_key_common(netlogon_pipe, cli, domain, pneg_flags, perr)) { - TALLOC_FREE(netlogon_pipe); + cli_rpc_pipe_close(netlogon_pipe); return NULL; } @@ -2540,7 +2511,7 @@ struct rpc_pipe_client *cli_rpc_pipe_open_schannel_with_key(struct cli_state *cl result->auth.a_u.schannel_auth = TALLOC_ZERO_P( result, struct schannel_auth_struct); if (!result->auth.a_u.schannel_auth) { - TALLOC_FREE(result); + cli_rpc_pipe_close(result); *perr = NT_STATUS_NO_MEMORY; return NULL; } @@ -2548,7 +2519,7 @@ struct rpc_pipe_client *cli_rpc_pipe_open_schannel_with_key(struct cli_state *cl TALLOC_FREE(result->domain); result->domain = talloc_strdup(result, domain); if (result->domain == NULL) { - TALLOC_FREE(result); + cli_rpc_pipe_close(result); *perr = NT_STATUS_NO_MEMORY; return NULL; } @@ -2559,7 +2530,7 @@ struct rpc_pipe_client *cli_rpc_pipe_open_schannel_with_key(struct cli_state *cl if (!NT_STATUS_IS_OK(*perr)) { DEBUG(0, ("cli_rpc_pipe_open_schannel_with_key: cli_rpc_pipe_bind failed with error %s\n", nt_errstr(*perr) )); - TALLOC_FREE(result); + cli_rpc_pipe_close(result); return NULL; } @@ -2599,7 +2570,7 @@ static struct rpc_pipe_client *get_schannel_session_key_auth_ntlmssp(struct cli_ if (!get_schannel_session_key_common(netlogon_pipe, cli, domain, pneg_flags, perr)) { - TALLOC_FREE(netlogon_pipe); + cli_rpc_pipe_close(netlogon_pipe); return NULL; } @@ -2638,7 +2609,7 @@ struct rpc_pipe_client *cli_rpc_pipe_open_ntlmssp_auth_schannel(struct cli_state domain, netlogon_pipe->dc, perr); /* Now we've bound using the session key we can close the netlog pipe. */ - TALLOC_FREE(netlogon_pipe); + cli_rpc_pipe_close(netlogon_pipe); return result; } @@ -2671,7 +2642,7 @@ struct rpc_pipe_client *cli_rpc_pipe_open_schannel(struct cli_state *cli, domain, netlogon_pipe->dc, perr); /* Now we've bound using the session key we can close the netlog pipe. */ - TALLOC_FREE(netlogon_pipe); + cli_rpc_pipe_close(netlogon_pipe); return result; } @@ -2716,7 +2687,7 @@ struct rpc_pipe_client *cli_rpc_pipe_open_krb5(struct cli_state *cli, service_princ = talloc_asprintf(result, "%s$@%s", cli->desthost, lp_realm() ); if (!service_princ) { - TALLOC_FREE(result); + cli_rpc_pipe_close(result); return NULL; } } @@ -2725,7 +2696,7 @@ struct rpc_pipe_client *cli_rpc_pipe_open_krb5(struct cli_state *cli, if (username && password) { int ret = kerberos_kinit_password(username, password, 0, NULL); if (ret) { - TALLOC_FREE(result); + cli_rpc_pipe_close(result); return NULL; } } @@ -2733,7 +2704,7 @@ struct rpc_pipe_client *cli_rpc_pipe_open_krb5(struct cli_state *cli, result->auth.a_u.kerberos_auth = TALLOC_ZERO_P( result, struct kerberos_auth_struct); if (!result->auth.a_u.kerberos_auth) { - TALLOC_FREE(result); + cli_rpc_pipe_close(result); *perr = NT_STATUS_NO_MEMORY; return NULL; } @@ -2745,7 +2716,7 @@ struct rpc_pipe_client *cli_rpc_pipe_open_krb5(struct cli_state *cli, if (!NT_STATUS_IS_OK(*perr)) { DEBUG(0, ("cli_rpc_pipe_open_krb5: cli_rpc_pipe_bind failed with error %s\n", nt_errstr(*perr) )); - TALLOC_FREE(result); + cli_rpc_pipe_close(result); return NULL; } diff --git a/source/rpcclient/cmd_test.c b/source/rpcclient/cmd_test.c index f9ea5c0fc2d..089d7bcaa3f 100644 --- a/source/rpcclient/cmd_test.c +++ b/source/rpcclient/cmd_test.c @@ -48,8 +48,8 @@ static NTSTATUS cmd_testme(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, goto done; done: - TALLOC_FREE(lsa_pipe); - TALLOC_FREE(samr_pipe); + if (lsa_pipe != NULL) cli_rpc_pipe_close(lsa_pipe); + if (samr_pipe != NULL) cli_rpc_pipe_close(samr_pipe); return status; } diff --git a/source/rpcclient/rpcclient.c b/source/rpcclient/rpcclient.c index ebd38044b84..8592e0a3b60 100644 --- a/source/rpcclient/rpcclient.c +++ b/source/rpcclient/rpcclient.c @@ -169,7 +169,7 @@ static void fetch_machine_sid(struct cli_state *cli) sid_copy(&domain_sid, info->account_domain.sid); rpccli_lsa_Close(lsapipe, mem_ctx, &pol); - TALLOC_FREE(lsapipe); + cli_rpc_pipe_close(lsapipe); talloc_destroy(mem_ctx); return; @@ -177,7 +177,7 @@ static void fetch_machine_sid(struct cli_state *cli) error: if (lsapipe) { - TALLOC_FREE(lsapipe); + cli_rpc_pipe_close(lsapipe); } fprintf(stderr, "could not obtain sid for domain %s\n", cli->domain); @@ -336,7 +336,7 @@ static NTSTATUS cmd_set_ss_level(void) if (tmp_set->rpc_pipe->auth.auth_type != pipe_default_auth_type || tmp_set->rpc_pipe->auth.auth_level != pipe_default_auth_level) { - TALLOC_FREE(tmp_set->rpc_pipe); + cli_rpc_pipe_close(tmp_set->rpc_pipe); tmp_set->rpc_pipe = NULL; } } diff --git a/source/utils/net_rpc.c b/source/utils/net_rpc.c index 136272b8b1a..f4e1bf60166 100644 --- a/source/utils/net_rpc.c +++ b/source/utils/net_rpc.c @@ -88,7 +88,7 @@ NTSTATUS net_get_remote_domain_sid(struct cli_state *cli, TALLOC_CTX *mem_ctx, *domain_sid = info->account_domain.sid; rpccli_lsa_Close(lsa_pipe, mem_ctx, &pol); - TALLOC_FREE(lsa_pipe); + cli_rpc_pipe_close(lsa_pipe); return NT_STATUS_OK; } @@ -185,7 +185,7 @@ int run_rpc_command(struct cli_state *cli_arg, if (!(conn_flags & NET_FLAGS_NO_PIPE)) { if (pipe_hnd) { - TALLOC_FREE(pipe_hnd); + cli_rpc_pipe_close(pipe_hnd); } } @@ -1972,7 +1972,7 @@ static NTSTATUS get_sid_from_name(struct cli_state *cli, done: if (pipe_hnd) { - TALLOC_FREE(pipe_hnd); + cli_rpc_pipe_close(pipe_hnd); } if (!NT_STATUS_IS_OK(result) && (StrnCaseCmp(name, "S-", 2) == 0)) { @@ -2747,14 +2747,14 @@ static NTSTATUS rpc_list_alias_members(struct rpc_pipe_client *pipe_hnd, if (!NT_STATUS_IS_OK(result)) { d_fprintf(stderr, "Couldn't open LSA policy handle\n"); - TALLOC_FREE(lsa_pipe); + cli_rpc_pipe_close(lsa_pipe); return result; } alias_sids = TALLOC_ZERO_ARRAY(mem_ctx, DOM_SID, num_members); if (!alias_sids) { d_fprintf(stderr, "Out of memory\n"); - TALLOC_FREE(lsa_pipe); + cli_rpc_pipe_close(lsa_pipe); return NT_STATUS_NO_MEMORY; } @@ -2769,7 +2769,7 @@ static NTSTATUS rpc_list_alias_members(struct rpc_pipe_client *pipe_hnd, if (!NT_STATUS_IS_OK(result) && !NT_STATUS_EQUAL(result, STATUS_SOME_UNMAPPED)) { d_fprintf(stderr, "Couldn't lookup SIDs\n"); - TALLOC_FREE(lsa_pipe); + cli_rpc_pipe_close(lsa_pipe); return result; } @@ -2789,7 +2789,7 @@ static NTSTATUS rpc_list_alias_members(struct rpc_pipe_client *pipe_hnd, } } - TALLOC_FREE(lsa_pipe); + cli_rpc_pipe_close(lsa_pipe); return NT_STATUS_OK; } @@ -5651,7 +5651,7 @@ static NTSTATUS rpc_trustdom_get_pdc(struct cli_state *cli, domain_name, &buffer, NULL); - TALLOC_FREE(netr); + cli_rpc_pipe_close(netr); if (NT_STATUS_IS_OK(status)) { return status; @@ -6247,7 +6247,7 @@ static int rpc_trustdom_list(int argc, const char **argv) return -1; }; - TALLOC_FREE(pipe_hnd); + cli_rpc_pipe_close(pipe_hnd); /* * Listing trusting domains (stored in passdb backend, if local) diff --git a/source/utils/net_rpc_join.c b/source/utils/net_rpc_join.c index c94e9d1a408..b868ea824fb 100644 --- a/source/utils/net_rpc_join.c +++ b/source/utils/net_rpc_join.c @@ -221,7 +221,7 @@ int net_rpc_join_newstyle(int argc, const char **argv) domain_sid = info->account_domain.sid; rpccli_lsa_Close(pipe_hnd, mem_ctx, &lsa_pol); - TALLOC_FREE(pipe_hnd); /* Done with this pipe */ + cli_rpc_pipe_close(pipe_hnd); /* Done with this pipe */ /* Bail out if domain didn't get set. */ if (!domain) { @@ -368,7 +368,7 @@ int net_rpc_join_newstyle(int argc, const char **argv) &set_info); rpccli_samr_Close(pipe_hnd, mem_ctx, &user_pol); - TALLOC_FREE(pipe_hnd); /* Done with this pipe */ + cli_rpc_pipe_close(pipe_hnd); /* Done with this pipe */ /* Now check the whole process from top-to-bottom */ @@ -429,10 +429,10 @@ int net_rpc_join_newstyle(int argc, const char **argv) goto done; } - TALLOC_FREE(netlogon_schannel_pipe); + cli_rpc_pipe_close(netlogon_schannel_pipe); } - TALLOC_FREE(pipe_hnd); + cli_rpc_pipe_close(pipe_hnd); /* Now store the secret in the secrets database */ diff --git a/source/utils/net_rpc_shell.c b/source/utils/net_rpc_shell.c index 7bd726e614f..e6302b652ed 100644 --- a/source/utils/net_rpc_shell.c +++ b/source/utils/net_rpc_shell.c @@ -85,7 +85,7 @@ static NTSTATUS net_sh_run(struct rpc_sh_ctx *ctx, struct rpc_sh_cmd *cmd, status = cmd->fn(mem_ctx, ctx, pipe_hnd, argc, argv); - TALLOC_FREE(pipe_hnd); + cli_rpc_pipe_close(pipe_hnd); talloc_destroy(mem_ctx); diff --git a/source/utils/net_util.c b/source/utils/net_util.c index 576c2191b31..f844992d562 100644 --- a/source/utils/net_util.c +++ b/source/utils/net_util.c @@ -75,7 +75,7 @@ NTSTATUS net_rpc_lookup_name(TALLOC_CTX *mem_ctx, struct cli_state *cli, if (is_valid_policy_hnd(&pol)) { rpccli_lsa_Close(lsa_pipe, mem_ctx, &pol); } - TALLOC_FREE(lsa_pipe); + cli_rpc_pipe_close(lsa_pipe); return result; } diff --git a/source/utils/smbcacls.c b/source/utils/smbcacls.c index af14c622dc9..134f5617603 100644 --- a/source/utils/smbcacls.c +++ b/source/utils/smbcacls.c @@ -103,7 +103,9 @@ static NTSTATUS cli_lsa_lookup_sid(struct cli_state *cli, status = NT_STATUS_OK; fail: - TALLOC_FREE(p); + if (p != NULL) { + cli_rpc_pipe_close(p); + } cli_tdis(cli); cli->cnum = orig_cnum; TALLOC_FREE(frame); @@ -149,7 +151,9 @@ static NTSTATUS cli_lsa_lookup_name(struct cli_state *cli, status = NT_STATUS_OK; fail: - TALLOC_FREE(p); + if (p != NULL) { + cli_rpc_pipe_close(p); + } cli_tdis(cli); cli->cnum = orig_cnum; TALLOC_FREE(frame); diff --git a/source/utils/smbtree.c b/source/utils/smbtree.c index c2b364d1e9a..d2dd1b49d32 100644 --- a/source/utils/smbtree.c +++ b/source/utils/smbtree.c @@ -188,7 +188,7 @@ static bool get_rpc_shares(struct cli_state *cli, if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(werr)) { TALLOC_FREE(mem_ctx); - TALLOC_FREE(pipe_hnd); + cli_rpc_pipe_close(pipe_hnd); return False; } @@ -198,7 +198,7 @@ static bool get_rpc_shares(struct cli_state *cli, } TALLOC_FREE(mem_ctx); - TALLOC_FREE(pipe_hnd); + cli_rpc_pipe_close(pipe_hnd); return True; } diff --git a/source/winbindd/winbindd_cm.c b/source/winbindd/winbindd_cm.c index d27f3e47f58..ba682d9745b 100644 --- a/source/winbindd/winbindd_cm.c +++ b/source/winbindd/winbindd_cm.c @@ -1436,27 +1436,33 @@ void invalidate_cm_connection(struct winbindd_cm_conn *conn) } if (conn->samr_pipe != NULL) { - TALLOC_FREE(conn->samr_pipe); - /* Ok, it must be dead. Drop timeout to 0.5 sec. */ - if (conn->cli) { - cli_set_timeout(conn->cli, 500); + if (!cli_rpc_pipe_close(conn->samr_pipe)) { + /* Ok, it must be dead. Drop timeout to 0.5 sec. */ + if (conn->cli) { + cli_set_timeout(conn->cli, 500); + } } + conn->samr_pipe = NULL; } if (conn->lsa_pipe != NULL) { - TALLOC_FREE(conn->lsa_pipe); - /* Ok, it must be dead. Drop timeout to 0.5 sec. */ - if (conn->cli) { - cli_set_timeout(conn->cli, 500); + if (!cli_rpc_pipe_close(conn->lsa_pipe)) { + /* Ok, it must be dead. Drop timeout to 0.5 sec. */ + if (conn->cli) { + cli_set_timeout(conn->cli, 500); + } } + conn->lsa_pipe = NULL; } if (conn->netlogon_pipe != NULL) { - TALLOC_FREE(conn->netlogon_pipe); - /* Ok, it must be dead. Drop timeout to 0.5 sec. */ - if (conn->cli) { - cli_set_timeout(conn->cli, 500); + if (!cli_rpc_pipe_close(conn->netlogon_pipe)) { + /* Ok, it must be dead. Drop timeout to 0.5 sec. */ + if (conn->cli) { + cli_set_timeout(conn->cli, 500); + } } + conn->netlogon_pipe = NULL; } if (conn->cli) { @@ -1709,7 +1715,7 @@ static void set_dc_type_and_flags_connect( struct winbindd_domain *domain ) DS_ROLE_BASIC_INFORMATION, &info, &werr); - TALLOC_FREE(cli); + cli_rpc_pipe_close(cli); if (!NT_STATUS_IS_OK(result)) { DEBUG(5, ("set_dc_type_and_flags_connect: rpccli_ds_getprimarydominfo " @@ -1743,7 +1749,7 @@ no_dssetup: DEBUG(5, ("set_dc_type_and_flags_connect: Could not bind to " "PI_LSARPC on domain %s: (%s)\n", domain->name, nt_errstr(result))); - TALLOC_FREE(cli); + cli_rpc_pipe_close(cli); TALLOC_FREE(mem_ctx); return; } @@ -1823,7 +1829,7 @@ done: DEBUG(5,("set_dc_type_and_flags_connect: domain %s is %srunning active directory.\n", domain->name, domain->active_directory ? "" : "NOT ")); - TALLOC_FREE(cli); + cli_rpc_pipe_close(cli); TALLOC_FREE(mem_ctx); @@ -1969,7 +1975,7 @@ NTSTATUS cm_connect_sam(struct winbindd_domain *domain, TALLOC_CTX *mem_ctx, DEBUG(10,("cm_connect_sam: ntlmssp-sealed rpccli_samr_Connect2 " "failed for domain %s, error was %s. Trying schannel\n", domain->name, nt_errstr(result) )); - TALLOC_FREE(conn->samr_pipe); + cli_rpc_pipe_close(conn->samr_pipe); schannel: @@ -2004,7 +2010,7 @@ NTSTATUS cm_connect_sam(struct winbindd_domain *domain, TALLOC_CTX *mem_ctx, DEBUG(10,("cm_connect_sam: schannel-sealed rpccli_samr_Connect2 failed " "for domain %s, error was %s. Trying anonymous\n", domain->name, nt_errstr(result) )); - TALLOC_FREE(conn->samr_pipe); + cli_rpc_pipe_close(conn->samr_pipe); anonymous: @@ -2106,7 +2112,7 @@ NTSTATUS cm_connect_lsa(struct winbindd_domain *domain, TALLOC_CTX *mem_ctx, DEBUG(10,("cm_connect_lsa: rpccli_lsa_open_policy failed, trying " "schannel\n")); - TALLOC_FREE(conn->lsa_pipe); + cli_rpc_pipe_close(conn->lsa_pipe); schannel: @@ -2141,7 +2147,7 @@ NTSTATUS cm_connect_lsa(struct winbindd_domain *domain, TALLOC_CTX *mem_ctx, DEBUG(10,("cm_connect_lsa: rpccli_lsa_open_policy failed, trying " "anonymous\n")); - TALLOC_FREE(conn->lsa_pipe); + cli_rpc_pipe_close(conn->lsa_pipe); anonymous: @@ -2216,7 +2222,7 @@ NTSTATUS cm_connect_netlogon(struct winbindd_domain *domain, if (!get_trust_pw_hash(domain->name, mach_pwd, &account_name, &sec_chan_type)) { - TALLOC_FREE(netlogon_pipe); + cli_rpc_pipe_close(netlogon_pipe); return NT_STATUS_CANT_ACCESS_DOMAIN_INFO; } @@ -2231,14 +2237,14 @@ NTSTATUS cm_connect_netlogon(struct winbindd_domain *domain, &neg_flags); if (!NT_STATUS_IS_OK(result)) { - TALLOC_FREE(netlogon_pipe); + cli_rpc_pipe_close(netlogon_pipe); return result; } if ((lp_client_schannel() == True) && ((neg_flags & NETLOGON_NEG_SCHANNEL) == 0)) { DEBUG(3, ("Server did not offer schannel\n")); - TALLOC_FREE(netlogon_pipe); + cli_rpc_pipe_close(netlogon_pipe); return NT_STATUS_ACCESS_DENIED; } @@ -2271,7 +2277,7 @@ NTSTATUS cm_connect_netlogon(struct winbindd_domain *domain, &result); /* We can now close the initial netlogon pipe. */ - TALLOC_FREE(netlogon_pipe); + cli_rpc_pipe_close(netlogon_pipe); if (conn->netlogon_pipe == NULL) { DEBUG(3, ("Could not open schannel'ed NETLOGON pipe. Error "