From: Stefan Metzmacher Date: Mon, 16 Sep 2024 20:10:00 +0000 (+0200) Subject: s3:rpc_client: let cli_rpc_pipe_open() use rpc_client_connection_np() X-Git-Tag: samba-4.21.7~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cb3e074ec54f41a6cdb223d1954c16d9d3e4f3ce;p=thirdparty%2Fsamba.git s3:rpc_client: let cli_rpc_pipe_open() use rpc_client_connection_np() 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 Reviewed-by: Ralph Boehme (cherry picked from commit fab0d27c5cf4885c31d7ed04ea69eda7992ea209) --- diff --git a/source3/rpc_client/cli_pipe.c b/source3/rpc_client/cli_pipe.c index 2766ff2f4fd..74e471d978b 100644 --- a/source3/rpc_client/cli_pipe.c +++ b/source3/rpc_client/cli_pipe.c @@ -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; diff --git a/source3/rpc_client/cli_pipe.h b/source3/rpc_client/cli_pipe.h index e6a66bbbe15..9dc46e755ea 100644 --- a/source3/rpc_client/cli_pipe.h +++ b/source3/rpc_client/cli_pipe.h @@ -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);