diff options
-rw-r--r-- | source3/rpc_server/rpc_ncacn_np.c | 82 | ||||
-rw-r--r-- | source3/rpc_server/rpc_ncacn_np.h | 8 |
2 files changed, 90 insertions, 0 deletions
diff --git a/source3/rpc_server/rpc_ncacn_np.c b/source3/rpc_server/rpc_ncacn_np.c index 5c3c875a08..0a5ab6abb2 100644 --- a/source3/rpc_server/rpc_ncacn_np.c +++ b/source3/rpc_server/rpc_ncacn_np.c @@ -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 ****************************************************************************/ diff --git a/source3/rpc_server/rpc_ncacn_np.h b/source3/rpc_server/rpc_ncacn_np.h index cd541da723..92e3d6c17b 100644 --- a/source3/rpc_server/rpc_ncacn_np.h +++ b/source3/rpc_server/rpc_ncacn_np.h @@ -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; |