2 * Unix SMB/CIFS implementation.
3 * RPC Pipe client / server routines
4 * Copyright (C) Andrew Tridgell 1992-1998,
5 * Largely re-written : 2005
6 * Copyright (C) Jeremy Allison 1998 - 2005
7 * Copyright (C) Simo Sorce 2010
8 * Copyright (C) Andrew Bartlett 2011
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 3 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, see <http://www.gnu.org/licenses/>.
25 #include "rpc_client/cli_pipe.h"
26 #include "rpc_server/srv_pipe_internal.h"
28 #include "../libcli/named_pipe_auth/npa_tstream.h"
29 #include "rpc_server/rpc_ncacn_np.h"
30 #include "librpc/gen_ndr/netlogon.h"
31 #include "librpc/gen_ndr/auth.h"
32 #include "../auth/auth_sam_reply.h"
34 #include "rpc_server/rpc_pipes.h"
35 #include "../lib/tsocket/tsocket.h"
36 #include "../lib/util/tevent_ntstatus.h"
37 #include "rpc_contexts.h"
38 #include "rpc_server/rpc_config.h"
39 #include "librpc/ndr/ndr_table.h"
42 #define DBGC_CLASS DBGC_RPC_SRV
44 static struct npa_state *npa_state_init(TALLOC_CTX *mem_ctx)
46 struct npa_state *npa;
48 npa = talloc_zero(mem_ctx, struct npa_state);
53 npa->read_queue = tevent_queue_create(npa, "npa_cli_read");
54 if (npa->read_queue == NULL) {
55 DEBUG(0, ("tevent_queue_create failed\n"));
59 npa->write_queue = tevent_queue_create(npa, "npa_cli_write");
60 if (npa->write_queue == NULL) {
61 DEBUG(0, ("tevent_queue_create failed\n"));
71 /****************************************************************************
72 Make an internal namedpipes structure
73 ****************************************************************************/
75 struct pipes_struct *make_internal_rpc_pipe_p(TALLOC_CTX *mem_ctx,
76 const struct ndr_syntax_id *syntax,
77 const struct tsocket_address *remote_address,
78 const struct auth_session_info *session_info,
79 struct messaging_context *msg_ctx)
81 struct pipes_struct *p;
82 struct pipe_rpc_fns *context_fns;
83 const char *pipe_name;
85 const struct ndr_interface_table *table;
87 table = ndr_table_by_uuid(&syntax->uuid);
89 DEBUG(0,("unknown interface\n"));
93 pipe_name = dcerpc_default_transport_endpoint(mem_ctx, NCACN_NP, table);
95 DEBUG(4,("Create pipe requested %s\n", pipe_name));
97 ret = make_base_pipes_struct(mem_ctx, msg_ctx, pipe_name,
98 NCALRPC, RPC_LITTLE_ENDIAN, false,
99 remote_address, NULL, &p);
101 DEBUG(0,("ERROR! no memory for pipes_struct!\n"));
105 if (!init_pipe_handles(p, syntax)) {
106 DEBUG(0,("open_rpc_pipe_p: init_pipe_handles failed.\n"));
111 p->session_info = copy_session_info(p, session_info);
112 if (p->session_info == NULL) {
113 DEBUG(0, ("open_rpc_pipe_p: copy_serverinfo failed\n"));
114 close_policy_by_pipe(p);
119 context_fns = talloc(p, struct pipe_rpc_fns);
120 if (context_fns == NULL) {
121 DEBUG(0,("talloc() failed!\n"));
126 context_fns->next = context_fns->prev = NULL;
127 context_fns->n_cmds = rpc_srv_get_pipe_num_cmds(syntax);
128 context_fns->cmds = rpc_srv_get_pipe_cmds(syntax);
129 context_fns->context_id = 0;
130 context_fns->syntax = *syntax;
132 /* add to the list of open contexts */
133 DLIST_ADD(p->contexts, context_fns);
135 DEBUG(4,("Created internal pipe %s\n", pipe_name));
140 static NTSTATUS rpcint_dispatch(struct pipes_struct *p,
143 const DATA_BLOB *in_data,
146 struct pipe_rpc_fns *fns = find_pipe_fns_by_context(p->contexts, 0);
147 uint32_t num_cmds = fns->n_cmds;
148 const struct api_struct *cmds = fns->cmds;
155 for (i = 0; i < num_cmds; i++) {
156 if (cmds[i].opnum == opnum && cmds[i].fn != NULL) {
162 return NT_STATUS_RPC_PROCNUM_OUT_OF_RANGE;
165 p->in_data.data = *in_data;
166 p->out_data.rdata = data_blob_null;
169 p->in_data.data = data_blob_null;
171 data_blob_free(&p->out_data.rdata);
172 talloc_free_children(p->mem_ctx);
173 return NT_STATUS_RPC_CALL_FAILED;
176 if (p->fault_state) {
179 status = NT_STATUS(p->fault_state);
181 data_blob_free(&p->out_data.rdata);
182 talloc_free_children(p->mem_ctx);
186 *out_data = p->out_data.rdata;
187 talloc_steal(mem_ctx, out_data->data);
188 p->out_data.rdata = data_blob_null;
190 talloc_free_children(p->mem_ctx);
194 struct rpcint_bh_state {
195 struct pipes_struct *p;
198 static bool rpcint_bh_is_connected(struct dcerpc_binding_handle *h)
200 struct rpcint_bh_state *hs = dcerpc_binding_handle_data(h,
201 struct rpcint_bh_state);
210 static uint32_t rpcint_bh_set_timeout(struct dcerpc_binding_handle *h,
213 /* TODO: implement timeouts */
217 struct rpcint_bh_raw_call_state {
223 static struct tevent_req *rpcint_bh_raw_call_send(TALLOC_CTX *mem_ctx,
224 struct tevent_context *ev,
225 struct dcerpc_binding_handle *h,
226 const struct GUID *object,
229 const uint8_t *in_data,
232 struct rpcint_bh_state *hs =
233 dcerpc_binding_handle_data(h,
234 struct rpcint_bh_state);
235 struct tevent_req *req;
236 struct rpcint_bh_raw_call_state *state;
240 req = tevent_req_create(mem_ctx, &state,
241 struct rpcint_bh_raw_call_state);
245 state->in_data.data = discard_const_p(uint8_t, in_data);
246 state->in_data.length = in_length;
248 ok = rpcint_bh_is_connected(h);
250 tevent_req_nterror(req, NT_STATUS_CONNECTION_DISCONNECTED);
251 return tevent_req_post(req, ev);
254 /* TODO: allow async */
255 status = rpcint_dispatch(hs->p, state, opnum,
258 if (!NT_STATUS_IS_OK(status)) {
259 tevent_req_nterror(req, status);
260 return tevent_req_post(req, ev);
263 tevent_req_done(req);
264 return tevent_req_post(req, ev);
267 static NTSTATUS rpcint_bh_raw_call_recv(struct tevent_req *req,
273 struct rpcint_bh_raw_call_state *state =
275 struct rpcint_bh_raw_call_state);
278 if (tevent_req_is_nterror(req, &status)) {
279 tevent_req_received(req);
283 *out_data = talloc_move(mem_ctx, &state->out_data.data);
284 *out_length = state->out_data.length;
286 tevent_req_received(req);
290 struct rpcint_bh_disconnect_state {
294 static struct tevent_req *rpcint_bh_disconnect_send(TALLOC_CTX *mem_ctx,
295 struct tevent_context *ev,
296 struct dcerpc_binding_handle *h)
298 struct rpcint_bh_state *hs = dcerpc_binding_handle_data(h,
299 struct rpcint_bh_state);
300 struct tevent_req *req;
301 struct rpcint_bh_disconnect_state *state;
304 req = tevent_req_create(mem_ctx, &state,
305 struct rpcint_bh_disconnect_state);
310 ok = rpcint_bh_is_connected(h);
312 tevent_req_nterror(req, NT_STATUS_CONNECTION_DISCONNECTED);
313 return tevent_req_post(req, ev);
317 * TODO: do a real async disconnect ...
319 * For now the caller needs to free pipes_struct
323 tevent_req_done(req);
324 return tevent_req_post(req, ev);
327 static NTSTATUS rpcint_bh_disconnect_recv(struct tevent_req *req)
331 if (tevent_req_is_nterror(req, &status)) {
332 tevent_req_received(req);
336 tevent_req_received(req);
340 static bool rpcint_bh_ref_alloc(struct dcerpc_binding_handle *h)
345 static void rpcint_bh_do_ndr_print(struct dcerpc_binding_handle *h,
347 const void *_struct_ptr,
348 const struct ndr_interface_call *call)
350 void *struct_ptr = discard_const(_struct_ptr);
352 if (DEBUGLEVEL < 11) {
356 if (ndr_flags & NDR_IN) {
357 ndr_print_function_debug(call->ndr_print,
362 if (ndr_flags & NDR_OUT) {
363 ndr_print_function_debug(call->ndr_print,
370 static const struct dcerpc_binding_handle_ops rpcint_bh_ops = {
372 .is_connected = rpcint_bh_is_connected,
373 .set_timeout = rpcint_bh_set_timeout,
374 .raw_call_send = rpcint_bh_raw_call_send,
375 .raw_call_recv = rpcint_bh_raw_call_recv,
376 .disconnect_send = rpcint_bh_disconnect_send,
377 .disconnect_recv = rpcint_bh_disconnect_recv,
379 .ref_alloc = rpcint_bh_ref_alloc,
380 .do_ndr_print = rpcint_bh_do_ndr_print,
383 static NTSTATUS rpcint_binding_handle_ex(TALLOC_CTX *mem_ctx,
384 const struct ndr_syntax_id *abstract_syntax,
385 const struct ndr_interface_table *ndr_table,
386 const struct tsocket_address *remote_address,
387 const struct auth_session_info *session_info,
388 struct messaging_context *msg_ctx,
389 struct dcerpc_binding_handle **binding_handle)
391 struct dcerpc_binding_handle *h;
392 struct rpcint_bh_state *hs;
395 abstract_syntax = &ndr_table->syntax_id;
398 h = dcerpc_binding_handle_create(mem_ctx,
403 struct rpcint_bh_state,
406 return NT_STATUS_NO_MEMORY;
408 hs->p = make_internal_rpc_pipe_p(hs,
415 return NT_STATUS_NO_MEMORY;
422 * @brief Create a new DCERPC Binding Handle which uses a local dispatch function.
424 * @param[in] mem_ctx The memory context to use.
426 * @param[in] ndr_table Normally the ndr_table_<name>.
428 * @param[in] remote_address The info about the connected client.
430 * @param[in] serversupplied_info The server supplied authentication function.
432 * @param[in] msg_ctx The messaging context that can be used by the server
434 * @param[out] binding_handle A pointer to store the connected
435 * dcerpc_binding_handle
437 * @return NT_STATUS_OK on success, a corresponding NT status if an
441 * struct dcerpc_binding_handle *winreg_binding;
444 * status = rpcint_binding_handle(tmp_ctx,
452 NTSTATUS rpcint_binding_handle(TALLOC_CTX *mem_ctx,
453 const struct ndr_interface_table *ndr_table,
454 const struct tsocket_address *remote_address,
455 const struct auth_session_info *session_info,
456 struct messaging_context *msg_ctx,
457 struct dcerpc_binding_handle **binding_handle)
459 return rpcint_binding_handle_ex(mem_ctx, NULL, ndr_table, remote_address,
460 session_info, msg_ctx, binding_handle);
466 * @brief Create a new RPC client context which uses a local transport.
468 * This creates a local transport. It is a shortcut to directly call the server
469 * functions and avoid marshalling.
470 * NOTE: this function should be used only by rpc_pipe_open_interface()
472 * @param[in] mem_ctx The memory context to use.
474 * @param[in] abstract_syntax Normally the syntax_id of the autogenerated
477 * @param[in] serversupplied_info The server supplied authentication function.
479 * @param[in] remote_address The client address information.
481 * @param[in] msg_ctx The messaging context to use.
483 * @param[out] presult A pointer to store the connected rpc client pipe.
485 * @return NT_STATUS_OK on success, a corresponding NT status if an
488 NTSTATUS rpc_pipe_open_internal(TALLOC_CTX *mem_ctx,
489 const struct ndr_syntax_id *abstract_syntax,
490 const struct auth_session_info *session_info,
491 const struct tsocket_address *remote_address,
492 struct messaging_context *msg_ctx,
493 struct rpc_pipe_client **presult)
495 struct rpc_pipe_client *result;
498 result = talloc_zero(mem_ctx, struct rpc_pipe_client);
499 if (result == NULL) {
500 return NT_STATUS_NO_MEMORY;
503 result->abstract_syntax = *abstract_syntax;
504 result->transfer_syntax = ndr_transfer_syntax_ndr;
506 if (remote_address == NULL) {
507 struct tsocket_address *local;
510 rc = tsocket_address_inet_from_strings(mem_ctx,
517 return NT_STATUS_NO_MEMORY;
520 remote_address = local;
523 result->max_xmit_frag = -1;
524 result->max_recv_frag = -1;
526 status = rpcint_binding_handle_ex(result,
532 &result->binding_handle);
533 if (!NT_STATUS_IS_OK(status)) {
542 /****************************************************************************
543 * External pipes functions
544 ***************************************************************************/
546 NTSTATUS make_external_rpc_pipe(TALLOC_CTX *mem_ctx,
547 const char *pipe_name,
548 const struct tsocket_address *local_address,
549 const struct tsocket_address *remote_address,
550 const struct auth_session_info *session_info,
551 struct npa_state **pnpa)
553 TALLOC_CTX *tmp_ctx = talloc_stackframe();
554 struct auth_session_info_transport *session_info_t;
555 struct tevent_context *ev_ctx;
556 struct tevent_req *subreq;
557 const char *socket_np_dir;
558 const char *socket_dir;
559 struct npa_state *npa;
565 npa = npa_state_init(tmp_ctx);
567 status = NT_STATUS_NO_MEMORY;
571 socket_dir = lp_parm_const_string(GLOBAL_SECTION_SNUM,
575 if (socket_dir == NULL) {
576 DEBUG(0, ("external_rpc_pipe: socket_dir not set\n"));
577 status = NT_STATUS_PIPE_NOT_AVAILABLE;
581 socket_np_dir = talloc_asprintf(tmp_ctx, "%s/np", socket_dir);
582 if (socket_np_dir == NULL) {
583 DEBUG(0, ("talloc_asprintf failed\n"));
584 status = NT_STATUS_NO_MEMORY;
588 session_info_t = talloc_zero(tmp_ctx,
589 struct auth_session_info_transport);
590 if (session_info_t == NULL) {
591 DEBUG(0, ("talloc failed\n"));
592 status = NT_STATUS_NO_MEMORY;
596 session_info_t->session_info = copy_session_info(session_info_t,
598 if (session_info_t->session_info == NULL) {
599 DEBUG(0, ("copy_session_info failed\n"));
600 status = NT_STATUS_NO_MEMORY;
604 ev_ctx = s3_tevent_context_init(tmp_ctx);
605 if (ev_ctx == NULL) {
606 DEBUG(0, ("s3_tevent_context_init failed\n"));
607 status = NT_STATUS_NO_MEMORY;
612 subreq = tstream_npa_connect_send(tmp_ctx,
616 remote_address, /* client_addr */
617 NULL, /* client_name */
618 local_address, /* server_addr */
619 NULL, /* server_name */
621 if (subreq == NULL) {
623 DEBUG(0, ("tstream_npa_connect_send to %s for pipe %s and "
624 "user %s\\%s failed\n",
625 socket_np_dir, pipe_name, session_info_t->session_info->info->domain_name,
626 session_info_t->session_info->info->account_name));
627 status = NT_STATUS_OBJECT_NAME_NOT_FOUND;
630 ok = tevent_req_poll(subreq, ev_ctx);
633 DEBUG(0, ("tevent_req_poll to %s for pipe %s and user %s\\%s "
634 "failed for tstream_npa_connect: %s\n",
637 session_info_t->session_info->info->domain_name,
638 session_info_t->session_info->info->account_name,
640 status = NT_STATUS_OBJECT_NAME_NOT_FOUND;
644 rc = tstream_npa_connect_recv(subreq,
650 &npa->allocation_size);
655 if (errno == ENOENT) {
659 DEBUG(l, ("tstream_npa_connect_recv to %s for pipe %s and "
660 "user %s\\%s failed: %s\n",
663 session_info_t->session_info->info->domain_name,
664 session_info_t->session_info->info->account_name,
665 strerror(sys_errno)));
666 status = NT_STATUS_OBJECT_NAME_NOT_FOUND;
670 *pnpa = talloc_steal(mem_ctx, npa);
671 status = NT_STATUS_OK;
673 talloc_free(tmp_ctx);
678 struct np_proxy_state *make_external_rpc_pipe_p(TALLOC_CTX *mem_ctx,
679 const char *pipe_name,
680 const struct tsocket_address *local_address,
681 const struct tsocket_address *remote_address,
682 const struct auth_session_info *session_info)
684 struct np_proxy_state *result;
686 const char *socket_dir;
687 struct tevent_context *ev;
688 struct tevent_req *subreq;
689 struct auth_session_info_transport *session_info_t;
694 result = talloc(mem_ctx, struct np_proxy_state);
695 if (result == NULL) {
696 DEBUG(0, ("talloc failed\n"));
700 result->read_queue = tevent_queue_create(result, "np_read");
701 if (result->read_queue == NULL) {
702 DEBUG(0, ("tevent_queue_create failed\n"));
706 result->write_queue = tevent_queue_create(result, "np_write");
707 if (result->write_queue == NULL) {
708 DEBUG(0, ("tevent_queue_create failed\n"));
712 ev = s3_tevent_context_init(talloc_tos());
714 DEBUG(0, ("s3_tevent_context_init failed\n"));
718 socket_dir = lp_parm_const_string(
719 GLOBAL_SECTION_SNUM, "external_rpc_pipe", "socket_dir",
721 if (socket_dir == NULL) {
722 DEBUG(0, ("external_rpc_pipe:socket_dir not set\n"));
725 socket_np_dir = talloc_asprintf(talloc_tos(), "%s/np", socket_dir);
726 if (socket_np_dir == NULL) {
727 DEBUG(0, ("talloc_asprintf failed\n"));
731 session_info_t = talloc_zero(talloc_tos(), struct auth_session_info_transport);
732 if (session_info_t == NULL) {
733 DEBUG(0, ("talloc failed\n"));
737 session_info_t->session_info = copy_session_info(session_info_t,
739 if (session_info_t->session_info == NULL) {
740 DEBUG(0, ("copy_session_info failed\n"));
745 subreq = tstream_npa_connect_send(talloc_tos(), ev,
748 remote_address, /* client_addr */
749 NULL, /* client_name */
750 local_address, /* server_addr */
751 NULL, /* server_name */
753 if (subreq == NULL) {
755 DEBUG(0, ("tstream_npa_connect_send to %s for pipe %s and "
756 "user %s\\%s failed\n",
757 socket_np_dir, pipe_name, session_info_t->session_info->info->domain_name,
758 session_info_t->session_info->info->account_name));
761 ok = tevent_req_poll(subreq, ev);
764 DEBUG(0, ("tevent_req_poll to %s for pipe %s and user %s\\%s "
765 "failed for tstream_npa_connect: %s\n",
766 socket_np_dir, pipe_name, session_info_t->session_info->info->domain_name,
767 session_info_t->session_info->info->account_name,
772 ret = tstream_npa_connect_recv(subreq, &sys_errno,
776 &result->device_state,
777 &result->allocation_size);
781 if (errno == ENOENT) {
784 DEBUG(l, ("tstream_npa_connect_recv to %s for pipe %s and "
785 "user %s\\%s failed: %s\n",
786 socket_np_dir, pipe_name, session_info_t->session_info->info->domain_name,
787 session_info_t->session_info->info->account_name,
788 strerror(sys_errno)));
799 static NTSTATUS rpc_pipe_open_external(TALLOC_CTX *mem_ctx,
800 const char *pipe_name,
801 const struct ndr_interface_table *table,
802 const struct auth_session_info *session_info,
803 struct rpc_pipe_client **_result)
805 struct tsocket_address *local, *remote;
806 struct rpc_pipe_client *result = NULL;
807 struct np_proxy_state *proxy_state = NULL;
808 struct pipe_auth_data *auth;
812 /* this is an internal connection, fake up ip addresses */
813 ret = tsocket_address_inet_from_strings(talloc_tos(), "ip",
816 return NT_STATUS_NO_MEMORY;
818 ret = tsocket_address_inet_from_strings(talloc_tos(), "ip",
821 return NT_STATUS_NO_MEMORY;
824 proxy_state = make_external_rpc_pipe_p(mem_ctx, pipe_name,
825 local, remote, session_info);
827 return NT_STATUS_UNSUCCESSFUL;
830 result = talloc_zero(mem_ctx, struct rpc_pipe_client);
831 if (result == NULL) {
832 status = NT_STATUS_NO_MEMORY;
836 result->abstract_syntax = table->syntax_id;
837 result->transfer_syntax = ndr_transfer_syntax_ndr;
839 result->desthost = get_myname(result);
840 result->srv_name_slash = talloc_asprintf_strupper_m(
841 result, "\\\\%s", result->desthost);
842 if ((result->desthost == NULL) || (result->srv_name_slash == NULL)) {
843 status = NT_STATUS_NO_MEMORY;
847 result->max_xmit_frag = RPC_MAX_PDU_FRAG_LEN;
848 result->max_recv_frag = RPC_MAX_PDU_FRAG_LEN;
850 status = rpc_transport_tstream_init(result,
853 if (!NT_STATUS_IS_OK(status)) {
857 result->binding_handle = rpccli_bh_create(result, NULL, table);
858 if (result->binding_handle == NULL) {
859 status = NT_STATUS_NO_MEMORY;
860 DEBUG(0, ("Failed to create binding handle.\n"));
864 result->auth = talloc_zero(result, struct pipe_auth_data);
866 status = NT_STATUS_NO_MEMORY;
869 result->auth->auth_type = DCERPC_AUTH_TYPE_NONE;
870 result->auth->auth_level = DCERPC_AUTH_LEVEL_NONE;
872 status = rpccli_anon_bind_data(result, &auth);
873 if (!NT_STATUS_IS_OK(status)) {
874 DEBUG(0, ("Failed to initialize anonymous bind.\n"));
878 status = rpc_pipe_bind(result, auth);
879 if (!NT_STATUS_IS_OK(status)) {
880 DEBUG(0, ("Failed to bind external pipe.\n"));
885 if (!NT_STATUS_IS_OK(status)) {
888 TALLOC_FREE(proxy_state);
894 * @brief Create a new RPC client context which uses a local dispatch function
895 * or a remote transport, depending on rpc_server configuration for the
898 * @param[in] mem_ctx The memory context to use.
900 * @param[in] abstract_syntax Normally the syntax_id of the autogenerated
903 * @param[in] serversupplied_info The server supplied authentication function.
905 * @param[in] remote_address The client address information.
907 * @param[in] msg_ctx The messaging context to use.
909 * @param[out] presult A pointer to store the connected rpc client pipe.
911 * @return NT_STATUS_OK on success, a corresponding NT status if an
915 * struct rpc_pipe_client *winreg_pipe;
918 * status = rpc_pipe_open_interface(tmp_ctx,
919 * &ndr_table_winreg.syntax_id,
926 NTSTATUS rpc_pipe_open_interface(TALLOC_CTX *mem_ctx,
927 const struct ndr_interface_table *table,
928 const struct auth_session_info *session_info,
929 const struct tsocket_address *remote_address,
930 struct messaging_context *msg_ctx,
931 struct rpc_pipe_client **cli_pipe)
933 struct rpc_pipe_client *cli = NULL;
934 enum rpc_service_mode_e pipe_mode;
935 const char *pipe_name;
939 if (cli_pipe != NULL) {
940 if (rpccli_is_connected(*cli_pipe)) {
943 TALLOC_FREE(*cli_pipe);
947 tmp_ctx = talloc_stackframe();
948 if (tmp_ctx == NULL) {
949 return NT_STATUS_NO_MEMORY;
952 pipe_name = dcerpc_default_transport_endpoint(mem_ctx, NCACN_NP, table);
953 if (pipe_name == NULL) {
954 status = NT_STATUS_INVALID_PARAMETER;
958 while (pipe_name[0] == '\\') {
962 DEBUG(5, ("Connecting to %s pipe.\n", pipe_name));
964 pipe_mode = rpc_service_mode(pipe_name);
967 case RPC_SERVICE_MODE_EMBEDDED:
968 status = rpc_pipe_open_internal(tmp_ctx,
969 &table->syntax_id, session_info,
970 remote_address, msg_ctx,
972 if (!NT_STATUS_IS_OK(status)) {
976 case RPC_SERVICE_MODE_EXTERNAL:
977 /* It would be nice to just use rpc_pipe_open_ncalrpc() but
978 * for now we need to use the special proxy setup to connect
981 status = rpc_pipe_open_external(tmp_ctx,
985 if (!NT_STATUS_IS_OK(status)) {
989 case RPC_SERVICE_MODE_DISABLED:
990 status = NT_STATUS_NOT_IMPLEMENTED;
991 DEBUG(0, ("Service pipe %s is disabled in config file: %s",
992 pipe_name, nt_errstr(status)));
996 status = NT_STATUS_OK;
998 if (NT_STATUS_IS_OK(status) && cli_pipe != NULL) {
999 *cli_pipe = talloc_move(mem_ctx, &cli);
1001 TALLOC_FREE(tmp_ctx);