s3:rpc_client: use netlogon_creds_copy before rpc_pipe_bind
authorStefan Metzmacher <metze@samba.org>
Thu, 25 Apr 2013 17:45:52 +0000 (19:45 +0200)
committerStefan Metzmacher <metze@samba.org>
Sat, 10 Aug 2013 07:18:54 +0000 (09:18 +0200)
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source3/rpc_client/cli_pipe.c

index 477853494aa64ada503704aefcf9079555eb8372..8775c3b03d31b520815db6cf933fe00cdaf60bb8 100644 (file)
@@ -3019,6 +3019,18 @@ NTSTATUS cli_rpc_pipe_open_schannel_with_key(struct cli_state *cli,
                return status;
        }
 
+       /*
+        * The credentials on a new netlogon pipe are the ones we are passed
+        * in - copy them over
+        *
+        * This may get overwritten... in rpc_pipe_bind()...
+        */
+       rpccli->dc = netlogon_creds_copy(rpccli, *pdc);
+       if (rpccli->dc == NULL) {
+               TALLOC_FREE(rpccli);
+               return NT_STATUS_NO_MEMORY;
+       }
+
        status = rpc_pipe_bind(rpccli, rpcauth);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0, ("cli_rpc_pipe_open_schannel_with_key: "
@@ -3028,18 +3040,6 @@ NTSTATUS cli_rpc_pipe_open_schannel_with_key(struct cli_state *cli,
                return status;
        }
 
-       /*
-        * The credentials on a new netlogon pipe are the ones we are passed
-        * in - copy them over
-        */
-       if (rpccli->dc == NULL) {
-               rpccli->dc = netlogon_creds_copy(rpccli, *pdc);
-               if (rpccli->dc == NULL) {
-                       TALLOC_FREE(rpccli);
-                       return NT_STATUS_NO_MEMORY;
-               }
-       }
-
        DEBUG(10,("cli_rpc_pipe_open_schannel_with_key: opened pipe %s to machine %s "
                  "for domain %s and bound using schannel.\n",
                  get_pipe_name_from_syntax(talloc_tos(), &table->syntax_id),