]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:libnet_join: calculate r->out.account_name in libnet_join_pre_processing()
authorStefan Metzmacher <metze@samba.org>
Wed, 17 May 2017 11:53:19 +0000 (13:53 +0200)
committerStefan Metzmacher <metze@samba.org>
Thu, 13 Jul 2017 08:51:17 +0000 (10:51 +0200)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12782

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
(cherry picked from commit 826223cc8d36871c2bcb37fe23241f1dbe99a0db)

source3/libnet/libnet_join.c

index 5089f25967b974f59e46ebfe5e523e102ff830dc..b16a0c0f48503f00b786cb43ffbb2b4c4d8193f9 100644 (file)
@@ -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,
@@ -2119,6 +2111,14 @@ static WERROR libnet_join_pre_processing(TALLOC_CTX *mem_ctx,
                return WERR_INVALID_PARAM;
         }
 
+       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)) {