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/ndr_epmapper_c.h"
25 #include "../librpc/gen_ndr/srv_epmapper.h"
26 #include "../librpc/gen_ndr/srv_srvsvc.h"
27 #include "../librpc/gen_ndr/srv_winreg.h"
28 #include "../librpc/gen_ndr/srv_dfs.h"
29 #include "../librpc/gen_ndr/srv_dssetup.h"
30 #include "../librpc/gen_ndr/srv_echo.h"
31 #include "../librpc/gen_ndr/srv_eventlog.h"
32 #include "../librpc/gen_ndr/srv_initshutdown.h"
33 #include "../librpc/gen_ndr/srv_lsa.h"
34 #include "../librpc/gen_ndr/srv_netlogon.h"
35 #include "../librpc/gen_ndr/srv_ntsvcs.h"
36 #include "../librpc/gen_ndr/srv_samr.h"
37 #include "../librpc/gen_ndr/srv_spoolss.h"
38 #include "../librpc/gen_ndr/srv_svcctl.h"
39 #include "../librpc/gen_ndr/srv_wkssvc.h"
41 #include "printing/nt_printing_migrate.h"
42 #include "rpc_server/eventlog/srv_eventlog_reg.h"
43 #include "rpc_server/svcctl/srv_svcctl_reg.h"
45 #include "librpc/rpc/dcerpc_ep.h"
47 #include "rpc_server/rpc_ep_setup.h"
48 #include "rpc_server/rpc_server.h"
49 #include "rpc_server/epmapper/srv_epmapper.h"
51 struct dcesrv_ep_context {
52 struct tevent_context *ev_ctx;
53 struct messaging_context *msg_ctx;
56 static uint16_t _open_sockets(struct tevent_context *ev_ctx,
57 struct messaging_context *msg_ctx,
58 struct ndr_syntax_id syntax_id,
61 uint32_t num_ifs = iface_count();
65 if (lp_interfaces() && lp_bind_interfaces_only()) {
67 * We have been given an interfaces line, and been told to only
68 * bind to those interfaces. Create a socket per interface and
72 /* Now open a listen socket for each of the interfaces. */
73 for(i = 0; i < num_ifs; i++) {
74 const struct sockaddr_storage *ifss =
75 iface_n_sockaddr_storage(i);
77 p = setup_dcerpc_ncacn_tcpip_socket(ev_ctx,
88 const char *sock_addr = lp_socket_address();
92 if (strequal(sock_addr, "0.0.0.0") ||
93 strequal(sock_addr, "::")) {
97 sock_addr = "0.0.0.0";
101 for (sock_ptr = sock_addr;
102 next_token_talloc(talloc_tos(), &sock_ptr, &sock_tok, " \t,");
104 struct sockaddr_storage ss;
106 /* open an incoming socket */
107 if (!interpret_string_addr(&ss,
109 AI_NUMERICHOST|AI_PASSIVE)) {
113 p = setup_dcerpc_ncacn_tcpip_socket(ev_ctx,
128 static NTSTATUS _rpc_ep_unregister(const struct ndr_interface_table *iface)
130 struct dcerpc_binding_vector *v = NULL;
133 status = dcerpc_binding_vector_create(talloc_tos(),
138 if (!NT_STATUS_IS_OK(status)) {
142 status = dcerpc_ep_unregister(iface,
144 &iface->syntax_id.uuid);
145 if (!NT_STATUS_IS_OK(status)) {
152 static void rpc_ep_setup_register_loop(struct tevent_req *subreq);
153 static NTSTATUS rpc_ep_setup_try_register(TALLOC_CTX *mem_ctx,
154 struct tevent_context *ev_ctx,
155 struct messaging_context *msg_ctx,
156 const struct ndr_interface_table *iface,
159 struct dcerpc_binding_handle **pbh);
161 struct rpc_ep_regsiter_state {
162 struct dcerpc_binding_handle *h;
165 struct tevent_context *ev_ctx;
166 struct messaging_context *msg_ctx;
168 const struct ndr_interface_table *iface;
176 static NTSTATUS rpc_ep_setup_register(struct tevent_context *ev_ctx,
177 struct messaging_context *msg_ctx,
178 const struct ndr_interface_table *iface,
182 struct rpc_ep_regsiter_state *state;
183 struct tevent_req *req;
185 state = talloc(ev_ctx, struct rpc_ep_regsiter_state);
187 return NT_STATUS_NO_MEMORY;
190 state->mem_ctx = talloc_named(state,
194 if (state->mem_ctx == NULL) {
196 return NT_STATUS_NO_MEMORY;
199 state->wait_time = 1;
200 state->ev_ctx = ev_ctx;
201 state->msg_ctx = msg_ctx;
202 state->iface = iface;
203 state->ncalrpc = talloc_strdup(state, ncalrpc);
206 req = tevent_wakeup_send(state->mem_ctx,
208 timeval_current_ofs(1, 0));
209 if (tevent_req_nomem(state->mem_ctx, req)) {
211 return NT_STATUS_NO_MEMORY;
214 tevent_req_set_callback(req, rpc_ep_setup_register_loop, state);
219 #define MONITOR_WAIT_TIME 15
220 static void rpc_ep_setup_monitor_loop(struct tevent_req *subreq);
222 static void rpc_ep_setup_register_loop(struct tevent_req *subreq)
224 struct rpc_ep_regsiter_state *state =
225 tevent_req_callback_data(subreq, struct rpc_ep_regsiter_state);
229 ok = tevent_wakeup_recv(subreq);
236 status = rpc_ep_setup_try_register(state->mem_ctx,
243 if (NT_STATUS_IS_OK(status)) {
244 /* endpoint registered, monitor the connnection. */
245 subreq = tevent_wakeup_send(state->mem_ctx,
247 timeval_current_ofs(MONITOR_WAIT_TIME, 0));
248 if (tevent_req_nomem(state->mem_ctx, subreq)) {
253 tevent_req_set_callback(subreq, rpc_ep_setup_monitor_loop, state);
257 state->wait_time = state->wait_time * 2;
258 if (state->wait_time > 16) {
263 subreq = tevent_wakeup_send(state->mem_ctx,
265 timeval_current_ofs(state->wait_time, 0));
266 if (tevent_req_nomem(state->mem_ctx, subreq)) {
271 tevent_req_set_callback(subreq, rpc_ep_setup_register_loop, state);
275 static NTSTATUS rpc_ep_setup_try_register(TALLOC_CTX *mem_ctx,
276 struct tevent_context *ev_ctx,
277 struct messaging_context *msg_ctx,
278 const struct ndr_interface_table *iface,
281 struct dcerpc_binding_handle **pbh)
283 struct dcerpc_binding_vector *v = NULL;
286 status = dcerpc_binding_vector_create(mem_ctx,
291 if (!NT_STATUS_IS_OK(status)) {
295 status = dcerpc_ep_register(mem_ctx,
298 &iface->syntax_id.uuid,
302 if (!NT_STATUS_IS_OK(status)) {
310 * Monitor the connection to the endpoint mapper and if it goes away, try to
311 * register the endpoint.
313 static void rpc_ep_setup_monitor_loop(struct tevent_req *subreq)
315 struct rpc_ep_regsiter_state *state =
316 tevent_req_callback_data(subreq, struct rpc_ep_regsiter_state);
317 struct policy_handle entry_handle;
318 struct dcerpc_binding map_binding;
319 struct epm_twr_p_t towers[10];
320 struct epm_twr_t *map_tower;
321 uint32_t num_towers = 0;
324 uint32_t result = EPMAPPER_STATUS_CANT_PERFORM_OP;
329 ZERO_STRUCT(entry_handle);
331 tmp_ctx = talloc_stackframe();
332 if (tmp_ctx == NULL) {
337 ok = tevent_wakeup_recv(subreq);
344 /* Create map tower */
345 map_binding.transport = NCACN_NP;
346 map_binding.object = state->iface->syntax_id;
347 map_binding.host = "";
348 map_binding.endpoint = "";
350 map_tower = talloc_zero(tmp_ctx, struct epm_twr_t);
351 if (map_tower == NULL) {
352 talloc_free(tmp_ctx);
357 status = dcerpc_binding_build_tower(map_tower, &map_binding,
359 if (!NT_STATUS_IS_OK(status)) {
360 talloc_free(tmp_ctx);
366 status = dcerpc_epm_Map(state->h,
375 if (NT_STATUS_IS_OK(status)) {
378 if (result == EPMAPPER_STATUS_OK ||
379 result == EPMAPPER_STATUS_NO_MORE_ENTRIES) {
382 if (num_towers == 0) {
386 talloc_free(tmp_ctx);
388 subreq = tevent_wakeup_send(state->mem_ctx,
390 timeval_current_ofs(MONITOR_WAIT_TIME, 0));
391 if (tevent_req_nomem(state->mem_ctx, subreq)) {
397 tevent_req_set_callback(subreq, rpc_ep_setup_monitor_loop, state);
399 TALLOC_FREE(state->h);
400 state->wait_time = 1;
402 tevent_req_set_callback(subreq, rpc_ep_setup_register_loop, state);
408 static bool epmapper_init_cb(void *ptr)
410 struct dcesrv_ep_context *ep_ctx =
411 talloc_get_type_abort(ptr, struct dcesrv_ep_context);
414 port = _open_sockets(ep_ctx->ev_ctx,
416 ndr_table_epmapper.syntax_id,
425 static bool epmapper_shutdown_cb(void *ptr)
427 srv_epmapper_cleanup();
432 static bool winreg_init_cb(void *ptr)
434 struct dcesrv_ep_context *ep_ctx =
435 talloc_get_type_abort(ptr, struct dcesrv_ep_context);
436 struct ndr_syntax_id abstract_syntax = ndr_table_winreg.syntax_id;
437 const char *pipe_name = "winreg";
438 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) {
451 ok = setup_dcerpc_ncalrpc_socket(ep_ctx->ev_ctx,
459 port = _open_sockets(ep_ctx->ev_ctx,
467 status = rpc_ep_setup_register(ep_ctx->ev_ctx,
472 if (!NT_STATUS_IS_OK(status)) {
480 static bool winreg_shutdown_cb(void *ptr)
482 const char *rpcsrv_type;
484 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
489 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
490 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
493 status = _rpc_ep_unregister(&ndr_table_winreg);
494 if (!NT_STATUS_IS_OK(status)) {
502 static bool srvsvc_init_cb(void *ptr)
504 struct dcesrv_ep_context *ep_ctx =
505 talloc_get_type_abort(ptr, struct dcesrv_ep_context);
506 struct ndr_syntax_id abstract_syntax = ndr_table_srvsvc.syntax_id;
507 const char *pipe_name = "srvsvc";
508 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) {
521 ok = setup_dcerpc_ncalrpc_socket(ep_ctx->ev_ctx,
530 port = _open_sockets(ep_ctx->ev_ctx,
538 status = rpc_ep_setup_register(ep_ctx->ev_ctx,
543 if (!NT_STATUS_IS_OK(status)) {
551 static bool srvsvc_shutdown_cb(void *ptr)
553 const char *rpcsrv_type;
555 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
560 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
561 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
564 status =_rpc_ep_unregister(&ndr_table_srvsvc);
565 if (!NT_STATUS_IS_OK(status)) {
573 static bool lsarpc_init_cb(void *ptr)
575 struct dcesrv_ep_context *ep_ctx =
576 talloc_get_type_abort(ptr, struct dcesrv_ep_context);
577 struct ndr_syntax_id abstract_syntax = ndr_table_lsarpc.syntax_id;
578 const char *pipe_name = "lsarpc";
579 const char *rpcsrv_type;
582 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
587 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
588 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
592 ok = setup_dcerpc_ncalrpc_socket(ep_ctx->ev_ctx,
601 port = _open_sockets(ep_ctx->ev_ctx,
609 status = rpc_ep_setup_register(ep_ctx->ev_ctx,
614 if (!NT_STATUS_IS_OK(status)) {
622 static bool lsarpc_shutdown_cb(void *ptr)
624 const char *rpcsrv_type;
626 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
631 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
632 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
635 status = _rpc_ep_unregister(&ndr_table_lsarpc);
636 if (!NT_STATUS_IS_OK(status)) {
644 static bool samr_init_cb(void *ptr)
646 struct dcesrv_ep_context *ep_ctx =
647 talloc_get_type_abort(ptr, struct dcesrv_ep_context);
648 struct ndr_syntax_id abstract_syntax = ndr_table_samr.syntax_id;
649 const char *pipe_name = "samr";
650 const char *rpcsrv_type;
653 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
658 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
659 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
663 ok = setup_dcerpc_ncalrpc_socket(ep_ctx->ev_ctx,
672 port = _open_sockets(ep_ctx->ev_ctx,
680 status = rpc_ep_setup_register(ep_ctx->ev_ctx,
685 if (!NT_STATUS_IS_OK(status)) {
693 static bool samr_shutdown_cb(void *ptr)
695 const char *rpcsrv_type;
697 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
702 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
703 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
706 status = _rpc_ep_unregister(&ndr_table_samr);
707 if (!NT_STATUS_IS_OK(status)) {
715 static bool netlogon_init_cb(void *ptr)
717 struct dcesrv_ep_context *ep_ctx =
718 talloc_get_type_abort(ptr, struct dcesrv_ep_context);
719 struct ndr_syntax_id abstract_syntax = ndr_table_netlogon.syntax_id;
720 const char *pipe_name = "netlogon";
721 const char *rpcsrv_type;
724 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
729 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
730 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
734 ok = setup_dcerpc_ncalrpc_socket(ep_ctx->ev_ctx,
743 port = _open_sockets(ep_ctx->ev_ctx,
751 status = rpc_ep_setup_register(ep_ctx->ev_ctx,
756 if (!NT_STATUS_IS_OK(status)) {
764 static bool netlogon_shutdown_cb(void *ptr)
766 const char *rpcsrv_type;
768 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
773 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
774 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
777 status = _rpc_ep_unregister(&ndr_table_netlogon);
778 if (!NT_STATUS_IS_OK(status)) {
786 static bool spoolss_init_cb(void *ptr)
788 struct dcesrv_ep_context *ep_ctx =
789 talloc_get_type_abort(ptr, struct dcesrv_ep_context);
790 const char *rpcsrv_type;
793 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
799 * Migrate the printers first.
801 ok = nt_printing_tdb_migrate(ep_ctx->msg_ctx);
806 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
807 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
810 status =rpc_ep_setup_register(ep_ctx->ev_ctx,
815 if (!NT_STATUS_IS_OK(status)) {
823 static bool spoolss_shutdown_cb(void *ptr)
825 const char *rpcsrv_type;
827 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
832 srv_spoolss_cleanup();
834 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
835 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
838 status = _rpc_ep_unregister(&ndr_table_spoolss);
839 if (!NT_STATUS_IS_OK(status)) {
847 static bool svcctl_init_cb(void *ptr)
849 struct dcesrv_ep_context *ep_ctx =
850 talloc_get_type_abort(ptr, struct dcesrv_ep_context);
851 const char *rpcsrv_type;
854 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
859 ok = svcctl_init_winreg(ep_ctx->msg_ctx);
864 /* initialize the control hooks */
865 init_service_op_table();
867 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
868 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
871 status = rpc_ep_setup_register(ep_ctx->ev_ctx,
876 if (!NT_STATUS_IS_OK(status)) {
884 static bool svcctl_shutdown_cb(void *ptr)
886 const char *rpcsrv_type;
888 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
892 shutdown_service_op_table();
894 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
895 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
898 status = _rpc_ep_unregister(&ndr_table_svcctl);
899 if (!NT_STATUS_IS_OK(status)) {
907 static bool ntsvcs_init_cb(void *ptr)
909 struct dcesrv_ep_context *ep_ctx =
910 talloc_get_type_abort(ptr, struct dcesrv_ep_context);
911 const char *rpcsrv_type;
913 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
918 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
919 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
922 status = rpc_ep_setup_register(ep_ctx->ev_ctx,
927 if (!NT_STATUS_IS_OK(status)) {
935 static bool ntsvcs_shutdown_cb(void *ptr)
937 const char *rpcsrv_type;
939 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
944 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
945 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
948 status = _rpc_ep_unregister(&ndr_table_ntsvcs);
949 if (!NT_STATUS_IS_OK(status)) {
957 static bool eventlog_init_cb(void *ptr)
959 struct dcesrv_ep_context *ep_ctx =
960 talloc_get_type_abort(ptr, struct dcesrv_ep_context);
961 const char *rpcsrv_type;
964 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
969 ok = eventlog_init_winreg(ep_ctx->msg_ctx);
974 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
975 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
978 status =rpc_ep_setup_register(ep_ctx->ev_ctx,
983 if (!NT_STATUS_IS_OK(status)) {
991 static bool eventlog_shutdown_cb(void *ptr)
993 const char *rpcsrv_type;
995 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
1000 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
1001 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
1004 status = _rpc_ep_unregister(&ndr_table_eventlog);
1005 if (!NT_STATUS_IS_OK(status)) {
1013 static bool initshutdown_init_cb(void *ptr)
1015 struct dcesrv_ep_context *ep_ctx =
1016 talloc_get_type_abort(ptr, struct dcesrv_ep_context);
1017 const char *rpcsrv_type;
1019 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
1024 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
1025 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
1028 status = rpc_ep_setup_register(ep_ctx->ev_ctx,
1030 &ndr_table_initshutdown,
1033 if (!NT_STATUS_IS_OK(status)) {
1041 static bool initshutdown_shutdown_cb(void *ptr)
1043 const char *rpcsrv_type;
1045 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
1050 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
1051 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
1054 status = _rpc_ep_unregister(&ndr_table_initshutdown);
1055 if (!NT_STATUS_IS_OK(status)) {
1064 static bool rpcecho_init_cb(void *ptr) {
1065 struct dcesrv_ep_context *ep_ctx =
1066 talloc_get_type_abort(ptr, struct dcesrv_ep_context);
1067 const char *rpcsrv_type;
1070 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
1075 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
1076 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
1079 port = _open_sockets(ep_ctx->ev_ctx,
1081 ndr_table_rpcecho.syntax_id,
1087 status = rpc_ep_setup_register(ep_ctx->ev_ctx,
1092 if (!NT_STATUS_IS_OK(status)) {
1100 static bool rpcecho_shutdown_cb(void *ptr)
1102 const char *rpcsrv_type;
1104 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
1109 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
1110 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
1113 status = _rpc_ep_unregister(&ndr_table_rpcecho);
1114 if (!NT_STATUS_IS_OK(status)) {
1123 static bool netdfs_init_cb(void *ptr)
1125 struct dcesrv_ep_context *ep_ctx =
1126 talloc_get_type_abort(ptr, struct dcesrv_ep_context);
1127 struct ndr_syntax_id abstract_syntax = ndr_table_netdfs.syntax_id;
1128 const char *pipe_name = "netdfs";
1129 const char *rpcsrv_type;
1132 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
1136 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
1137 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
1141 ok = setup_dcerpc_ncalrpc_socket(ep_ctx->ev_ctx,
1150 port = _open_sockets(ep_ctx->ev_ctx,
1158 status = rpc_ep_setup_register(ep_ctx->ev_ctx,
1163 if (!NT_STATUS_IS_OK(status)) {
1171 static bool netdfs_shutdown_cb(void *ptr) {
1172 const char *rpcsrv_type;
1174 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
1179 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
1180 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
1183 status = _rpc_ep_unregister(&ndr_table_netdfs);
1184 if (!NT_STATUS_IS_OK(status)) {
1192 static bool dssetup_init_cb(void *ptr)
1194 struct dcesrv_ep_context *ep_ctx =
1195 talloc_get_type_abort(ptr, struct dcesrv_ep_context);
1196 struct ndr_syntax_id abstract_syntax = ndr_table_dssetup.syntax_id;
1197 const char *pipe_name = "dssetup";
1198 const char *rpcsrv_type;
1201 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
1206 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
1207 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
1211 ok = setup_dcerpc_ncalrpc_socket(ep_ctx->ev_ctx,
1220 port = _open_sockets(ep_ctx->ev_ctx,
1228 status = rpc_ep_setup_register(ep_ctx->ev_ctx,
1233 if (!NT_STATUS_IS_OK(status)) {
1241 static bool dssetup_shutdown_cb(void *ptr) {
1242 const char *rpcsrv_type;
1244 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
1249 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
1250 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
1253 status = _rpc_ep_unregister(&ndr_table_dssetup);
1254 if (!NT_STATUS_IS_OK(status)) {
1262 static bool wkssvc_init_cb(void *ptr)
1264 struct dcesrv_ep_context *ep_ctx =
1265 talloc_get_type_abort(ptr, struct dcesrv_ep_context);
1266 struct ndr_syntax_id abstract_syntax = ndr_table_wkssvc.syntax_id;
1267 const char *pipe_name = "wkssvc";
1268 const char *rpcsrv_type;
1271 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
1275 if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
1276 StrCaseCmp(rpcsrv_type, "daemon") == 0) {
1280 ok = setup_dcerpc_ncalrpc_socket(ep_ctx->ev_ctx,
1289 port = _open_sockets(ep_ctx->ev_ctx,
1297 status = rpc_ep_setup_register(ep_ctx->ev_ctx,
1302 if (!NT_STATUS_IS_OK(status)) {
1310 static bool wkssvc_shutdown_cb(void *ptr) {
1311 return NT_STATUS_IS_OK(_rpc_ep_unregister(&ndr_table_wkssvc));
1314 bool dcesrv_ep_setup(struct tevent_context *ev_ctx,
1315 struct messaging_context *msg_ctx)
1317 struct dcesrv_ep_context *ep_ctx;
1319 struct rpc_srv_callbacks epmapper_cb;
1321 struct rpc_srv_callbacks winreg_cb;
1322 struct rpc_srv_callbacks srvsvc_cb;
1324 struct rpc_srv_callbacks lsarpc_cb;
1325 struct rpc_srv_callbacks samr_cb;
1326 struct rpc_srv_callbacks netlogon_cb;
1328 struct rpc_srv_callbacks spoolss_cb;
1329 struct rpc_srv_callbacks svcctl_cb;
1330 struct rpc_srv_callbacks ntsvcs_cb;
1331 struct rpc_srv_callbacks eventlog_cb;
1332 struct rpc_srv_callbacks initshutdown_cb;
1333 struct rpc_srv_callbacks netdfs_cb;
1335 struct rpc_srv_callbacks rpcecho_cb;
1337 struct rpc_srv_callbacks dssetup_cb;
1338 struct rpc_srv_callbacks wkssvc_cb;
1340 const char *rpcsrv_type;
1342 ep_ctx = talloc(ev_ctx, struct dcesrv_ep_context);
1343 if (ep_ctx == NULL) {
1347 ep_ctx->ev_ctx = ev_ctx;
1348 ep_ctx->msg_ctx = msg_ctx;
1350 /* start endpoint mapper only if enabled */
1351 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
1355 if (StrCaseCmp(rpcsrv_type, "embedded") == 0) {
1356 epmapper_cb.init = epmapper_init_cb;
1357 epmapper_cb.shutdown = epmapper_shutdown_cb;
1358 epmapper_cb.private_data = ep_ctx;
1360 if (!NT_STATUS_IS_OK(rpc_epmapper_init(&epmapper_cb))) {
1365 winreg_cb.init = winreg_init_cb;
1366 winreg_cb.shutdown = winreg_shutdown_cb;
1367 winreg_cb.private_data = ep_ctx;
1368 if (!NT_STATUS_IS_OK(rpc_winreg_init(&winreg_cb))) {
1372 srvsvc_cb.init = srvsvc_init_cb;
1373 srvsvc_cb.shutdown = srvsvc_shutdown_cb;
1374 srvsvc_cb.private_data = ep_ctx;
1375 if (!NT_STATUS_IS_OK(rpc_srvsvc_init(&srvsvc_cb))) {
1380 lsarpc_cb.init = lsarpc_init_cb;
1381 lsarpc_cb.shutdown = lsarpc_shutdown_cb;
1382 lsarpc_cb.private_data = ep_ctx;
1383 if (!NT_STATUS_IS_OK(rpc_lsarpc_init(&lsarpc_cb))) {
1387 samr_cb.init = samr_init_cb;
1388 samr_cb.shutdown = samr_shutdown_cb;
1389 samr_cb.private_data = ep_ctx;
1390 if (!NT_STATUS_IS_OK(rpc_samr_init(&samr_cb))) {
1394 netlogon_cb.init = netlogon_init_cb;
1395 netlogon_cb.shutdown = netlogon_shutdown_cb;
1396 netlogon_cb.private_data = ep_ctx;
1397 if (!NT_STATUS_IS_OK(rpc_netlogon_init(&netlogon_cb))) {
1401 spoolss_cb.init = spoolss_init_cb;
1402 spoolss_cb.shutdown = spoolss_shutdown_cb;
1403 spoolss_cb.private_data = ep_ctx;
1404 if (!NT_STATUS_IS_OK(rpc_spoolss_init(&spoolss_cb))) {
1409 svcctl_cb.init = svcctl_init_cb;
1410 svcctl_cb.shutdown = svcctl_shutdown_cb;
1411 svcctl_cb.private_data = ep_ctx;
1412 if (!NT_STATUS_IS_OK(rpc_svcctl_init(&svcctl_cb))) {
1416 ntsvcs_cb.init = ntsvcs_init_cb;
1417 ntsvcs_cb.shutdown = ntsvcs_shutdown_cb;
1418 ntsvcs_cb.private_data = ep_ctx;
1419 if (!NT_STATUS_IS_OK(rpc_ntsvcs_init(&ntsvcs_cb))) {
1423 eventlog_cb.init = eventlog_init_cb;
1424 eventlog_cb.shutdown = eventlog_shutdown_cb;
1425 eventlog_cb.private_data = ep_ctx;
1426 if (!NT_STATUS_IS_OK(rpc_eventlog_init(&eventlog_cb))) {
1430 initshutdown_cb.init = initshutdown_init_cb;
1431 initshutdown_cb.shutdown = initshutdown_shutdown_cb;
1432 initshutdown_cb.private_data = ep_ctx;
1433 if (!NT_STATUS_IS_OK(rpc_initshutdown_init(&initshutdown_cb))) {
1437 netdfs_cb.init = netdfs_init_cb;
1438 netdfs_cb.shutdown = netdfs_shutdown_cb;
1439 netdfs_cb.private_data = ep_ctx;
1440 if (!NT_STATUS_IS_OK(rpc_netdfs_init(&netdfs_cb))) {
1445 rpcecho_cb.init = rpcecho_init_cb;
1446 rpcecho_cb.shutdown = rpcecho_shutdown_cb;
1447 rpcecho_cb.private_data = ep_ctx;
1448 if (!NT_STATUS_IS_OK(rpc_rpcecho_init(&rpcecho_cb))) {
1453 dssetup_cb.init = dssetup_init_cb;
1454 dssetup_cb.shutdown = dssetup_shutdown_cb;
1455 dssetup_cb.private_data = ep_ctx;
1456 if (!NT_STATUS_IS_OK(rpc_dssetup_init(&dssetup_cb))) {
1460 wkssvc_cb.init = wkssvc_init_cb;
1461 wkssvc_cb.shutdown = wkssvc_shutdown_cb;
1462 wkssvc_cb.private_data = ep_ctx;
1463 if (!NT_STATUS_IS_OK(rpc_wkssvc_init(&wkssvc_cb))) {
1470 /* vim: set ts=8 sw=8 noet cindent ft=c.doxygen: */