diff options
author | Andreas Schneider <asn@samba.org> | 2013-09-25 11:35:41 +0200 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2013-10-29 16:17:03 +0100 |
commit | 7daa4b94fa6299d6e1788c93ed8ff0b4c4023b40 (patch) | |
tree | 337e488e3ae2be6df11874da5ad85ea838a8e4ea | |
parent | 327b0ddcd9ea7db373a92e47db7e796da3186b05 (diff) | |
download | samba-7daa4b94fa6299d6e1788c93ed8ff0b4c4023b40.tar.gz |
s3-rpc_server: Add make_internal_rpc_pipe_socketpair().
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
-rw-r--r-- | source3/rpc_server/rpc_ncacn_np.c | 109 | ||||
-rw-r--r-- | source3/rpc_server/rpc_ncacn_np.h | 9 | ||||
-rwxr-xr-x | source3/rpc_server/wscript_build | 5 | ||||
-rwxr-xr-x | source3/wscript_build | 5 |
4 files changed, 122 insertions, 6 deletions
diff --git a/source3/rpc_server/rpc_ncacn_np.c b/source3/rpc_server/rpc_ncacn_np.c index 0a5ab6abb2d..92a724b982f 100644 --- a/source3/rpc_server/rpc_ncacn_np.c +++ b/source3/rpc_server/rpc_ncacn_np.c @@ -37,6 +37,7 @@ #include "rpc_contexts.h" #include "rpc_server/rpc_config.h" #include "librpc/ndr/ndr_table.h" +#include "rpc_server/rpc_server.h" #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV @@ -68,6 +69,114 @@ fail: return NULL; } +NTSTATUS make_internal_rpc_pipe_socketpair(TALLOC_CTX *mem_ctx, + struct tevent_context *ev_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 named_pipe_client *npc; + struct tevent_req *subreq; + struct npa_state *npa; + NTSTATUS status; + int error; + int rc; + + 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; + } + + npa->file_type = FILE_TYPE_MESSAGE_MODE_PIPE; + npa->device_state = 0xff | 0x0400 | 0x0100; + npa->allocation_size = 4096; + + npc = named_pipe_client_init(npa, + ev_ctx, + msg_ctx, + pipe_name, + NULL, /* term_fn */ + npa->file_type, + npa->device_state, + npa->allocation_size, + NULL); /* private_data */ + if (npc == NULL) { + status = NT_STATUS_NO_MEMORY; + goto out; + } + npa->private_data = (void*) npc; + + rc = tstream_npa_socketpair(npa->file_type, + npa, + &npa->stream, + npc, + &npc->tstream); + if (rc == -1) { + status = map_nt_error_from_unix(errno); + goto out; + } + + npc->client = tsocket_address_copy(remote_address, npc); + if (npc->client == NULL) { + status = NT_STATUS_NO_MEMORY; + goto out; + } + + npc->client_name = tsocket_address_inet_addr_string(npc->client, npc); + if (npc->client_name == NULL) { + status = NT_STATUS_NO_MEMORY; + goto out; + } + + npc->session_info = copy_session_info(npc, session_info); + if (npc->session_info == NULL) { + status = NT_STATUS_NO_MEMORY; + goto out; + } + + rc = make_server_pipes_struct(npc, + npc->msg_ctx, + npc->pipe_name, + NCACN_NP, + false, + npc->server, + npc->client, + npc->session_info, + &npc->p, + &error); + if (rc == -1) { + status = map_nt_error_from_unix(error); + goto out; + } + + npc->write_queue = tevent_queue_create(npc, "npa_server_write_queue"); + if (npc->write_queue == NULL) { + status = NT_STATUS_NO_MEMORY; + goto out; + } + + subreq = dcerpc_read_ncacn_packet_send(npc, npc->ev, npc->tstream); + if (subreq == NULL) { + DEBUG(2, ("Failed to start receving packets\n")); + status = NT_STATUS_PIPE_BROKEN; + goto out; + } + tevent_req_set_callback(subreq, named_pipe_packet_process, npc); + + *pnpa = talloc_steal(mem_ctx, npa); + status = NT_STATUS_OK; +out: + talloc_free(tmp_ctx); + return status; +} + NTSTATUS make_internal_rpc_pipe(TALLOC_CTX *mem_ctx, struct messaging_context *msg_ctx, const char *pipe_name, diff --git a/source3/rpc_server/rpc_ncacn_np.h b/source3/rpc_server/rpc_ncacn_np.h index 92e3d6c17b0..07a2c15a63e 100644 --- a/source3/rpc_server/rpc_ncacn_np.h +++ b/source3/rpc_server/rpc_ncacn_np.h @@ -52,6 +52,15 @@ NTSTATUS make_internal_rpc_pipe(TALLOC_CTX *mem_ctx, const struct auth_session_info *session_info, struct npa_state **pnpa); +NTSTATUS make_internal_rpc_pipe_socketpair(TALLOC_CTX *mem_ctx, + struct tevent_context *ev_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; diff --git a/source3/rpc_server/wscript_build b/source3/rpc_server/wscript_build index c30852a75a0..061bdd6b327 100755 --- a/source3/rpc_server/wscript_build +++ b/source3/rpc_server/wscript_build @@ -73,8 +73,7 @@ bld.SAMBA3_SUBSYSTEM('RPC_NETDFS', bld.SAMBA3_SUBSYSTEM('RPC_NETLOGON', source='''netlogon/srv_netlog_nt.c - ../../librpc/gen_ndr/srv_netlogon.c''', - deps='RPC_NCACN_NP') + ../../librpc/gen_ndr/srv_netlogon.c''') bld.SAMBA3_SUBSYSTEM('RPC_NTSVCS', source='''ntsvcs/srv_ntsvcs_nt.c @@ -97,7 +96,7 @@ bld.SAMBA3_SUBSYSTEM('RPC_SPOOLSS', source='''spoolss/srv_spoolss_nt.c ../../librpc/gen_ndr/srv_spoolss.c spoolss/srv_spoolss_util.c''', - deps='PRINTING PRINTBACKEND LIBCLI_WINREG_INTERNAL RPC_NCACN_NP') + deps='PRINTING PRINTBACKEND LIBCLI_WINREG_INTERNAL') bld.SAMBA3_SUBSYSTEM('RPC_SRVSVC', source='''srvsvc/srv_srvsvc_nt.c diff --git a/source3/wscript_build b/source3/wscript_build index 9f5be8ee36a..d3eed3c1647 100755 --- a/source3/wscript_build +++ b/source3/wscript_build @@ -778,7 +778,7 @@ bld.SAMBA3_SUBSYSTEM('LIBCLI_WINREG', bld.SAMBA3_SUBSYSTEM('LIBCLI_WINREG_INTERNAL', source='rpc_client/cli_winreg_int.c', - deps='LIBCLI_WINREG RPC_NCACN_NP') + deps='LIBCLI_WINREG RPC_SERVER') bld.SAMBA3_SUBSYSTEM('RPC_CLIENT_SCHANNEL', source='rpc_client/cli_pipe_schannel.c', @@ -935,8 +935,7 @@ bld.SAMBA3_BINARY('winbindd/winbindd', SRV_NDR_WBINT RPC_SAMR RPC_LSARPC - RPC_NCACN_NP - RPC_PIPE_REGISTER + RPC_SERVER WB_REQTRANS TDB_VALIDATE ''', |