summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2008-07-20 10:40:43 +0200
committerVolker Lendecke <vl@samba.org>2008-07-20 17:06:21 +0200
commit2e905d2cd14b96af4ed8a912cc1f46c661e31756 (patch)
treeac32a99db8ce1a35613d7bcd571969a40a5c3ef3
parent65dfc40a4adc41fc45e48d96631238817cef8394 (diff)
downloadsamba-2e905d2cd14b96af4ed8a912cc1f46c661e31756.tar.gz
samba-2e905d2cd14b96af4ed8a912cc1f46c661e31756.tar.bz2
samba-2e905d2cd14b96af4ed8a912cc1f46c661e31756.zip
Allocate rpc_cli->dc in rpccli_netlogon_setup_creds()
The general cli_pipe routines should not have to know about this NETLOGON speciality. (This used to be commit d30237598d0c55b73e202c1de3a020194b67a7e6)
-rw-r--r--source3/rpc_client/cli_netlogon.c11
-rw-r--r--source3/rpc_client/cli_pipe.c30
2 files changed, 15 insertions, 26 deletions
diff --git a/source3/rpc_client/cli_netlogon.c b/source3/rpc_client/cli_netlogon.c
index cb1d93e9c1..7beaae2e22 100644
--- a/source3/rpc_client/cli_netlogon.c
+++ b/source3/rpc_client/cli_netlogon.c
@@ -136,13 +136,12 @@ NTSTATUS rpccli_netlogon_setup_creds(struct rpc_pipe_client *cli,
SMB_ASSERT(rpccli_is_pipe_idx(cli, PI_NETLOGON));
- dc = cli->dc;
- if (!dc) {
- return NT_STATUS_INVALID_PARAMETER;
+ TALLOC_FREE(cli->dc);
+ cli->dc = talloc_zero(cli, struct dcinfo);
+ if (cli->dc == NULL) {
+ return NT_STATUS_NO_MEMORY;
}
-
- /* Ensure we don't reuse any of this state. */
- ZERO_STRUCTP(dc);
+ dc = cli->dc;
/* Store the machine account password we're going to use. */
memcpy(dc->mach_pw, machine_pwd, 16);
diff --git a/source3/rpc_client/cli_pipe.c b/source3/rpc_client/cli_pipe.c
index af4c28195d..2aa96ab414 100644
--- a/source3/rpc_client/cli_pipe.c
+++ b/source3/rpc_client/cli_pipe.c
@@ -2818,7 +2818,7 @@ NTSTATUS rpc_pipe_open_ncalrpc(TALLOC_CTX *mem_ctx, const char *socket_path,
struct sockaddr_un addr;
NTSTATUS status;
- result = talloc(mem_ctx, struct rpc_pipe_client);
+ result = talloc_zero(mem_ctx, struct rpc_pipe_client);
if (result == NULL) {
return NT_STATUS_NO_MEMORY;
}
@@ -2847,12 +2847,6 @@ NTSTATUS rpc_pipe_open_ncalrpc(TALLOC_CTX *mem_ctx, const char *socket_path,
talloc_set_destructor(result, rpc_pipe_sock_destructor);
- result->dc = TALLOC_ZERO_P(result, struct dcinfo);
- if (result->dc == NULL) {
- status = NT_STATUS_NO_MEMORY;
- goto fail;
- }
-
ZERO_STRUCT(addr);
addr.sun_family = AF_UNIX;
strncpy(addr.sun_path, socket_path, sizeof(addr.sun_path));
@@ -2927,16 +2921,6 @@ static struct rpc_pipe_client *rpc_pipe_open_np(struct cli_state *cli, int pipe_
return NULL;
}
- if (pipe_idx == PI_NETLOGON) {
- /* Set up a netlogon credential chain for a netlogon pipe. */
- result->dc = TALLOC_ZERO_P(result, struct dcinfo);
- if (result->dc == NULL) {
- *perr = NT_STATUS_NO_MEMORY;
- TALLOC_FREE(result);
- return NULL;
- }
- }
-
fnum = cli_nt_create(cli, result->trans.np.pipe_name,
DESIRED_ACCESS_PIPE);
if (fnum == -1) {
@@ -3267,9 +3251,15 @@ struct rpc_pipe_client *cli_rpc_pipe_open_schannel_with_key(struct cli_state *cl
return NULL;
}
- /* The credentials on a new netlogon pipe are the ones we are passed in - copy them over. */
- if (result->dc) {
- *result->dc = *pdc;
+ /*
+ * The credentials on a new netlogon pipe are the ones we are passed
+ * in - copy them over.
+ */
+ result->dc = (struct dcinfo *)talloc_memdup(result, pdc, sizeof(*pdc));
+ if (result->dc == NULL) {
+ DEBUG(0, ("talloc failed\n"));
+ TALLOC_FREE(result);
+ return NULL;
}
DEBUG(10,("cli_rpc_pipe_open_schannel_with_key: opened pipe %s to machine %s "