2 * Unix SMB/CIFS implementation.
4 * SMBD RPC service callbacks
6 * Copyright (c) 2011 Andreas Schneider <asn@samba.org>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, see <http://www.gnu.org/licenses/>.
24 #include "../librpc/gen_ndr/srv_epmapper.h"
25 #include "../librpc/gen_ndr/srv_srvsvc.h"
26 #include "../librpc/gen_ndr/srv_winreg.h"
27 #include "../librpc/gen_ndr/srv_dfs.h"
28 #include "../librpc/gen_ndr/srv_dssetup.h"
29 #include "../librpc/gen_ndr/srv_echo.h"
30 #include "../librpc/gen_ndr/srv_eventlog.h"
31 #include "../librpc/gen_ndr/srv_initshutdown.h"
32 #include "../librpc/gen_ndr/srv_lsa.h"
33 #include "../librpc/gen_ndr/srv_netlogon.h"
34 #include "../librpc/gen_ndr/srv_ntsvcs.h"
35 #include "../librpc/gen_ndr/srv_samr.h"
36 #include "../librpc/gen_ndr/srv_spoolss.h"
37 #include "../librpc/gen_ndr/srv_svcctl.h"
38 #include "../librpc/gen_ndr/srv_wkssvc.h"
40 #include "printing/nt_printing_migrate.h"
41 #include "rpc_server/eventlog/srv_eventlog_reg.h"
42 #include "rpc_server/svcctl/srv_svcctl_reg.h"
44 #include "librpc/rpc/dcerpc_ep.h"
46 #include "rpc_server/rpc_ep_setup.h"
47 #include "rpc_server/rpc_server.h"
48 #include "rpc_server/epmapper/srv_epmapper.h"
50 struct dcesrv_ep_context {
51 struct tevent_context *ev_ctx;
52 struct messaging_context *msg_ctx;
55 static uint16_t _open_sockets(struct tevent_context *ev_ctx,
56 struct messaging_context *msg_ctx,
57 struct ndr_syntax_id syntax_id,
60 uint32_t num_ifs = iface_count();
64 if (lp_interfaces() && lp_bind_interfaces_only()) {
66 * We have been given an interfaces line, and been told to only
67 * bind to those interfaces. Create a socket per interface and
71 /* Now open a listen socket for each of the interfaces. */
72 for(i = 0; i < num_ifs; i++) {
73 const struct sockaddr_storage *ifss =
74 iface_n_sockaddr_storage(i);
76 p = setup_dcerpc_ncacn_tcpip_socket(ev_ctx,
87 const char *sock_addr = lp_socket_address();
91 if (strequal(sock_addr, "0.0.0.0") ||
92 strequal(sock_addr, "::")) {
96 sock_addr = "0.0.0.0";
100 for (sock_ptr = sock_addr;
101 next_token_talloc(talloc_tos(), &sock_ptr, &sock_tok, " \t,");
103 struct sockaddr_storage ss;
105 /* open an incoming socket */
106 if (!interpret_string_addr(&ss,
108 AI_NUMERICHOST|AI_PASSIVE)) {
112 p = setup_dcerpc_ncacn_tcpip_socket(ev_ctx,
127 static NTSTATUS _rpc_ep_unregister(const struct ndr_interface_table *iface)
129 struct dcerpc_binding_vector *v = NULL;
132 status = dcerpc_binding_vector_create(talloc_tos(),
137 if (!NT_STATUS_IS_OK(status)) {
141 status = dcerpc_ep_unregister(iface,
143 &iface->syntax_id.uuid);
144 if (!NT_STATUS_IS_OK(status)) {
151 static void rpc_ep_setup_register_loop(struct tevent_req *subreq);
152 static NTSTATUS rpc_ep_setup_try_register(TALLOC_CTX *mem_ctx,
153 struct tevent_context *ev_ctx,
154 struct messaging_context *msg_ctx,
155 const struct ndr_interface_table *iface,
158 struct dcerpc_binding_handle **pbh);
160 struct rpc_ep_regsiter_state {
161 struct dcerpc_binding_handle *h;
164 struct tevent_context *ev_ctx;
165 struct messaging_context *msg_ctx;
167 const struct ndr_interface_table *iface;
175 static NTSTATUS rpc_ep_setup_register(struct tevent_context *ev_ctx,
176 struct messaging_context *msg_ctx,
177 const struct ndr_interface_table *iface,
181 struct rpc_ep_regsiter_state *state;
182 struct tevent_req *req;
184 state = talloc(ev_ctx, struct rpc_ep_regsiter_state);
186 return NT_STATUS_NO_MEMORY;
189 state->mem_ctx = talloc_named(state,
193 if (state->mem_ctx == NULL) {
195 return NT_STATUS_NO_MEMORY;
198 state->wait_time = 1;
199 state->ev_ctx = ev_ctx;
200 state->msg_ctx = msg_ctx;
201 state->iface = iface;
202 state->ncalrpc = talloc_strdup(state, ncalrpc);
205 req = tevent_wakeup_send(state->mem_ctx,
207 timeval_current_ofs(1, 0));
208 if (tevent_req_nomem(state->mem_ctx, req)) {
210 return NT_STATUS_NO_MEMORY;
213 tevent_req_set_callback(req, rpc_ep_setup_register_loop, state);
218 static void rpc_ep_setup_register_loop(struct tevent_req *req)
220 struct rpc_ep_regsiter_state *state =
221 tevent_req_callback_data(req, struct rpc_ep_regsiter_state);
225 ok = tevent_wakeup_recv(req);
232 status = rpc_ep_setup_try_register(state->mem_ctx,
239 if (NT_STATUS_IS_OK(status)) {
244 state->wait_time = state->wait_time * 2;
245 if (state->wait_time > 16) {
250 req = tevent_wakeup_send(state->mem_ctx,
252 timeval_current_ofs(state->wait_time, 0));
253 if (tevent_req_nomem(state->mem_ctx, req)) {
258 tevent_req_set_callback(req, rpc_ep_setup_register_loop, state);
262 static NTSTATUS rpc_ep_setup_try_register(TALLOC_CTX *mem_ctx,
263 struct tevent_context *ev_ctx,
264 struct messaging_context *msg_ctx,
265 const struct ndr_interface_table *iface,
268 struct dcerpc_binding_handle **pbh)
270 struct dcerpc_binding_vector *v = NULL;
273 status = dcerpc_binding_vector_create(mem_ctx,
278 if (!NT_STATUS_IS_OK(status)) {
282 status = dcerpc_ep_register(mem_ctx,
285 &iface->syntax_id.uuid,
289 if (!NT_STATUS_IS_OK(status)) {
296 static bool epmapper_init_cb(void *ptr)
298 struct dcesrv_ep_context *ep_ctx =
299 talloc_get_type_abort(ptr, struct dcesrv_ep_context);
302 port = _open_sockets(ep_ctx->ev_ctx,
304 ndr_table_epmapper.syntax_id,
313 static bool epmapper_shutdown_cb(void *ptr)
315 srv_epmapper_cleanup();
320 static bool winreg_init_cb(void *ptr)
322 struct dcesrv_ep_context *ep_ctx =
323 talloc_get_type_abort(ptr, struct dcesrv_ep_context);
324 struct ndr_syntax_id abstract_syntax = ndr_table_winreg.syntax_id;
325 const char *pipe_name = "winreg";
326 const char *rpcsrv_type;
329 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
334 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
335 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
339 ok = setup_dcerpc_ncalrpc_socket(ep_ctx->ev_ctx,
346 port = _open_sockets(ep_ctx->ev_ctx,
354 status = rpc_ep_setup_register(ep_ctx->ev_ctx,
359 if (!NT_STATUS_IS_OK(status)) {
367 static bool winreg_shutdown_cb(void *ptr)
369 const char *rpcsrv_type;
371 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
376 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
377 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
380 status = _rpc_ep_unregister(&ndr_table_winreg);
381 if (!NT_STATUS_IS_OK(status)) {
389 static bool srvsvc_init_cb(void *ptr)
391 struct dcesrv_ep_context *ep_ctx =
392 talloc_get_type_abort(ptr, struct dcesrv_ep_context);
393 struct ndr_syntax_id abstract_syntax = ndr_table_srvsvc.syntax_id;
394 const char *pipe_name = "srvsvc";
395 const char *rpcsrv_type;
398 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
403 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
404 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
408 ok = setup_dcerpc_ncalrpc_socket(ep_ctx->ev_ctx,
416 port = _open_sockets(ep_ctx->ev_ctx,
424 status = rpc_ep_setup_register(ep_ctx->ev_ctx,
429 if (!NT_STATUS_IS_OK(status)) {
437 static bool srvsvc_shutdown_cb(void *ptr)
439 const char *rpcsrv_type;
441 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
446 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
447 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
450 status =_rpc_ep_unregister(&ndr_table_srvsvc);
451 if (!NT_STATUS_IS_OK(status)) {
459 static bool lsarpc_init_cb(void *ptr)
461 struct dcesrv_ep_context *ep_ctx =
462 talloc_get_type_abort(ptr, struct dcesrv_ep_context);
463 struct ndr_syntax_id abstract_syntax = ndr_table_lsarpc.syntax_id;
464 const char *pipe_name = "lsarpc";
465 const char *rpcsrv_type;
468 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
473 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
474 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
478 ok = setup_dcerpc_ncalrpc_socket(ep_ctx->ev_ctx,
486 port = _open_sockets(ep_ctx->ev_ctx,
494 status = rpc_ep_setup_register(ep_ctx->ev_ctx,
499 if (!NT_STATUS_IS_OK(status)) {
507 static bool lsarpc_shutdown_cb(void *ptr)
509 const char *rpcsrv_type;
511 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
516 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
517 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
520 status = _rpc_ep_unregister(&ndr_table_lsarpc);
521 if (!NT_STATUS_IS_OK(status)) {
529 static bool samr_init_cb(void *ptr)
531 struct dcesrv_ep_context *ep_ctx =
532 talloc_get_type_abort(ptr, struct dcesrv_ep_context);
533 struct ndr_syntax_id abstract_syntax = ndr_table_samr.syntax_id;
534 const char *pipe_name = "samr";
535 const char *rpcsrv_type;
538 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
543 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
544 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
548 ok = setup_dcerpc_ncalrpc_socket(ep_ctx->ev_ctx,
556 port = _open_sockets(ep_ctx->ev_ctx,
564 status = rpc_ep_setup_register(ep_ctx->ev_ctx,
569 if (!NT_STATUS_IS_OK(status)) {
577 static bool samr_shutdown_cb(void *ptr)
579 const char *rpcsrv_type;
581 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
586 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
587 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
590 status = _rpc_ep_unregister(&ndr_table_samr);
591 if (!NT_STATUS_IS_OK(status)) {
599 static bool netlogon_init_cb(void *ptr)
601 struct dcesrv_ep_context *ep_ctx =
602 talloc_get_type_abort(ptr, struct dcesrv_ep_context);
603 struct ndr_syntax_id abstract_syntax = ndr_table_netlogon.syntax_id;
604 const char *pipe_name = "netlogon";
605 const char *rpcsrv_type;
608 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
613 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
614 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
618 ok = setup_dcerpc_ncalrpc_socket(ep_ctx->ev_ctx,
626 port = _open_sockets(ep_ctx->ev_ctx,
634 status = rpc_ep_setup_register(ep_ctx->ev_ctx,
639 if (!NT_STATUS_IS_OK(status)) {
647 static bool netlogon_shutdown_cb(void *ptr)
649 const char *rpcsrv_type;
651 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
656 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
657 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
660 status = _rpc_ep_unregister(&ndr_table_netlogon);
661 if (!NT_STATUS_IS_OK(status)) {
669 static bool spoolss_init_cb(void *ptr)
671 struct dcesrv_ep_context *ep_ctx =
672 talloc_get_type_abort(ptr, struct dcesrv_ep_context);
673 const char *rpcsrv_type;
676 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
682 * Migrate the printers first.
684 ok = nt_printing_tdb_migrate(ep_ctx->msg_ctx);
689 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
690 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
693 status =rpc_ep_setup_register(ep_ctx->ev_ctx,
698 if (!NT_STATUS_IS_OK(status)) {
706 static bool spoolss_shutdown_cb(void *ptr)
708 const char *rpcsrv_type;
710 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
715 srv_spoolss_cleanup();
717 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
718 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
721 status = _rpc_ep_unregister(&ndr_table_spoolss);
722 if (!NT_STATUS_IS_OK(status)) {
730 static bool svcctl_init_cb(void *ptr)
732 struct dcesrv_ep_context *ep_ctx =
733 talloc_get_type_abort(ptr, struct dcesrv_ep_context);
734 const char *rpcsrv_type;
737 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
742 ok = svcctl_init_winreg(ep_ctx->msg_ctx);
747 /* initialize the control hooks */
748 init_service_op_table();
750 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
751 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
754 status = rpc_ep_setup_register(ep_ctx->ev_ctx,
759 if (!NT_STATUS_IS_OK(status)) {
767 static bool svcctl_shutdown_cb(void *ptr)
769 const char *rpcsrv_type;
771 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
775 shutdown_service_op_table();
777 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
778 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
781 status = _rpc_ep_unregister(&ndr_table_svcctl);
782 if (!NT_STATUS_IS_OK(status)) {
790 static bool ntsvcs_init_cb(void *ptr)
792 struct dcesrv_ep_context *ep_ctx =
793 talloc_get_type_abort(ptr, struct dcesrv_ep_context);
794 const char *rpcsrv_type;
796 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
801 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
802 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
805 status = rpc_ep_setup_register(ep_ctx->ev_ctx,
810 if (!NT_STATUS_IS_OK(status)) {
818 static bool ntsvcs_shutdown_cb(void *ptr)
820 const char *rpcsrv_type;
822 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
827 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
828 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
831 status = _rpc_ep_unregister(&ndr_table_ntsvcs);
832 if (!NT_STATUS_IS_OK(status)) {
840 static bool eventlog_init_cb(void *ptr)
842 struct dcesrv_ep_context *ep_ctx =
843 talloc_get_type_abort(ptr, struct dcesrv_ep_context);
844 const char *rpcsrv_type;
847 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
852 ok = eventlog_init_winreg(ep_ctx->msg_ctx);
857 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
858 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
861 status =rpc_ep_setup_register(ep_ctx->ev_ctx,
866 if (!NT_STATUS_IS_OK(status)) {
874 static bool eventlog_shutdown_cb(void *ptr)
876 const char *rpcsrv_type;
878 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
883 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
884 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
887 status = _rpc_ep_unregister(&ndr_table_eventlog);
888 if (!NT_STATUS_IS_OK(status)) {
896 static bool initshutdown_init_cb(void *ptr)
898 struct dcesrv_ep_context *ep_ctx =
899 talloc_get_type_abort(ptr, struct dcesrv_ep_context);
900 const char *rpcsrv_type;
902 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
907 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
908 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
911 status = rpc_ep_setup_register(ep_ctx->ev_ctx,
913 &ndr_table_initshutdown,
916 if (!NT_STATUS_IS_OK(status)) {
924 static bool initshutdown_shutdown_cb(void *ptr)
926 const char *rpcsrv_type;
928 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
933 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
934 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
937 status = _rpc_ep_unregister(&ndr_table_initshutdown);
938 if (!NT_STATUS_IS_OK(status)) {
947 static bool rpcecho_init_cb(void *ptr) {
948 struct dcesrv_ep_context *ep_ctx =
949 talloc_get_type_abort(ptr, struct dcesrv_ep_context);
950 const char *rpcsrv_type;
953 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
958 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
959 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
962 port = _open_sockets(ep_ctx->ev_ctx,
964 ndr_table_rpcecho.syntax_id,
970 status = rpc_ep_setup_register(ep_ctx->ev_ctx,
975 if (!NT_STATUS_IS_OK(status)) {
983 static bool rpcecho_shutdown_cb(void *ptr)
985 const char *rpcsrv_type;
987 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
992 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
993 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
996 status = _rpc_ep_unregister(&ndr_table_rpcecho);
997 if (!NT_STATUS_IS_OK(status)) {
1006 static bool netdfs_init_cb(void *ptr)
1008 struct dcesrv_ep_context *ep_ctx =
1009 talloc_get_type_abort(ptr, struct dcesrv_ep_context);
1010 struct ndr_syntax_id abstract_syntax = ndr_table_netdfs.syntax_id;
1011 const char *pipe_name = "netdfs";
1012 const char *rpcsrv_type;
1015 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
1019 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
1020 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
1024 ok = setup_dcerpc_ncalrpc_socket(ep_ctx->ev_ctx,
1032 port = _open_sockets(ep_ctx->ev_ctx,
1040 status = rpc_ep_setup_register(ep_ctx->ev_ctx,
1045 if (!NT_STATUS_IS_OK(status)) {
1053 static bool netdfs_shutdown_cb(void *ptr) {
1054 const char *rpcsrv_type;
1056 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
1061 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
1062 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
1065 status = _rpc_ep_unregister(&ndr_table_netdfs);
1066 if (!NT_STATUS_IS_OK(status)) {
1074 static bool dssetup_init_cb(void *ptr)
1076 struct dcesrv_ep_context *ep_ctx =
1077 talloc_get_type_abort(ptr, struct dcesrv_ep_context);
1078 struct ndr_syntax_id abstract_syntax = ndr_table_dssetup.syntax_id;
1079 const char *pipe_name = "dssetup";
1080 const char *rpcsrv_type;
1083 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
1088 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
1089 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
1093 ok = setup_dcerpc_ncalrpc_socket(ep_ctx->ev_ctx,
1101 port = _open_sockets(ep_ctx->ev_ctx,
1109 status = rpc_ep_setup_register(ep_ctx->ev_ctx,
1114 if (!NT_STATUS_IS_OK(status)) {
1122 static bool dssetup_shutdown_cb(void *ptr) {
1123 const char *rpcsrv_type;
1125 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
1130 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
1131 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
1134 status = _rpc_ep_unregister(&ndr_table_dssetup);
1135 if (!NT_STATUS_IS_OK(status)) {
1143 static bool wkssvc_init_cb(void *ptr)
1145 struct dcesrv_ep_context *ep_ctx =
1146 talloc_get_type_abort(ptr, struct dcesrv_ep_context);
1147 struct ndr_syntax_id abstract_syntax = ndr_table_wkssvc.syntax_id;
1148 const char *pipe_name = "wkssvc";
1149 const char *rpcsrv_type;
1152 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
1156 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
1157 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
1161 ok = setup_dcerpc_ncalrpc_socket(ep_ctx->ev_ctx,
1169 port = _open_sockets(ep_ctx->ev_ctx,
1177 status = rpc_ep_setup_register(ep_ctx->ev_ctx,
1182 if (!NT_STATUS_IS_OK(status)) {
1190 static bool wkssvc_shutdown_cb(void *ptr) {
1191 return NT_STATUS_IS_OK(_rpc_ep_unregister(&ndr_table_wkssvc));
1194 bool dcesrv_ep_setup(struct tevent_context *ev_ctx,
1195 struct messaging_context *msg_ctx)
1197 struct dcesrv_ep_context *ep_ctx;
1199 struct rpc_srv_callbacks epmapper_cb;
1201 struct rpc_srv_callbacks winreg_cb;
1202 struct rpc_srv_callbacks srvsvc_cb;
1204 struct rpc_srv_callbacks lsarpc_cb;
1205 struct rpc_srv_callbacks samr_cb;
1206 struct rpc_srv_callbacks netlogon_cb;
1208 struct rpc_srv_callbacks spoolss_cb;
1209 struct rpc_srv_callbacks svcctl_cb;
1210 struct rpc_srv_callbacks ntsvcs_cb;
1211 struct rpc_srv_callbacks eventlog_cb;
1212 struct rpc_srv_callbacks initshutdown_cb;
1213 struct rpc_srv_callbacks netdfs_cb;
1215 struct rpc_srv_callbacks rpcecho_cb;
1217 struct rpc_srv_callbacks dssetup_cb;
1218 struct rpc_srv_callbacks wkssvc_cb;
1220 const char *rpcsrv_type;
1222 ep_ctx = talloc(ev_ctx, struct dcesrv_ep_context);
1223 if (ep_ctx == NULL) {
1227 ep_ctx->ev_ctx = ev_ctx;
1228 ep_ctx->msg_ctx = msg_ctx;
1230 /* start endpoint mapper only if enabled */
1231 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
1235 if (StrCaseCmp(rpcsrv_type, "embedded") == 0) {
1236 epmapper_cb.init = epmapper_init_cb;
1237 epmapper_cb.shutdown = epmapper_shutdown_cb;
1238 epmapper_cb.private_data = ep_ctx;
1240 if (!NT_STATUS_IS_OK(rpc_epmapper_init(&epmapper_cb))) {
1245 winreg_cb.init = winreg_init_cb;
1246 winreg_cb.shutdown = winreg_shutdown_cb;
1247 winreg_cb.private_data = ep_ctx;
1248 if (!NT_STATUS_IS_OK(rpc_winreg_init(&winreg_cb))) {
1252 srvsvc_cb.init = srvsvc_init_cb;
1253 srvsvc_cb.shutdown = srvsvc_shutdown_cb;
1254 srvsvc_cb.private_data = ep_ctx;
1255 if (!NT_STATUS_IS_OK(rpc_srvsvc_init(&srvsvc_cb))) {
1260 lsarpc_cb.init = lsarpc_init_cb;
1261 lsarpc_cb.shutdown = lsarpc_shutdown_cb;
1262 lsarpc_cb.private_data = ep_ctx;
1263 if (!NT_STATUS_IS_OK(rpc_lsarpc_init(&lsarpc_cb))) {
1267 samr_cb.init = samr_init_cb;
1268 samr_cb.shutdown = samr_shutdown_cb;
1269 samr_cb.private_data = ep_ctx;
1270 if (!NT_STATUS_IS_OK(rpc_samr_init(&samr_cb))) {
1274 netlogon_cb.init = netlogon_init_cb;
1275 netlogon_cb.shutdown = netlogon_shutdown_cb;
1276 netlogon_cb.private_data = ep_ctx;
1277 if (!NT_STATUS_IS_OK(rpc_netlogon_init(&netlogon_cb))) {
1281 spoolss_cb.init = spoolss_init_cb;
1282 spoolss_cb.shutdown = spoolss_shutdown_cb;
1283 spoolss_cb.private_data = ep_ctx;
1284 if (!NT_STATUS_IS_OK(rpc_spoolss_init(&spoolss_cb))) {
1289 svcctl_cb.init = svcctl_init_cb;
1290 svcctl_cb.shutdown = svcctl_shutdown_cb;
1291 svcctl_cb.private_data = ep_ctx;
1292 if (!NT_STATUS_IS_OK(rpc_svcctl_init(&svcctl_cb))) {
1296 ntsvcs_cb.init = ntsvcs_init_cb;
1297 ntsvcs_cb.shutdown = ntsvcs_shutdown_cb;
1298 ntsvcs_cb.private_data = ep_ctx;
1299 if (!NT_STATUS_IS_OK(rpc_ntsvcs_init(&ntsvcs_cb))) {
1303 eventlog_cb.init = eventlog_init_cb;
1304 eventlog_cb.shutdown = eventlog_shutdown_cb;
1305 eventlog_cb.private_data = ep_ctx;
1306 if (!NT_STATUS_IS_OK(rpc_eventlog_init(&eventlog_cb))) {
1310 initshutdown_cb.init = initshutdown_init_cb;
1311 initshutdown_cb.shutdown = initshutdown_shutdown_cb;
1312 initshutdown_cb.private_data = ep_ctx;
1313 if (!NT_STATUS_IS_OK(rpc_initshutdown_init(&initshutdown_cb))) {
1317 netdfs_cb.init = netdfs_init_cb;
1318 netdfs_cb.shutdown = netdfs_shutdown_cb;
1319 netdfs_cb.private_data = ep_ctx;
1320 if (!NT_STATUS_IS_OK(rpc_netdfs_init(&netdfs_cb))) {
1325 rpcecho_cb.init = rpcecho_init_cb;
1326 rpcecho_cb.shutdown = rpcecho_shutdown_cb;
1327 rpcecho_cb.private_data = ep_ctx;
1328 if (!NT_STATUS_IS_OK(rpc_rpcecho_init(&rpcecho_cb))) {
1333 dssetup_cb.init = dssetup_init_cb;
1334 dssetup_cb.shutdown = dssetup_shutdown_cb;
1335 dssetup_cb.private_data = ep_ctx;
1336 if (!NT_STATUS_IS_OK(rpc_dssetup_init(&dssetup_cb))) {
1340 wkssvc_cb.init = wkssvc_init_cb;
1341 wkssvc_cb.shutdown = wkssvc_shutdown_cb;
1342 wkssvc_cb.private_data = ep_ctx;
1343 if (!NT_STATUS_IS_OK(rpc_wkssvc_init(&wkssvc_cb))) {
1350 /* vim: set ts=8 sw=8 noet cindent ft=c.doxygen: */