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;
163 struct tevent_context *ev_ctx;
164 struct messaging_context *msg_ctx;
166 const struct ndr_interface_table *iface;
174 static NTSTATUS rpc_ep_setup_register(struct tevent_context *ev_ctx,
175 struct messaging_context *msg_ctx,
176 const struct ndr_interface_table *iface,
180 struct rpc_ep_regsiter_state *state;
181 struct tevent_req *req;
183 state = talloc(ev_ctx, struct rpc_ep_regsiter_state);
185 return NT_STATUS_NO_MEMORY;
188 state->wait_time = 1;
189 state->ev_ctx = ev_ctx;
190 state->msg_ctx = msg_ctx;
191 state->iface = iface;
192 state->ncalrpc = talloc_strdup(state, ncalrpc);
195 req = tevent_wakeup_send(state, ev_ctx, timeval_current_ofs(1, 0));
196 if (tevent_req_nomem(state, req)) {
198 return NT_STATUS_NO_MEMORY;
201 tevent_req_set_callback(req, rpc_ep_setup_register_loop, state);
206 static void rpc_ep_setup_register_loop(struct tevent_req *req)
208 struct rpc_ep_regsiter_state *state =
209 tevent_req_callback_data(req, struct rpc_ep_regsiter_state);
213 ok = tevent_wakeup_recv(req);
220 status = rpc_ep_setup_try_register(state,
227 if (NT_STATUS_IS_OK(status)) {
232 state->wait_time = state->wait_time * 2;
233 if (state->wait_time > 16) {
238 req = tevent_wakeup_send(state,
240 timeval_current_ofs(state->wait_time, 0));
241 if (tevent_req_nomem(state, req)) {
246 tevent_req_set_callback(req, rpc_ep_setup_register_loop, state);
250 static NTSTATUS rpc_ep_setup_try_register(TALLOC_CTX *mem_ctx,
251 struct tevent_context *ev_ctx,
252 struct messaging_context *msg_ctx,
253 const struct ndr_interface_table *iface,
256 struct dcerpc_binding_handle **pbh)
258 struct dcerpc_binding_vector *v = NULL;
261 status = dcerpc_binding_vector_create(mem_ctx,
266 if (!NT_STATUS_IS_OK(status)) {
270 status = dcerpc_ep_register(mem_ctx,
273 &iface->syntax_id.uuid,
277 if (!NT_STATUS_IS_OK(status)) {
284 static bool epmapper_init_cb(void *ptr)
286 struct dcesrv_ep_context *ep_ctx =
287 talloc_get_type_abort(ptr, struct dcesrv_ep_context);
290 port = _open_sockets(ep_ctx->ev_ctx,
292 ndr_table_epmapper.syntax_id,
301 static bool epmapper_shutdown_cb(void *ptr)
303 srv_epmapper_cleanup();
308 static bool winreg_init_cb(void *ptr)
310 struct dcesrv_ep_context *ep_ctx =
311 talloc_get_type_abort(ptr, struct dcesrv_ep_context);
312 struct ndr_syntax_id abstract_syntax = ndr_table_winreg.syntax_id;
313 const char *pipe_name = "winreg";
314 const char *rpcsrv_type;
317 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
322 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
323 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
327 ok = setup_dcerpc_ncalrpc_socket(ep_ctx->ev_ctx,
334 port = _open_sockets(ep_ctx->ev_ctx,
342 status = rpc_ep_setup_register(ep_ctx->ev_ctx,
347 if (!NT_STATUS_IS_OK(status)) {
355 static bool winreg_shutdown_cb(void *ptr)
357 const char *rpcsrv_type;
359 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
364 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
365 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
368 status = _rpc_ep_unregister(&ndr_table_winreg);
369 if (!NT_STATUS_IS_OK(status)) {
377 static bool srvsvc_init_cb(void *ptr)
379 struct dcesrv_ep_context *ep_ctx =
380 talloc_get_type_abort(ptr, struct dcesrv_ep_context);
381 struct ndr_syntax_id abstract_syntax = ndr_table_srvsvc.syntax_id;
382 const char *pipe_name = "srvsvc";
383 const char *rpcsrv_type;
386 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
391 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
392 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
396 ok = setup_dcerpc_ncalrpc_socket(ep_ctx->ev_ctx,
404 port = _open_sockets(ep_ctx->ev_ctx,
412 status = rpc_ep_setup_register(ep_ctx->ev_ctx,
417 if (!NT_STATUS_IS_OK(status)) {
425 static bool srvsvc_shutdown_cb(void *ptr)
427 const char *rpcsrv_type;
429 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
434 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
435 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
438 status =_rpc_ep_unregister(&ndr_table_srvsvc);
439 if (!NT_STATUS_IS_OK(status)) {
447 static bool lsarpc_init_cb(void *ptr)
449 struct dcesrv_ep_context *ep_ctx =
450 talloc_get_type_abort(ptr, struct dcesrv_ep_context);
451 struct ndr_syntax_id abstract_syntax = ndr_table_lsarpc.syntax_id;
452 const char *pipe_name = "lsarpc";
453 const char *rpcsrv_type;
456 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
461 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
462 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
466 ok = setup_dcerpc_ncalrpc_socket(ep_ctx->ev_ctx,
474 port = _open_sockets(ep_ctx->ev_ctx,
482 status = rpc_ep_setup_register(ep_ctx->ev_ctx,
487 if (!NT_STATUS_IS_OK(status)) {
495 static bool lsarpc_shutdown_cb(void *ptr)
497 const char *rpcsrv_type;
499 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
504 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
505 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
508 status = _rpc_ep_unregister(&ndr_table_lsarpc);
509 if (!NT_STATUS_IS_OK(status)) {
517 static bool samr_init_cb(void *ptr)
519 struct dcesrv_ep_context *ep_ctx =
520 talloc_get_type_abort(ptr, struct dcesrv_ep_context);
521 struct ndr_syntax_id abstract_syntax = ndr_table_samr.syntax_id;
522 const char *pipe_name = "samr";
523 const char *rpcsrv_type;
526 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
531 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
532 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
536 ok = setup_dcerpc_ncalrpc_socket(ep_ctx->ev_ctx,
544 port = _open_sockets(ep_ctx->ev_ctx,
552 status = rpc_ep_setup_register(ep_ctx->ev_ctx,
557 if (!NT_STATUS_IS_OK(status)) {
565 static bool samr_shutdown_cb(void *ptr)
567 const char *rpcsrv_type;
569 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
574 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
575 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
578 status = _rpc_ep_unregister(&ndr_table_samr);
579 if (!NT_STATUS_IS_OK(status)) {
587 static bool netlogon_init_cb(void *ptr)
589 struct dcesrv_ep_context *ep_ctx =
590 talloc_get_type_abort(ptr, struct dcesrv_ep_context);
591 struct ndr_syntax_id abstract_syntax = ndr_table_netlogon.syntax_id;
592 const char *pipe_name = "netlogon";
593 const char *rpcsrv_type;
596 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
601 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
602 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
606 ok = setup_dcerpc_ncalrpc_socket(ep_ctx->ev_ctx,
614 port = _open_sockets(ep_ctx->ev_ctx,
622 status = rpc_ep_setup_register(ep_ctx->ev_ctx,
627 if (!NT_STATUS_IS_OK(status)) {
635 static bool netlogon_shutdown_cb(void *ptr)
637 const char *rpcsrv_type;
639 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
644 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
645 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
648 status = _rpc_ep_unregister(&ndr_table_netlogon);
649 if (!NT_STATUS_IS_OK(status)) {
657 static bool spoolss_init_cb(void *ptr)
659 struct dcesrv_ep_context *ep_ctx =
660 talloc_get_type_abort(ptr, struct dcesrv_ep_context);
661 const char *rpcsrv_type;
664 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
670 * Migrate the printers first.
672 ok = nt_printing_tdb_migrate(ep_ctx->msg_ctx);
677 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
678 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
681 status =rpc_ep_setup_register(ep_ctx->ev_ctx,
686 if (!NT_STATUS_IS_OK(status)) {
694 static bool spoolss_shutdown_cb(void *ptr)
696 const char *rpcsrv_type;
698 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
703 srv_spoolss_cleanup();
705 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
706 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
709 status = _rpc_ep_unregister(&ndr_table_spoolss);
710 if (!NT_STATUS_IS_OK(status)) {
718 static bool svcctl_init_cb(void *ptr)
720 struct dcesrv_ep_context *ep_ctx =
721 talloc_get_type_abort(ptr, struct dcesrv_ep_context);
722 const char *rpcsrv_type;
725 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
730 ok = svcctl_init_winreg(ep_ctx->msg_ctx);
735 /* initialize the control hooks */
736 init_service_op_table();
738 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
739 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
742 status = rpc_ep_setup_register(ep_ctx->ev_ctx,
747 if (!NT_STATUS_IS_OK(status)) {
755 static bool svcctl_shutdown_cb(void *ptr)
757 const char *rpcsrv_type;
759 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
763 shutdown_service_op_table();
765 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
766 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
769 status = _rpc_ep_unregister(&ndr_table_svcctl);
770 if (!NT_STATUS_IS_OK(status)) {
778 static bool ntsvcs_init_cb(void *ptr)
780 struct dcesrv_ep_context *ep_ctx =
781 talloc_get_type_abort(ptr, struct dcesrv_ep_context);
782 const char *rpcsrv_type;
784 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
789 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
790 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
793 status = rpc_ep_setup_register(ep_ctx->ev_ctx,
798 if (!NT_STATUS_IS_OK(status)) {
806 static bool ntsvcs_shutdown_cb(void *ptr)
808 const char *rpcsrv_type;
810 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
815 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
816 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
819 status = _rpc_ep_unregister(&ndr_table_ntsvcs);
820 if (!NT_STATUS_IS_OK(status)) {
828 static bool eventlog_init_cb(void *ptr)
830 struct dcesrv_ep_context *ep_ctx =
831 talloc_get_type_abort(ptr, struct dcesrv_ep_context);
832 const char *rpcsrv_type;
835 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
840 ok = eventlog_init_winreg(ep_ctx->msg_ctx);
845 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
846 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
849 status =rpc_ep_setup_register(ep_ctx->ev_ctx,
854 if (!NT_STATUS_IS_OK(status)) {
862 static bool eventlog_shutdown_cb(void *ptr)
864 const char *rpcsrv_type;
866 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
871 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
872 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
875 status = _rpc_ep_unregister(&ndr_table_eventlog);
876 if (!NT_STATUS_IS_OK(status)) {
884 static bool initshutdown_init_cb(void *ptr)
886 struct dcesrv_ep_context *ep_ctx =
887 talloc_get_type_abort(ptr, struct dcesrv_ep_context);
888 const char *rpcsrv_type;
890 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
895 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
896 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
899 status = rpc_ep_setup_register(ep_ctx->ev_ctx,
901 &ndr_table_initshutdown,
904 if (!NT_STATUS_IS_OK(status)) {
912 static bool initshutdown_shutdown_cb(void *ptr)
914 const char *rpcsrv_type;
916 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
921 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
922 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
925 status = _rpc_ep_unregister(&ndr_table_initshutdown);
926 if (!NT_STATUS_IS_OK(status)) {
935 static bool rpcecho_init_cb(void *ptr) {
936 struct dcesrv_ep_context *ep_ctx =
937 talloc_get_type_abort(ptr, struct dcesrv_ep_context);
938 const char *rpcsrv_type;
941 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
946 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
947 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
950 port = _open_sockets(ep_ctx->ev_ctx,
952 ndr_table_rpcecho.syntax_id,
958 status = rpc_ep_setup_register(ep_ctx->ev_ctx,
963 if (!NT_STATUS_IS_OK(status)) {
971 static bool rpcecho_shutdown_cb(void *ptr)
973 const char *rpcsrv_type;
975 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
980 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
981 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
984 status = _rpc_ep_unregister(&ndr_table_rpcecho);
985 if (!NT_STATUS_IS_OK(status)) {
994 static bool netdfs_init_cb(void *ptr)
996 struct dcesrv_ep_context *ep_ctx =
997 talloc_get_type_abort(ptr, struct dcesrv_ep_context);
998 struct ndr_syntax_id abstract_syntax = ndr_table_netdfs.syntax_id;
999 const char *pipe_name = "netdfs";
1000 const char *rpcsrv_type;
1003 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
1007 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
1008 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
1012 ok = setup_dcerpc_ncalrpc_socket(ep_ctx->ev_ctx,
1020 port = _open_sockets(ep_ctx->ev_ctx,
1028 status = rpc_ep_setup_register(ep_ctx->ev_ctx,
1033 if (!NT_STATUS_IS_OK(status)) {
1041 static bool netdfs_shutdown_cb(void *ptr) {
1042 const char *rpcsrv_type;
1044 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
1049 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
1050 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
1053 status = _rpc_ep_unregister(&ndr_table_netdfs);
1054 if (!NT_STATUS_IS_OK(status)) {
1062 static bool dssetup_init_cb(void *ptr)
1064 struct dcesrv_ep_context *ep_ctx =
1065 talloc_get_type_abort(ptr, struct dcesrv_ep_context);
1066 struct ndr_syntax_id abstract_syntax = ndr_table_dssetup.syntax_id;
1067 const char *pipe_name = "dssetup";
1068 const char *rpcsrv_type;
1071 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
1076 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
1077 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
1081 ok = setup_dcerpc_ncalrpc_socket(ep_ctx->ev_ctx,
1089 port = _open_sockets(ep_ctx->ev_ctx,
1097 status = rpc_ep_setup_register(ep_ctx->ev_ctx,
1102 if (!NT_STATUS_IS_OK(status)) {
1110 static bool dssetup_shutdown_cb(void *ptr) {
1111 const char *rpcsrv_type;
1113 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
1118 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
1119 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
1122 status = _rpc_ep_unregister(&ndr_table_dssetup);
1123 if (!NT_STATUS_IS_OK(status)) {
1131 static bool wkssvc_init_cb(void *ptr)
1133 struct dcesrv_ep_context *ep_ctx =
1134 talloc_get_type_abort(ptr, struct dcesrv_ep_context);
1135 struct ndr_syntax_id abstract_syntax = ndr_table_wkssvc.syntax_id;
1136 const char *pipe_name = "wkssvc";
1137 const char *rpcsrv_type;
1140 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
1144 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
1145 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
1149 ok = setup_dcerpc_ncalrpc_socket(ep_ctx->ev_ctx,
1157 port = _open_sockets(ep_ctx->ev_ctx,
1165 status = rpc_ep_setup_register(ep_ctx->ev_ctx,
1170 if (!NT_STATUS_IS_OK(status)) {
1178 static bool wkssvc_shutdown_cb(void *ptr) {
1179 return NT_STATUS_IS_OK(_rpc_ep_unregister(&ndr_table_wkssvc));
1182 bool dcesrv_ep_setup(struct tevent_context *ev_ctx,
1183 struct messaging_context *msg_ctx)
1185 struct dcesrv_ep_context *ep_ctx;
1187 struct rpc_srv_callbacks epmapper_cb;
1189 struct rpc_srv_callbacks winreg_cb;
1190 struct rpc_srv_callbacks srvsvc_cb;
1192 struct rpc_srv_callbacks lsarpc_cb;
1193 struct rpc_srv_callbacks samr_cb;
1194 struct rpc_srv_callbacks netlogon_cb;
1196 struct rpc_srv_callbacks spoolss_cb;
1197 struct rpc_srv_callbacks svcctl_cb;
1198 struct rpc_srv_callbacks ntsvcs_cb;
1199 struct rpc_srv_callbacks eventlog_cb;
1200 struct rpc_srv_callbacks initshutdown_cb;
1201 struct rpc_srv_callbacks netdfs_cb;
1203 struct rpc_srv_callbacks rpcecho_cb;
1205 struct rpc_srv_callbacks dssetup_cb;
1206 struct rpc_srv_callbacks wkssvc_cb;
1208 const char *rpcsrv_type;
1210 ep_ctx = talloc(ev_ctx, struct dcesrv_ep_context);
1211 if (ep_ctx == NULL) {
1215 ep_ctx->ev_ctx = ev_ctx;
1216 ep_ctx->msg_ctx = msg_ctx;
1218 /* start endpoint mapper only if enabled */
1219 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
1223 if (StrCaseCmp(rpcsrv_type, "embedded") == 0) {
1224 epmapper_cb.init = epmapper_init_cb;
1225 epmapper_cb.shutdown = epmapper_shutdown_cb;
1226 epmapper_cb.private_data = ep_ctx;
1228 if (!NT_STATUS_IS_OK(rpc_epmapper_init(&epmapper_cb))) {
1233 winreg_cb.init = winreg_init_cb;
1234 winreg_cb.shutdown = winreg_shutdown_cb;
1235 winreg_cb.private_data = ep_ctx;
1236 if (!NT_STATUS_IS_OK(rpc_winreg_init(&winreg_cb))) {
1240 srvsvc_cb.init = srvsvc_init_cb;
1241 srvsvc_cb.shutdown = srvsvc_shutdown_cb;
1242 srvsvc_cb.private_data = ep_ctx;
1243 if (!NT_STATUS_IS_OK(rpc_srvsvc_init(&srvsvc_cb))) {
1248 lsarpc_cb.init = lsarpc_init_cb;
1249 lsarpc_cb.shutdown = lsarpc_shutdown_cb;
1250 lsarpc_cb.private_data = ep_ctx;
1251 if (!NT_STATUS_IS_OK(rpc_lsarpc_init(&lsarpc_cb))) {
1255 samr_cb.init = samr_init_cb;
1256 samr_cb.shutdown = samr_shutdown_cb;
1257 samr_cb.private_data = ep_ctx;
1258 if (!NT_STATUS_IS_OK(rpc_samr_init(&samr_cb))) {
1262 netlogon_cb.init = netlogon_init_cb;
1263 netlogon_cb.shutdown = netlogon_shutdown_cb;
1264 netlogon_cb.private_data = ep_ctx;
1265 if (!NT_STATUS_IS_OK(rpc_netlogon_init(&netlogon_cb))) {
1269 spoolss_cb.init = spoolss_init_cb;
1270 spoolss_cb.shutdown = spoolss_shutdown_cb;
1271 spoolss_cb.private_data = ep_ctx;
1272 if (!NT_STATUS_IS_OK(rpc_spoolss_init(&spoolss_cb))) {
1277 svcctl_cb.init = svcctl_init_cb;
1278 svcctl_cb.shutdown = svcctl_shutdown_cb;
1279 svcctl_cb.private_data = ep_ctx;
1280 if (!NT_STATUS_IS_OK(rpc_svcctl_init(&svcctl_cb))) {
1284 ntsvcs_cb.init = ntsvcs_init_cb;
1285 ntsvcs_cb.shutdown = ntsvcs_shutdown_cb;
1286 ntsvcs_cb.private_data = ep_ctx;
1287 if (!NT_STATUS_IS_OK(rpc_ntsvcs_init(&ntsvcs_cb))) {
1291 eventlog_cb.init = eventlog_init_cb;
1292 eventlog_cb.shutdown = eventlog_shutdown_cb;
1293 eventlog_cb.private_data = ep_ctx;
1294 if (!NT_STATUS_IS_OK(rpc_eventlog_init(&eventlog_cb))) {
1298 initshutdown_cb.init = initshutdown_init_cb;
1299 initshutdown_cb.shutdown = initshutdown_shutdown_cb;
1300 initshutdown_cb.private_data = ep_ctx;
1301 if (!NT_STATUS_IS_OK(rpc_initshutdown_init(&initshutdown_cb))) {
1305 netdfs_cb.init = netdfs_init_cb;
1306 netdfs_cb.shutdown = netdfs_shutdown_cb;
1307 netdfs_cb.private_data = ep_ctx;
1308 if (!NT_STATUS_IS_OK(rpc_netdfs_init(&netdfs_cb))) {
1313 rpcecho_cb.init = rpcecho_init_cb;
1314 rpcecho_cb.shutdown = rpcecho_shutdown_cb;
1315 rpcecho_cb.private_data = ep_ctx;
1316 if (!NT_STATUS_IS_OK(rpc_rpcecho_init(&rpcecho_cb))) {
1321 dssetup_cb.init = dssetup_init_cb;
1322 dssetup_cb.shutdown = dssetup_shutdown_cb;
1323 dssetup_cb.private_data = ep_ctx;
1324 if (!NT_STATUS_IS_OK(rpc_dssetup_init(&dssetup_cb))) {
1328 wkssvc_cb.init = wkssvc_init_cb;
1329 wkssvc_cb.shutdown = wkssvc_shutdown_cb;
1330 wkssvc_cb.private_data = ep_ctx;
1331 if (!NT_STATUS_IS_OK(rpc_wkssvc_init(&wkssvc_cb))) {
1338 /* vim: set ts=8 sw=8 noet cindent ft=c.doxygen: */