]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:rpc_client: let cli_rpc_pipe_open() use rpc_client_connection_np()
authorStefan Metzmacher <metze@samba.org>
Mon, 16 Sep 2024 20:10:00 +0000 (22:10 +0200)
committerJule Anger <janger@samba.org>
Thu, 12 Jun 2025 11:27:15 +0000 (11:27 +0000)
This way cli_rpc_pipe_open() uses the same flow for
rpc_client_connection_np() and rpc_pipe_open_tcp_port().

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
(cherry picked from commit fab0d27c5cf4885c31d7ed04ea69eda7992ea209)

source3/rpc_client/cli_pipe.c
source3/rpc_client/cli_pipe.h

index 2766ff2f4fd1e78c9f7a4768848c3b72df4c322e..74e471d978b3049f0b1e18c1c589072bd3a2a15c 100644 (file)
@@ -3563,6 +3563,32 @@ static NTSTATUS rpc_client_connection_np_recv(
        return NT_STATUS_OK;
 }
 
+static NTSTATUS rpc_client_connection_np(struct cli_state *cli,
+                                        const struct rpc_client_association *assoc,
+                                        struct rpc_client_connection **pconn)
+{
+       struct tevent_context *ev = NULL;
+       struct tevent_req *req = NULL;
+       NTSTATUS status = NT_STATUS_NO_MEMORY;
+
+       ev = samba_tevent_context_init(cli);
+       if (ev == NULL) {
+               goto fail;
+       }
+       req = rpc_client_connection_np_send(ev, ev, cli, assoc);
+       if (req == NULL) {
+               goto fail;
+       }
+       if (!tevent_req_poll_ntstatus(req, ev, &status)) {
+               goto fail;
+       }
+       status = rpc_client_connection_np_recv(req, NULL, pconn);
+fail:
+       TALLOC_FREE(req);
+       TALLOC_FREE(ev);
+       return status;
+}
+
 struct rpc_pipe_open_np_state {
        struct cli_state *cli;
        const struct ndr_interface_table *table;
@@ -3671,32 +3697,6 @@ NTSTATUS rpc_pipe_open_np_recv(
        return NT_STATUS_OK;
 }
 
-NTSTATUS rpc_pipe_open_np(struct cli_state *cli,
-                         const struct ndr_interface_table *table,
-                         struct rpc_pipe_client **presult)
-{
-       struct tevent_context *ev = NULL;
-       struct tevent_req *req = NULL;
-       NTSTATUS status = NT_STATUS_NO_MEMORY;
-
-       ev = samba_tevent_context_init(cli);
-       if (ev == NULL) {
-               goto fail;
-       }
-       req = rpc_pipe_open_np_send(ev, ev, cli, table);
-       if (req == NULL) {
-               goto fail;
-       }
-       if (!tevent_req_poll_ntstatus(req, ev, &status)) {
-               goto fail;
-       }
-       status = rpc_pipe_open_np_recv(req, NULL, presult);
-fail:
-       TALLOC_FREE(req);
-       TALLOC_FREE(ev);
-       return status;
-}
-
 /****************************************************************************
  Open a pipe to a remote server.
  ****************************************************************************/
@@ -3786,8 +3786,15 @@ static NTSTATUS cli_rpc_pipe_open(struct cli_state *cli,
                talloc_steal(frame, conn);
                break;
        case NCACN_NP:
-               TALLOC_FREE(frame);
-               return rpc_pipe_open_np(cli, table, presult);
+               status = rpc_client_connection_np(cli,
+                                                 assoc,
+                                                 &conn);
+               if (!NT_STATUS_IS_OK(status)) {
+                       TALLOC_FREE(frame);
+                       return status;
+               }
+               talloc_steal(frame, conn);
+               break;
        default:
                TALLOC_FREE(frame);
                return NT_STATUS_NOT_IMPLEMENTED;
index e6a66bbbe158ebc1f24fb577f1934d3995cf5183..9dc46e755ead569212588f8234dff10ac2334a0b 100644 (file)
@@ -47,9 +47,6 @@ NTSTATUS rpc_pipe_open_np_recv(
        struct tevent_req *req,
        TALLOC_CTX *mem_ctx,
        struct rpc_pipe_client **_result);
-NTSTATUS rpc_pipe_open_np(struct cli_state *cli,
-                         const struct ndr_interface_table *table,
-                         struct rpc_pipe_client **presult);
 
 unsigned int rpccli_set_timeout(struct rpc_pipe_client *cli,
                                unsigned int timeout);