s3:rpc_client: Add remote name and socket to cli_rpc_pipe_open_bind_schannel()
authorAndreas Schneider <asn@samba.org>
Thu, 18 Nov 2021 10:47:26 +0000 (11:47 +0100)
committerAndreas Schneider <asn@cryptomilk.org>
Thu, 2 Dec 2021 13:59:31 +0000 (13:59 +0000)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14767

Pair-Programmed-With: Andreas Schneider <asn@samba.org>
Signed-off-by: Guenther Deschner <gd@samba.org>
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
source3/rpc_client/cli_netlogon.c
source3/rpc_client/cli_pipe.c
source3/rpc_client/cli_pipe.h
source3/rpc_client/cli_pipe_schannel.c
source3/rpcclient/rpcclient.c
source3/utils/net_rpc.c

index c5a967a64a443268d0dfd5dd32336cc015c93e30..049186e5a515630e80d746e964b9f39f423c2a57 100644 (file)
@@ -368,15 +368,22 @@ again:
                }
        }
 
+       remote_name = smbXcli_conn_remote_name(cli->conn);
+       remote_sockaddr = smbXcli_conn_remote_sockaddr(cli->conn);
+
        do_serverauth = force_reauth || !found_existing_creds;
 
        if (!do_serverauth) {
                /*
                 * Do the quick schannel bind without a reauth
                 */
-               status = cli_rpc_pipe_open_bind_schannel(
-                       cli, &ndr_table_netlogon, transport, creds_ctx,
-                       &rpccli);
+               status = cli_rpc_pipe_open_bind_schannel(cli,
+                                                        &ndr_table_netlogon,
+                                                        transport,
+                                                        creds_ctx,
+                                                        remote_name,
+                                                        remote_sockaddr,
+                                                        &rpccli);
                if (!retry && NT_STATUS_EQUAL(status, NT_STATUS_NETWORK_ACCESS_DENIED)) {
                        DBG_DEBUG("Retrying with serverauthenticate\n");
                        TALLOC_FREE(lck);
@@ -426,9 +433,6 @@ again:
                        goto fail;
                }
 
-               remote_name = smbXcli_conn_remote_name(cli->conn);
-               remote_sockaddr = smbXcli_conn_remote_sockaddr(cli->conn);
-
                status = cli_rpc_pipe_open_noauth_transport(cli,
                                                            transport,
                                                            &ndr_table_netlogon,
@@ -443,8 +447,13 @@ again:
                goto done;
        }
 
-       status = cli_rpc_pipe_open_bind_schannel(
-               cli, &ndr_table_netlogon, transport, creds_ctx, &rpccli);
+       status = cli_rpc_pipe_open_bind_schannel(cli,
+                                                &ndr_table_netlogon,
+                                                transport,
+                                                creds_ctx,
+                                                remote_name,
+                                                remote_sockaddr,
+                                                &rpccli);
        if (!NT_STATUS_IS_OK(status)) {
                DBG_DEBUG("cli_rpc_pipe_open_bind_schannel "
                          "failed: %s\n", nt_errstr(status));
index ddb1a73a3f66107f481cd8a183599f2f8a60b21c..7e62907256b2ca24a2755947e0f995584c5df270 100644 (file)
@@ -3320,6 +3320,8 @@ NTSTATUS cli_rpc_pipe_open_bind_schannel(
        const struct ndr_interface_table *table,
        enum dcerpc_transport_t transport,
        struct netlogon_creds_cli_context *netlogon_creds,
+       const char *remote_name,
+       const struct sockaddr_storage *remote_sockaddr,
        struct rpc_pipe_client **_rpccli)
 {
        struct rpc_pipe_client *rpccli;
@@ -3328,9 +3330,6 @@ NTSTATUS cli_rpc_pipe_open_bind_schannel(
        struct cli_credentials *cli_creds;
        enum dcerpc_AuthLevel auth_level;
        NTSTATUS status;
-       const char *remote_name = smbXcli_conn_remote_name(cli->conn);
-       const struct sockaddr_storage *remote_sockaddr =
-               smbXcli_conn_remote_sockaddr(cli->conn);
 
        status = cli_rpc_pipe_open(cli,
                                   transport,
@@ -3395,6 +3394,9 @@ NTSTATUS cli_rpc_pipe_open_schannel_with_creds(struct cli_state *cli,
        struct rpc_pipe_client *rpccli;
        struct netlogon_creds_cli_lck *lck;
        NTSTATUS status;
+       const char *remote_name = smbXcli_conn_remote_name(cli->conn);
+       const struct sockaddr_storage *remote_sockaddr =
+               smbXcli_conn_remote_sockaddr(cli->conn);
 
        status = netlogon_creds_cli_lck(
                netlogon_creds, NETLOGON_CREDS_CLI_LCK_EXCLUSIVE,
@@ -3406,8 +3408,13 @@ NTSTATUS cli_rpc_pipe_open_schannel_with_creds(struct cli_state *cli,
                return status;
        }
 
-       status = cli_rpc_pipe_open_bind_schannel(
-               cli, table, transport, netlogon_creds, &rpccli);
+       status = cli_rpc_pipe_open_bind_schannel(cli,
+                                                table,
+                                                transport,
+                                                netlogon_creds,
+                                                remote_name,
+                                                remote_sockaddr,
+                                                &rpccli);
        if (NT_STATUS_EQUAL(status, NT_STATUS_NETWORK_ACCESS_DENIED)) {
                netlogon_creds_cli_delete_lck(netlogon_creds);
        }
index f9392515e69e08e803543e14d095f83944858540..43cd5f0b96cfb3ace3350d94eecdacdba840d12c 100644 (file)
@@ -89,6 +89,8 @@ NTSTATUS cli_rpc_pipe_open_bind_schannel(
        const struct ndr_interface_table *table,
        enum dcerpc_transport_t transport,
        struct netlogon_creds_cli_context *netlogon_creds,
+       const char *remote_name,
+       const struct sockaddr_storage *remote_sockaddr,
        struct rpc_pipe_client **_rpccli);
 NTSTATUS cli_rpc_pipe_open_schannel_with_creds(struct cli_state *cli,
                                               const struct ndr_interface_table *table,
@@ -101,6 +103,8 @@ NTSTATUS cli_rpc_pipe_open_schannel(struct cli_state *cli,
                                    const struct ndr_interface_table *table,
                                    enum dcerpc_transport_t transport,
                                    const char *domain,
+                                   const char *remote_name,
+                                   const struct sockaddr_storage *remote_sockaddr,
                                    struct rpc_pipe_client **presult,
                                    TALLOC_CTX *mem_ctx,
                                    struct netlogon_creds_cli_context **pcreds);
index 8a8177be2e550802a3ae5642413f99f0e24d3414..9877ea6c5422c7e38b0144b59fc452d9c3ca1b94 100644 (file)
@@ -42,12 +42,13 @@ NTSTATUS cli_rpc_pipe_open_schannel(struct cli_state *cli,
                                    const struct ndr_interface_table *table,
                                    enum dcerpc_transport_t transport,
                                    const char *domain,
+                                   const char *remote_name,
+                                   const struct sockaddr_storage *remote_sockaddr,
                                    struct rpc_pipe_client **presult,
                                    TALLOC_CTX *mem_ctx,
                                    struct netlogon_creds_cli_context **pcreds)
 {
        TALLOC_CTX *frame = talloc_stackframe();
-       const char *dc_name = smbXcli_conn_remote_name(cli->conn);
        struct rpc_pipe_client *result = NULL;
        NTSTATUS status;
        struct cli_credentials *cli_creds = NULL;
@@ -63,7 +64,7 @@ NTSTATUS cli_rpc_pipe_open_schannel(struct cli_state *cli,
        }
 
        status = rpccli_create_netlogon_creds_ctx(cli_creds,
-                                                 dc_name,
+                                                 remote_name,
                                                  msg_ctx,
                                                  frame,
                                                  &netlogon_creds);
index a85f037728539a468492d8bb1923d8c7010efa32..b89534f22254e4156de176f1e26b58cc34c6d0e1 100644 (file)
@@ -970,6 +970,8 @@ static NTSTATUS do_cmd(struct cli_state *cli,
                                        cmd_entry->table,
                                        transport,
                                        rpcclient_netlogon_domain,
+                                       remote_name,
+                                       remote_sockaddr,
                                        &cmd_entry->rpc_pipe,
                                        rpcclient_msg_ctx,
                                        &rpcclient_netlogon_creds);
index b871dc3b1f59f0f5fe39debb9149f8f49a2c69e8..97c0158d612f26d53f48c006877d8729e165f1b5 100644 (file)
@@ -188,11 +188,18 @@ int run_rpc_command(struct net_context *c,
                if (lp_client_schannel()
                    && (ndr_syntax_id_equal(&table->syntax_id,
                                            &ndr_table_netlogon.syntax_id))) {
+                       const char *remote_name =
+                               smbXcli_conn_remote_name(cli->conn);
+                       const struct sockaddr_storage *remote_sockaddr =
+                               smbXcli_conn_remote_sockaddr(cli->conn);
+
                        /* Always try and create an schannel netlogon pipe. */
                        TALLOC_FREE(c->netlogon_creds);
                        nt_status = cli_rpc_pipe_open_schannel(
                                cli, c->msg_ctx, table, NCACN_NP,
                                domain_name,
+                               remote_name,
+                               remote_sockaddr,
                                &pipe_hnd, c, &c->netlogon_creds);
                        if (!NT_STATUS_IS_OK(nt_status)) {
                                DEBUG(0, ("Could not initialise schannel netlogon pipe. Error was %s\n",