s3-rpc_server: Add make_internal_rpc_pipe().
authorAndreas Schneider <asn@samba.org>
Tue, 24 Sep 2013 09:28:39 +0000 (11:28 +0200)
committerStefan Metzmacher <metze@samba.org>
Tue, 29 Oct 2013 14:35:49 +0000 (15:35 +0100)
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
source3/rpc_server/rpc_ncacn_np.c
source3/rpc_server/rpc_ncacn_np.h

index 5c3c875a08c15c71b76fff9de6662c1ff689f314..0a5ab6abb2da6a4824d31cb57a274580c4e3dccc 100644 (file)
@@ -68,6 +68,88 @@ fail:
        return NULL;
 }
 
+NTSTATUS make_internal_rpc_pipe(TALLOC_CTX *mem_ctx,
+                               struct messaging_context *msg_ctx,
+                               const char *pipe_name,
+                               const struct ndr_syntax_id *syntax,
+                               const struct tsocket_address *remote_address,
+                               const struct auth_session_info *session_info,
+                               struct npa_state **pnpa)
+{
+       TALLOC_CTX *tmp_ctx = talloc_stackframe();
+       struct pipe_rpc_fns *context_fns;
+       struct pipes_struct *p = NULL;
+       struct npa_state *npa;
+       NTSTATUS status;
+       int rc;
+       bool ok;
+
+       DEBUG(4, ("Create of internal pipe %s requested\n", pipe_name));
+
+       npa = npa_state_init(tmp_ctx);
+       if (npa == NULL) {
+               status = NT_STATUS_NO_MEMORY;
+               goto out;
+       }
+
+       /* Create a basic pipes struct */
+       rc = make_base_pipes_struct(npa,
+                                   msg_ctx,
+                                   pipe_name,
+                                   NCACN_NP,
+                                   RPC_LITTLE_ENDIAN,
+                                   false,
+                                   remote_address,
+                                   NULL,
+                                   &p);
+       if (rc != 0) {
+               status = NT_STATUS_NO_MEMORY;
+               DEBUG(0,("ERROR! No memory to create pipes_struct!\n"));
+               goto out;
+       }
+       npa->private_data = (void *)p;
+
+       ok = init_pipe_handles(p, syntax);
+       if (!ok) {
+               DEBUG(0, ("init_pipe_handles failed.\n"));
+               status = NT_STATUS_NO_MEMORY;
+               goto out;
+       }
+
+       p->session_info = copy_session_info(p, session_info);
+       if (p->session_info == NULL) {
+               DEBUG(0, ("Duplicating the session_info failed\n"));
+               status = NT_STATUS_NO_MEMORY;
+               goto out;
+       }
+
+       context_fns = talloc(p, struct pipe_rpc_fns);
+       if (context_fns == NULL) {
+               DEBUG(0,("Failed to allocate the context functions structure!\n"));
+               status = NT_STATUS_NO_MEMORY;
+               goto out;
+       }
+
+       context_fns->next = context_fns->prev = NULL;
+       context_fns->n_cmds = rpc_srv_get_pipe_num_cmds(syntax);
+       context_fns->cmds = rpc_srv_get_pipe_cmds(syntax);
+       context_fns->context_id = 0;
+       context_fns->syntax = *syntax;
+
+       /* add to the list of open contexts */
+       DLIST_ADD(p->contexts, context_fns);
+
+       *pnpa = talloc_steal(mem_ctx, npa);
+       status = NT_STATUS_OK;
+out:
+       if (!NT_STATUS_IS_OK(status) && p != NULL) {
+               close_policy_by_pipe(p);
+       }
+
+       talloc_free(tmp_ctx);
+       return status;
+}
+
 /****************************************************************************
  Make an internal namedpipes structure
 ****************************************************************************/
index cd541da723b1f7c7e321fd46109e49e7958dd321..92e3d6c17b07d84cf27e73e5848028ffb5b1c54c 100644 (file)
@@ -44,6 +44,14 @@ NTSTATUS make_external_rpc_pipe(TALLOC_CTX *mem_ctx,
                                const struct auth_session_info *session_info,
                                struct npa_state **pnpa);
 
+NTSTATUS make_internal_rpc_pipe(TALLOC_CTX *mem_ctx,
+                               struct messaging_context *msg_ctx,
+                               const char *pipe_name,
+                               const struct ndr_syntax_id *syntax,
+                               const struct tsocket_address *remote_address,
+                               const struct auth_session_info *session_info,
+                               struct npa_state **pnpa);
+
 struct np_proxy_state {
        uint16_t file_type;
        uint16_t device_state;