s3-rpc_server: Created a per connection spoolss pipe.
authorSimo Sorce <idra@samba.org>
Wed, 28 Apr 2010 13:51:12 +0000 (09:51 -0400)
committerGünther Deschner <gd@samba.org>
Wed, 26 May 2010 13:07:57 +0000 (15:07 +0200)
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>
source3/include/proto.h
source3/include/smb.h
source3/rpc_server/srv_pipe_hnd.c

index f7d9f392580a632c557bc5c89b85783e339c3292..3bff172d4fc1329420c6ba0572dc06f3ad4003ca 100644 (file)
@@ -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);
index 1ceb54b7926976b33900365e021d7f7e4a90d48c..a93caa7bf1b5120de04e67f77b41e2020d6f1b39 100644 (file)
@@ -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 {
index 847953d1862528914d9a1bb0ba7b02a36642aaae..075d705ef0df9bdc9a7590f05e60f8a4901aa961 100644 (file)
@@ -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;
+}