From 826223cc8d36871c2bcb37fe23241f1dbe99a0db Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 17 May 2017 13:53:19 +0200 Subject: [PATCH] s3:libnet_join: calculate r->out.account_name in libnet_join_pre_processing() BUG: https://bugzilla.samba.org/show_bug.cgi?id=12782 Signed-off-by: Stefan Metzmacher Reviewed-by: Andreas Schneider --- source3/libnet/libnet_join.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/source3/libnet/libnet_join.c b/source3/libnet/libnet_join.c index e33c3838866..1e290d78570 100644 --- a/source3/libnet/libnet_join.c +++ b/source3/libnet/libnet_join.c @@ -1122,7 +1122,6 @@ static NTSTATUS libnet_join_joindomain_rpc_unsecure(TALLOC_CTX *mem_ctx, struct rpc_pipe_client *netlogon_pipe = NULL; struct netlogon_creds_cli_context *netlogon_creds = NULL; struct samr_Password current_nt_hash; - const char *account_name = NULL; NTSTATUS status; status = cli_rpc_pipe_open_noauth(cli, &ndr_table_netlogon, @@ -1147,16 +1146,9 @@ static NTSTATUS libnet_join_joindomain_rpc_unsecure(TALLOC_CTX *mem_ctx, /* according to WKSSVC_JOIN_FLAGS_MACHINE_PWD_PASSED */ E_md4hash(r->in.admin_password, current_nt_hash.hash); - account_name = talloc_asprintf(frame, "%s$", - r->in.machine_name); - if (account_name == NULL) { - TALLOC_FREE(frame); - return NT_STATUS_NO_MEMORY; - } - status = rpccli_create_netlogon_creds(netlogon_pipe->desthost, r->in.domain_name, - account_name, + r->out.account_name, r->in.secure_channel_type, r->in.msg_ctx, frame, @@ -2111,6 +2103,14 @@ static WERROR libnet_join_pre_processing(TALLOC_CTX *mem_ctx, return WERR_INVALID_PARAMETER; } + r->out.account_name = talloc_asprintf(mem_ctx, "%s$", + r->in.machine_name); + if (r->out.account_name == NULL) { + libnet_join_set_error_string(mem_ctx, r, + "Unable to construct r->out.account_name"); + return WERR_NOT_ENOUGH_MEMORY; + } + if (!libnet_parse_domain_dc(mem_ctx, r->in.domain_name, &r->in.domain_name, &r->in.dc_name)) {