cli_netlogon: Eliminate rpccli_setup_netlogon_creds_with_creds
authorVolker Lendecke <vl@samba.org>
Wed, 6 Sep 2017 15:31:38 +0000 (17:31 +0200)
committerAndrew Bartlett <abartlet@samba.org>
Sat, 16 Sep 2017 06:36:17 +0000 (08:36 +0200)
Inlining the code from rpccli_setup_netlogon_creds

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source3/libnet/libnet_join.c
source3/rpc_client/cli_netlogon.c
source3/rpc_client/cli_netlogon.h
source3/rpc_client/cli_pipe_schannel.c
source3/rpcclient/rpcclient.c
source3/winbindd/winbindd_cm.c

index e588001d7d6156566306fd0173805688a90e1876..5880913a39f4bcba6905deabe2d53c0a6bf21a24 100644 (file)
@@ -1174,7 +1174,7 @@ static NTSTATUS libnet_join_joindomain_rpc_unsecure(TALLOC_CTX *mem_ctx,
                return status;
        }
 
-       status = rpccli_setup_netlogon_creds_with_creds(
+       status = rpccli_setup_netlogon_creds(
                cli, NCACN_NP, netlogon_creds, true /* force_reauth */,
                cli_creds);
        if (!NT_STATUS_IS_OK(status)) {
@@ -1628,10 +1628,10 @@ NTSTATUS libnet_join_ok(struct messaging_context *msg_ctx,
                return status;
        }
 
-       status = rpccli_setup_netlogon_creds_with_creds(cli, NCACN_NP,
-                                                       netlogon_creds,
-                                                       true, /* force_reauth */
-                                                       cli_creds);
+       status = rpccli_setup_netlogon_creds(cli, NCACN_NP,
+                                            netlogon_creds,
+                                            true, /* force_reauth */
+                                            cli_creds);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0,("connect_to_domain_password_server: "
                         "unable to open the domain client session to "
index 75234a6799c48f4d6d6ab542748bb6b5748c297c..2c3e205e2f4dbb39777acfb3487552118f6f4aca 100644 (file)
@@ -157,13 +157,12 @@ NTSTATUS rpccli_create_netlogon_creds_ctx(
                                            netlogon_creds);
 }
 
-static NTSTATUS rpccli_setup_netlogon_creds(
+NTSTATUS rpccli_setup_netlogon_creds(
        struct cli_state *cli,
        enum dcerpc_transport_t transport,
        struct netlogon_creds_cli_context *netlogon_creds,
        bool force_reauth,
-       struct samr_Password current_nt_hash,
-       const struct samr_Password *previous_nt_hash)
+       struct cli_credentials *cli_creds)
 {
        TALLOC_CTX *frame = talloc_stackframe();
        struct rpc_pipe_client *netlogon_pipe = NULL;
@@ -193,6 +192,19 @@ static NTSTATUS rpccli_setup_netlogon_creds(
                TALLOC_FREE(creds);
        }
 
+       nt_hashes[0] = cli_credentials_get_nt_hash(cli_creds, talloc_tos());
+       if (nt_hashes[0] == NULL) {
+               TALLOC_FREE(frame);
+               return NT_STATUS_NO_MEMORY;
+       }
+       num_nt_hashes = 1;
+
+       nt_hashes[1] = cli_credentials_get_old_nt_hash(cli_creds,
+                                                      talloc_tos());
+       if (nt_hashes[1] != NULL) {
+               num_nt_hashes = 2;
+       }
+
        status = cli_rpc_pipe_open_noauth_transport(cli,
                                                    transport,
                                                    &ndr_table_netlogon,
@@ -207,13 +219,6 @@ static NTSTATUS rpccli_setup_netlogon_creds(
        }
        talloc_steal(frame, netlogon_pipe);
 
-       nt_hashes[0] = &current_nt_hash;
-       num_nt_hashes = 1;
-       if (previous_nt_hash != NULL) {
-               nt_hashes[1] = previous_nt_hash;
-               num_nt_hashes = 2;
-       }
-
        status = netlogon_creds_cli_auth(netlogon_creds,
                                         netlogon_pipe->binding_handle,
                                         num_nt_hashes,
@@ -240,37 +245,6 @@ static NTSTATUS rpccli_setup_netlogon_creds(
        return NT_STATUS_OK;
 }
 
-NTSTATUS rpccli_setup_netlogon_creds_with_creds(struct cli_state *cli,
-                                               enum dcerpc_transport_t transport,
-                                               struct netlogon_creds_cli_context *netlogon_creds,
-                                               bool force_reauth,
-                                               struct cli_credentials *creds)
-{
-       struct samr_Password *current_nt_hash = NULL;
-       struct samr_Password *previous_nt_hash = NULL;
-       NTSTATUS status;
-
-       current_nt_hash = cli_credentials_get_nt_hash(creds, talloc_tos());
-       if (current_nt_hash == NULL) {
-               return NT_STATUS_NO_MEMORY;
-       }
-
-       previous_nt_hash = cli_credentials_get_old_nt_hash(creds, talloc_tos());
-
-       status = rpccli_setup_netlogon_creds(cli, transport,
-                                            netlogon_creds,
-                                            force_reauth,
-                                            *current_nt_hash,
-                                            previous_nt_hash);
-       TALLOC_FREE(current_nt_hash);
-       TALLOC_FREE(previous_nt_hash);
-       if (!NT_STATUS_IS_OK(status)) {
-               return status;
-       }
-
-       return NT_STATUS_OK;
-}
-
 static NTSTATUS map_validation_to_info3(TALLOC_CTX *mem_ctx,
                                        uint16_t validation_level,
                                        union netr_Validation *validation,
index 62cdc63e77e76dda23dfc0cb01ac1763c4d24e35..d66bcd3b55bf8f77a8874c1df840b2f4097757f0 100644 (file)
@@ -39,11 +39,12 @@ NTSTATUS rpccli_create_netlogon_creds_ctx(
        struct messaging_context *msg_ctx,
        TALLOC_CTX *mem_ctx,
        struct netlogon_creds_cli_context **netlogon_creds);
-NTSTATUS rpccli_setup_netlogon_creds_with_creds(struct cli_state *cli,
-                                               enum dcerpc_transport_t transport,
-                                               struct netlogon_creds_cli_context *netlogon_creds,
-                                               bool force_reauth,
-                                               struct cli_credentials *creds);
+NTSTATUS rpccli_setup_netlogon_creds(
+       struct cli_state *cli,
+       enum dcerpc_transport_t transport,
+       struct netlogon_creds_cli_context *netlogon_creds,
+       bool force_reauth,
+       struct cli_credentials *cli_creds);
 NTSTATUS rpccli_netlogon_password_logon(struct netlogon_creds_cli_context *creds,
                                        struct dcerpc_binding_handle *binding_handle,
                                        TALLOC_CTX *mem_ctx,
index 0a1dd79b98691d45db03e7b6bb2b7bc2973a79dd..a94429538c75d73b6e36d2df1e490f7bd93f8659 100644 (file)
@@ -72,7 +72,7 @@ NTSTATUS cli_rpc_pipe_open_schannel(struct cli_state *cli,
                return status;
        }
 
-       status = rpccli_setup_netlogon_creds_with_creds(cli, transport,
+       status = rpccli_setup_netlogon_creds(cli, transport,
                                             netlogon_creds,
                                             false, /* force_reauth */
                                             cli_creds);
index 05bbb0b478bae4f3d08966e43f72794febf56b8a..c1039ed84c57a98e403ed4c2be6c8996167f3e54 100644 (file)
@@ -816,11 +816,12 @@ static NTSTATUS do_cmd(struct cli_state *cli,
                                return ntresult;
                        }
 
-                       ntresult = rpccli_setup_netlogon_creds_with_creds(cli,
-                                                       NCACN_NP,
-                                                       rpcclient_netlogon_creds,
-                                                       false, /* force_reauth */
-                                                       creds);
+                       ntresult = rpccli_setup_netlogon_creds(
+                               cli,
+                               NCACN_NP,
+                               rpcclient_netlogon_creds,
+                               false, /* force_reauth */
+                               creds);
                        TALLOC_FREE(creds);
                        if (!NT_STATUS_IS_OK(ntresult)) {
                                DEBUG(0, ("Could not initialise credentials for %s.\n",
index 5fd8f086b873d60191353b962fc3573b0ee9beef..b2d14c47b40cc19dac8bebf7cf3ae96cd9a7389b 100644 (file)
@@ -3289,10 +3289,10 @@ static NTSTATUS cm_connect_netlogon_transport(struct winbindd_domain *domain,
                return result;
        }
 
-       result = rpccli_setup_netlogon_creds_with_creds(conn->cli, transport,
-                                               conn->netlogon_creds_ctx,
-                                               conn->netlogon_force_reauth,
-                                               creds);
+       result = rpccli_setup_netlogon_creds(conn->cli, transport,
+                                            conn->netlogon_creds_ctx,
+                                            conn->netlogon_force_reauth,
+                                            creds);
        conn->netlogon_force_reauth = false;
        if (!NT_STATUS_IS_OK(result)) {
                DEBUG(1, ("rpccli_setup_netlogon_creds failed for %s, "