From 8aa96566a96413384b7c8af0143c4ed1af100492 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Wed, 28 Apr 2010 09:51:12 -0400 Subject: s3-rpc_server: Created a per connection spoolss pipe. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This way all code can reuse the same connection to spoolss and not have to deal with the creation of a new pipe all over the code every time we need to ask a service off spoolss. Signed-off-by: Günther Deschner --- source3/rpc_server/srv_pipe_hnd.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 847953d186..075d705ef0 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -20,6 +20,7 @@ */ #include "includes.h" +#include "../librpc/gen_ndr/srv_spoolss.h" #include "librpc/gen_ndr/ndr_named_pipe_auth.h" #undef DBGC_CLASS @@ -1516,3 +1517,35 @@ NTSTATUS rpc_pipe_open_internal(TALLOC_CTX *mem_ctx, *presult = result; return NT_STATUS_OK; } + +/** + * @brief Create a new RPC client context which uses a local dispatch function. + * + * @param[in] conn The connection struct that will hold the pipe + * + * @param[out] spoolss_pipe A pointer to the connected rpc client pipe. + * + * @return NT_STATUS_OK on success, a corresponding NT status if an + * error occured. + */ +NTSTATUS rpc_connect_spoolss_pipe(connection_struct *conn, + struct rpc_pipe_client **spoolss_pipe) +{ + NTSTATUS status; + + /* TODO: check and handle disconnections */ + + if (!conn->spoolss_pipe) { + status = rpc_pipe_open_internal(conn, + &ndr_table_spoolss.syntax_id, + rpc_spoolss_dispatch, + conn->server_info, + &conn->spoolss_pipe); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + } + + *spoolss_pipe = conn->spoolss_pipe; + return NT_STATUS_OK; +} -- cgit