Revert "Refactoring: Make struct rpc_pipe_client its own talloc parent"
authorVolker Lendecke <vl@samba.org>
Fri, 25 Apr 2008 14:35:10 +0000 (16:35 +0200)
committerVolker Lendecke <vl@samba.org>
Fri, 25 Apr 2008 14:35:10 +0000 (16:35 +0200)
This reverts commit a6d74a5a562b54f0b36934965f545fdeb1e8b34a.

source/include/client.h
source/libsmb/clientgen.c
source/libsmb/passchange.c
source/rpc_client/cli_netlogon.c
source/rpc_client/cli_pipe.c
source/smbd/change_trust_pw.c

index 3c0b65576ca652ab9e5df14d8469cf7bc71c0b7d..0e73745edbb37d7252ab0541eced53af7ea8d5e0 100644 (file)
@@ -60,6 +60,8 @@ struct cli_pipe_auth_data {
 struct rpc_pipe_client {
        struct rpc_pipe_client *prev, *next;
 
+       TALLOC_CTX *mem_ctx;
+
        struct cli_state *cli;
 
        int pipe_idx;
index 860cb948ac1d99d21f148d58ffabc461f3d3bf7d..64191239d334dc84f9557c5f788d338512d359f2 100644 (file)
@@ -650,7 +650,7 @@ bool cli_rpc_pipe_close(struct rpc_pipe_client *cli)
                cli->pipe_name, cli->cli->desthost ));
 
        DLIST_REMOVE(cli->cli->pipe_list, cli);
-       talloc_destroy(cli);
+       talloc_destroy(cli->mem_ctx);
        return ret;
 }
 
index 2f9a87dee4a70aa10a8c0fe19531b5bccc0cc181..468750f8012a78627e209035d4287607b097b6ab 100644 (file)
@@ -177,9 +177,8 @@ NTSTATUS remote_password_change(const char *remote_machine, const char *user_nam
                }
        }
 
