diff options
author | Simo Sorce <idra@samba.org> | 2010-04-28 09:51:12 -0400 |
---|---|---|
committer | Günther Deschner <gd@samba.org> | 2010-05-26 15:07:57 +0200 |
commit | 8aa96566a96413384b7c8af0143c4ed1af100492 (patch) | |
tree | 656fb67679b91a2d024f1b735ea9e1e389568e36 /source3 | |
parent | 83b2fd30215c5286f0f05bddce76bd5e0959c5c8 (diff) | |
download | samba-8aa96566a96413384b7c8af0143c4ed1af100492.tar.gz samba-8aa96566a96413384b7c8af0143c4ed1af100492.tar.bz2 samba-8aa96566a96413384b7c8af0143c4ed1af100492.zip |
s3-rpc_server: Created a per connection spoolss pipe.
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 <gd@samba.org>
Diffstat (limited to 'source3')
-rw-r--r-- | source3/include/proto.h | 2 | ||||
-rw-r--r-- | source3/include/smb.h | 3 | ||||
-rw-r--r-- | source3/rpc_server/srv_pipe_hnd.c | 33 |
3 files changed, 38 insertions, 0 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h index f7d9f39258..3bff172d4f 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -4899,6 +4899,8 @@ NTSTATUS rpc_pipe_open_internal(TALLOC_CTX *mem_ctx, const struct ndr_syntax_id NTSTATUS (*dispatch) (struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, const struct ndr_interface_table *table, uint32_t opnum, void *r), struct auth_serversupplied_info *serversupplied_info, struct rpc_pipe_client **presult); +NTSTATUS rpc_connect_spoolss_pipe(connection_struct *conn, + struct rpc_pipe_client **spoolss_pipe); NTSTATUS cli_rpc_pipe_open_noauth(struct cli_state *cli, const struct ndr_syntax_id *interface, struct rpc_pipe_client **presult); diff --git a/source3/include/smb.h b/source3/include/smb.h index 1ceb54b792..a93caa7bf1 100644 --- a/source3/include/smb.h +++ b/source3/include/smb.h @@ -592,6 +592,9 @@ typedef struct connection_struct { struct dfree_cached_info *dfree_info; struct trans_state *pending_trans; struct notify_context *notify_ctx; + + struct rpc_pipe_client *spoolss_pipe; + } connection_struct; struct current_user { 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; +} |