-       result = rpccli_samr_chgpasswd_user(pipe_hnd, talloc_tos(),
-                                           user_name, new_passwd, old_passwd);
-       if (NT_STATUS_IS_OK(result)) {
+       if (NT_STATUS_IS_OK(result = rpccli_samr_chgpasswd_user(pipe_hnd, pipe_hnd->mem_ctx, user_name, 
+                                                            new_passwd, old_passwd))) {
                /* Great - it all worked! */
                cli_shutdown(cli);
                return NT_STATUS_OK;
@@ -207,9 +206,11 @@ NTSTATUS remote_password_change(const char *remote_machine, const char *user_nam
        pipe_hnd = cli_rpc_pipe_open_noauth(cli, PI_SAMR, &result);
 
        if ( pipe_hnd &&
-               (NT_STATUS_IS_OK(result = rpccli_samr_chgpasswd_user(
-                                        pipe_hnd, talloc_tos(), user_name,
-                                        new_passwd, old_passwd)))) {
+               (NT_STATUS_IS_OK(result = rpccli_samr_chgpasswd_user(pipe_hnd,
+                                               pipe_hnd->mem_ctx,
+                                               user_name, 
+                                               new_passwd,
+                                               old_passwd)))) {
                /* Great - it all worked! */
                cli_shutdown(cli);
                return NT_STATUS_OK;
index 478a8558824be1a562aea6e606ed58e36f9baae5..851a4a8da825285befa304cfe822feef2cb13fa6 100644 (file)
@@ -159,7 +159,7 @@ NTSTATUS rpccli_netlogon_setup_creds(struct rpc_pipe_client *cli,
        generate_random_buffer(clnt_chal_send.data, 8);
 
        /* Get the server challenge. */
-       result = rpccli_netr_ServerReqChallenge(cli, talloc_tos(),
+       result = rpccli_netr_ServerReqChallenge(cli, cli->mem_ctx,
                                                dc->remote_machine,
                                                clnt_name,
                                                &clnt_chal_send,
@@ -180,7 +180,7 @@ NTSTATUS rpccli_netlogon_setup_creds(struct rpc_pipe_client *cli,
         * Send client auth-2 challenge and receive server repy.
         */
 
-       result = rpccli_netr_ServerAuthenticate2(cli, talloc_tos(),
+       result = rpccli_netr_ServerAuthenticate2(cli, cli->mem_ctx,
                                                 dc->remote_machine,
                                                 dc->mach_acct,
                                                 sec_chan_type,
index a94da8b79b9c272447bf86f85ee042a04961f30d..bc49e24df1dfdf07490327d3041d8946c47a2fa4 100644 (file)
@@ -1979,7 +1979,7 @@ static NTSTATUS rpc_finish_spnego_ntlmssp_bind(struct rpc_pipe_client *cli,
 
        /* Initialize the returning data struct. */
        prs_mem_free(rbuf);
-       prs_init_empty(rbuf, talloc_tos(), UNMARSHALL);
+       prs_init_empty(rbuf, cli->mem_ctx, UNMARSHALL);
 
        nt_status = rpc_api_pipe(cli, &rpc_out, rbuf, RPC_ALTCONTRESP);
        if (!NT_STATUS_IS_OK(nt_status)) {
@@ -2052,7 +2052,7 @@ static NTSTATUS rpc_pipe_bind(struct rpc_pipe_client *cli,
                return NT_STATUS_INVALID_PARAMETER;
        }
 
-       prs_init_empty(&rpc_out, talloc_tos(), MARSHALL);
+       prs_init_empty(&rpc_out, cli->mem_ctx, MARSHALL);
 
        rpc_call_id = get_rpc_call_id();
 
@@ -2068,7 +2068,7 @@ static NTSTATUS rpc_pipe_bind(struct rpc_pipe_client *cli,
        }
 
        /* Initialize the incoming data struct. */
-       prs_init_empty(&rbuf, talloc_tos(), UNMARSHALL);
+       prs_init_empty(&rbuf, cli->mem_ctx, UNMARSHALL);
 
        /* send data on \PIPE\.  receive a response */
        status = rpc_api_pipe(cli, &rpc_out, &rbuf, RPC_BINDACK);
@@ -2188,6 +2188,7 @@ static NTSTATUS rpc_pipe_bind(struct rpc_pipe_client *cli,
 
 static struct rpc_pipe_client *cli_rpc_pipe_open(struct cli_state *cli, int pipe_idx, NTSTATUS *perr)
 {
+       TALLOC_CTX *mem_ctx;
        struct rpc_pipe_client *result;
        int fnum;
 
@@ -2203,11 +2204,18 @@ static struct rpc_pipe_client *cli_rpc_pipe_open(struct cli_state *cli, int pipe
        /* The pipe name index must fall within our array */
        SMB_ASSERT((pipe_idx >= 0) && (pipe_idx < PI_MAX_PIPES));
 
-       result = TALLOC_ZERO_P(NULL, struct rpc_pipe_client);
+       mem_ctx = talloc_init("struct rpc_pipe_client");
+       if (mem_ctx == NULL) {
+               return NULL;
+       }
+
+       result = TALLOC_ZERO_P(mem_ctx, struct rpc_pipe_client);
        if (result == NULL) {
                return NULL;
        }
 
+       result->mem_ctx = mem_ctx;
+
        result->pipe_name = cli_get_pipe_name(pipe_idx);
 
        fnum = cli_nt_create(cli, result->pipe_name, DESIRED_ACCESS_PIPE);
@@ -2218,7 +2226,7 @@ static struct rpc_pipe_client *cli_rpc_pipe_open(struct cli_state *cli, int pipe
                         result->pipe_name, cli->desthost,
                         cli_errstr(cli)));
                *perr = cli_get_nt_error(cli);
-               talloc_destroy(result);
+               talloc_destroy(result->mem_ctx);
                return NULL;
        }
 
@@ -2230,9 +2238,9 @@ static struct rpc_pipe_client *cli_rpc_pipe_open(struct cli_state *cli, int pipe
 
        if (pipe_idx == PI_NETLOGON) {
                /* Set up a netlogon credential chain for a netlogon pipe. */
-               result->dc = TALLOC_ZERO_P(result, struct dcinfo);
+               result->dc = TALLOC_ZERO_P(mem_ctx, struct dcinfo);
                if (result->dc == NULL) {
-                       talloc_destroy(result);
+                       talloc_destroy(result->mem_ctx);
                        return NULL;
                }
        }
@@ -2517,8 +2525,7 @@ struct rpc_pipe_client *cli_rpc_pipe_open_schannel_with_key(struct cli_state *cl
                return NULL;
        }
 
-       result->auth.a_u.schannel_auth = TALLOC_ZERO_P(
-               result, struct schannel_auth_struct);
+       result->auth.a_u.schannel_auth = TALLOC_ZERO_P(result->mem_ctx, struct schannel_auth_struct);
        if (!result->auth.a_u.schannel_auth) {
                cli_rpc_pipe_close(result);
                *perr = NT_STATUS_NO_MEMORY;
@@ -2686,8 +2693,8 @@ struct rpc_pipe_client *cli_rpc_pipe_open_krb5(struct cli_state *cli,
 
        /* Default service principal is "desthost$@realm" */
        if (!service_princ) {
-               service_princ = talloc_asprintf(result, "%s$@%s",
-                                               cli->desthost, lp_realm() );
+               service_princ = talloc_asprintf(result->mem_ctx, "%s$@%s",
+                       cli->desthost, lp_realm() );
                if (!service_princ) {
                        cli_rpc_pipe_close(result);
                        return NULL;
@@ -2703,8 +2710,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);
+       result->auth.a_u.kerberos_auth = TALLOC_ZERO_P(result->mem_ctx, struct kerberos_auth_struct);
        if (!result->auth.a_u.kerberos_auth) {
                cli_rpc_pipe_close(result);
                *perr = NT_STATUS_NO_MEMORY;
index 227b2d689991064411c66f333fb4288f2c6e9f95..4773eeff8644d44e658ccdffe1198e6163cb44ac 100644 (file)
@@ -82,8 +82,7 @@ NTSTATUS change_trust_account_password( const char *domain, const char *remote_m
                goto failed;
        }
 
-       nt_status = trust_pw_find_change_and_store_it(
-               netlogon_pipe, netlogon_pipe, domain);
+       nt_status = trust_pw_find_change_and_store_it(netlogon_pipe, netlogon_pipe->mem_ctx, domain);
   
        cli_shutdown(cli);
        cli = NULL;