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"
49 struct dcesrv_ep_context
{
50 struct tevent_context
*ev_ctx
;
51 struct messaging_context
*msg_ctx
;
54 static uint16_t _open_sockets(struct tevent_context
*ev_ctx
,
55 struct messaging_context
*msg_ctx
,
56 struct ndr_syntax_id syntax_id
,
59 uint32_t num_ifs
= iface_count();
63 if (lp_interfaces() && lp_bind_interfaces_only()) {
65 * We have been given an interfaces line, and been told to only
66 * bind to those interfaces. Create a socket per interface and
70 /* Now open a listen socket for each of the interfaces. */
71 for(i
= 0; i
< num_ifs
; i
++) {
72 const struct sockaddr_storage
*ifss
=
73 iface_n_sockaddr_storage(i
);
75 p
= setup_dcerpc_ncacn_tcpip_socket(ev_ctx
,
86 const char *sock_addr
= lp_socket_address();
90 if (strequal(sock_addr
, "0.0.0.0") ||
91 strequal(sock_addr
, "::")) {
95 sock_addr
= "0.0.0.0";
99 for (sock_ptr
= sock_addr
;
100 next_token_talloc(talloc_tos(), &sock_ptr
, &sock_tok
, " \t,");
102 struct sockaddr_storage ss
;
104 /* open an incoming socket */
105 if (!interpret_string_addr(&ss
,
107 AI_NUMERICHOST
|AI_PASSIVE
)) {
111 p
= setup_dcerpc_ncacn_tcpip_socket(ev_ctx
,
126 static NTSTATUS
_rpc_ep_unregister(const struct ndr_interface_table
*iface
)
128 struct dcerpc_binding_vector
*v
= NULL
;
131 status
= dcerpc_binding_vector_create(talloc_tos(),
136 if (!NT_STATUS_IS_OK(status
)) {
140 status
= dcerpc_ep_unregister(iface
,
142 &iface
->syntax_id
.uuid
);
143 if (!NT_STATUS_IS_OK(status
)) {
150 static void rpc_ep_setup_register_loop(struct tevent_req
*subreq
);
151 static NTSTATUS
rpc_ep_setup_try_register(struct tevent_context
*ev_ctx
,
152 struct messaging_context
*msg_ctx
,
153 const struct ndr_interface_table
*iface
,
157 struct rpc_ep_regsiter_state
{
160 struct tevent_context
*ev_ctx
;
161 struct messaging_context
*msg_ctx
;
163 const struct ndr_interface_table
*iface
;
169 static NTSTATUS
rpc_ep_setup_register(struct tevent_context
*ev_ctx
,
170 struct messaging_context
*msg_ctx
,
171 const struct ndr_interface_table
*iface
,
175 struct rpc_ep_regsiter_state
*state
;
176 struct tevent_req
*req
;
178 state
= talloc(ev_ctx
, struct rpc_ep_regsiter_state
);
180 return NT_STATUS_NO_MEMORY
;
183 state
->wait_time
= 1;
184 state
->ev_ctx
= ev_ctx
;
185 state
->msg_ctx
= msg_ctx
;
186 state
->iface
= iface
;
187 state
->ncalrpc
= talloc_strdup(state
, ncalrpc
);
190 req
= tevent_wakeup_send(state
, ev_ctx
, timeval_current_ofs(1, 0));
191 if (tevent_req_nomem(state
, req
)) {
193 return NT_STATUS_NO_MEMORY
;
196 tevent_req_set_callback(req
, rpc_ep_setup_register_loop
, state
);
201 static void rpc_ep_setup_register_loop(struct tevent_req
*req
)
203 struct rpc_ep_regsiter_state
*state
=
204 tevent_req_callback_data(req
, struct rpc_ep_regsiter_state
);
208 ok
= tevent_wakeup_recv(req
);
214 status
= rpc_ep_setup_try_register(state
->ev_ctx
,
219 if (NT_STATUS_IS_OK(status
)) {
224 state
->wait_time
= state
->wait_time
* 2;
225 if (state
->wait_time
> 16) {
230 req
= tevent_wakeup_send(state
,
232 timeval_current_ofs(state
->wait_time
, 0));
233 if (tevent_req_nomem(state
, req
)) {
238 tevent_req_set_callback(req
, rpc_ep_setup_register_loop
, state
);
242 static NTSTATUS
rpc_ep_setup_try_register(struct tevent_context
*ev_ctx
,
243 struct messaging_context
*msg_ctx
,
244 const struct ndr_interface_table
*iface
,
248 struct dcerpc_binding_vector
*v
= NULL
;
251 status
= dcerpc_binding_vector_create(talloc_tos(),
256 if (!NT_STATUS_IS_OK(status
)) {
260 status
= dcerpc_ep_register(iface
,
262 &iface
->syntax_id
.uuid
,
264 if (!NT_STATUS_IS_OK(status
)) {
271 static bool epmapper_init_cb(void *ptr
)
273 struct dcesrv_ep_context
*ep_ctx
=
274 talloc_get_type_abort(ptr
, struct dcesrv_ep_context
);
277 port
= _open_sockets(ep_ctx
->ev_ctx
,
279 ndr_table_epmapper
.syntax_id
,
288 static bool winreg_init_cb(void *ptr
)
290 struct dcesrv_ep_context
*ep_ctx
=
291 talloc_get_type_abort(ptr
, struct dcesrv_ep_context
);
292 struct ndr_syntax_id abstract_syntax
= ndr_table_winreg
.syntax_id
;
293 const char *pipe_name
= "winreg";
294 const char *rpcsrv_type
;
297 rpcsrv_type
= lp_parm_const_string(GLOBAL_SECTION_SNUM
,
302 if (StrCaseCmp(rpcsrv_type
, "embedded") == 0 ||
303 StrCaseCmp(rpcsrv_type
, "daemon") == 0) {
307 ok
= setup_dcerpc_ncalrpc_socket(ep_ctx
->ev_ctx
,
314 port
= _open_sockets(ep_ctx
->ev_ctx
,
322 status
= rpc_ep_setup_register(ep_ctx
->ev_ctx
,
327 if (!NT_STATUS_IS_OK(status
)) {
335 static bool winreg_shutdown_cb(void *ptr
)
337 const char *rpcsrv_type
;
339 rpcsrv_type
= lp_parm_const_string(GLOBAL_SECTION_SNUM
,
344 if (StrCaseCmp(rpcsrv_type
, "embedded") == 0 ||
345 StrCaseCmp(rpcsrv_type
, "daemon") == 0) {
348 status
= _rpc_ep_unregister(&ndr_table_winreg
);
349 if (!NT_STATUS_IS_OK(status
)) {
357 static bool srvsvc_init_cb(void *ptr
)
359 struct dcesrv_ep_context
*ep_ctx
=
360 talloc_get_type_abort(ptr
, struct dcesrv_ep_context
);
361 struct ndr_syntax_id abstract_syntax
= ndr_table_srvsvc
.syntax_id
;
362 const char *pipe_name
= "srvsvc";
363 const char *rpcsrv_type
;
366 rpcsrv_type
= lp_parm_const_string(GLOBAL_SECTION_SNUM
,
371 if (StrCaseCmp(rpcsrv_type
, "embedded") == 0 ||
372 StrCaseCmp(rpcsrv_type
, "daemon") == 0) {
376 ok
= setup_dcerpc_ncalrpc_socket(ep_ctx
->ev_ctx
,
384 port
= _open_sockets(ep_ctx
->ev_ctx
,
392 status
= rpc_ep_setup_register(ep_ctx
->ev_ctx
,
397 if (!NT_STATUS_IS_OK(status
)) {
405 static bool srvsvc_shutdown_cb(void *ptr
)
407 const char *rpcsrv_type
;
409 rpcsrv_type
= lp_parm_const_string(GLOBAL_SECTION_SNUM
,
414 if (StrCaseCmp(rpcsrv_type
, "embedded") == 0 ||
415 StrCaseCmp(rpcsrv_type
, "daemon") == 0) {
418 status
=_rpc_ep_unregister(&ndr_table_srvsvc
);
419 if (!NT_STATUS_IS_OK(status
)) {
427 static bool lsarpc_init_cb(void *ptr
)
429 struct dcesrv_ep_context
*ep_ctx
=
430 talloc_get_type_abort(ptr
, struct dcesrv_ep_context
);
431 struct ndr_syntax_id abstract_syntax
= ndr_table_lsarpc
.syntax_id
;
432 const char *pipe_name
= "lsarpc";
433 const char *rpcsrv_type
;
436 rpcsrv_type
= lp_parm_const_string(GLOBAL_SECTION_SNUM
,
441 if (StrCaseCmp(rpcsrv_type
, "embedded") == 0 ||
442 StrCaseCmp(rpcsrv_type
, "daemon") == 0) {
446 ok
= setup_dcerpc_ncalrpc_socket(ep_ctx
->ev_ctx
,
454 port
= _open_sockets(ep_ctx
->ev_ctx
,
462 status
= rpc_ep_setup_register(ep_ctx
->ev_ctx
,
467 if (!NT_STATUS_IS_OK(status
)) {
475 static bool lsarpc_shutdown_cb(void *ptr
)
477 const char *rpcsrv_type
;
479 rpcsrv_type
= lp_parm_const_string(GLOBAL_SECTION_SNUM
,
484 if (StrCaseCmp(rpcsrv_type
, "embedded") == 0 ||
485 StrCaseCmp(rpcsrv_type
, "daemon") == 0) {
488 status
= _rpc_ep_unregister(&ndr_table_lsarpc
);
489 if (!NT_STATUS_IS_OK(status
)) {
497 static bool samr_init_cb(void *ptr
)
499 struct dcesrv_ep_context
*ep_ctx
=
500 talloc_get_type_abort(ptr
, struct dcesrv_ep_context
);
501 struct ndr_syntax_id abstract_syntax
= ndr_table_samr
.syntax_id
;
502 const char *pipe_name
= "samr";
503 const char *rpcsrv_type
;
506 rpcsrv_type
= lp_parm_const_string(GLOBAL_SECTION_SNUM
,
511 if (StrCaseCmp(rpcsrv_type
, "embedded") == 0 ||
512 StrCaseCmp(rpcsrv_type
, "daemon") == 0) {
516 ok
= setup_dcerpc_ncalrpc_socket(ep_ctx
->ev_ctx
,
524 port
= _open_sockets(ep_ctx
->ev_ctx
,
532 status
= rpc_ep_setup_register(ep_ctx
->ev_ctx
,
537 if (!NT_STATUS_IS_OK(status
)) {
545 static bool samr_shutdown_cb(void *ptr
)
547 const char *rpcsrv_type
;
549 rpcsrv_type
= lp_parm_const_string(GLOBAL_SECTION_SNUM
,
554 if (StrCaseCmp(rpcsrv_type
, "embedded") == 0 ||
555 StrCaseCmp(rpcsrv_type
, "daemon") == 0) {
558 status
= _rpc_ep_unregister(&ndr_table_samr
);
559 if (!NT_STATUS_IS_OK(status
)) {
567 static bool netlogon_init_cb(void *ptr
)
569 struct dcesrv_ep_context
*ep_ctx
=
570 talloc_get_type_abort(ptr
, struct dcesrv_ep_context
);
571 struct ndr_syntax_id abstract_syntax
= ndr_table_netlogon
.syntax_id
;
572 const char *pipe_name
= "netlogon";
573 const char *rpcsrv_type
;
576 rpcsrv_type
= lp_parm_const_string(GLOBAL_SECTION_SNUM
,
581 if (StrCaseCmp(rpcsrv_type
, "embedded") == 0 ||
582 StrCaseCmp(rpcsrv_type
, "daemon") == 0) {
586 ok
= setup_dcerpc_ncalrpc_socket(ep_ctx
->ev_ctx
,
594 port
= _open_sockets(ep_ctx
->ev_ctx
,
602 status
= rpc_ep_setup_register(ep_ctx
->ev_ctx
,
607 if (!NT_STATUS_IS_OK(status
)) {
615 static bool netlogon_shutdown_cb(void *ptr
)
617 const char *rpcsrv_type
;
619 rpcsrv_type
= lp_parm_const_string(GLOBAL_SECTION_SNUM
,
624 if (StrCaseCmp(rpcsrv_type
, "embedded") == 0 ||
625 StrCaseCmp(rpcsrv_type
, "daemon") == 0) {
628 status
= _rpc_ep_unregister(&ndr_table_netlogon
);
629 if (!NT_STATUS_IS_OK(status
)) {
637 static bool spoolss_init_cb(void *ptr
)
639 struct dcesrv_ep_context
*ep_ctx
=
640 talloc_get_type_abort(ptr
, struct dcesrv_ep_context
);
641 const char *rpcsrv_type
;
644 rpcsrv_type
= lp_parm_const_string(GLOBAL_SECTION_SNUM
,
650 * Migrate the printers first.
652 ok
= nt_printing_tdb_migrate(ep_ctx
->msg_ctx
);
657 if (StrCaseCmp(rpcsrv_type
, "embedded") == 0 ||
658 StrCaseCmp(rpcsrv_type
, "daemon") == 0) {
661 status
=rpc_ep_setup_register(ep_ctx
->ev_ctx
,
666 if (!NT_STATUS_IS_OK(status
)) {
674 static bool spoolss_shutdown_cb(void *ptr
)
676 const char *rpcsrv_type
;
678 rpcsrv_type
= lp_parm_const_string(GLOBAL_SECTION_SNUM
,
683 srv_spoolss_cleanup();
685 if (StrCaseCmp(rpcsrv_type
, "embedded") == 0 ||
686 StrCaseCmp(rpcsrv_type
, "daemon") == 0) {
689 status
= _rpc_ep_unregister(&ndr_table_spoolss
);
690 if (!NT_STATUS_IS_OK(status
)) {
698 static bool svcctl_init_cb(void *ptr
)
700 struct dcesrv_ep_context
*ep_ctx
=
701 talloc_get_type_abort(ptr
, struct dcesrv_ep_context
);
702 const char *rpcsrv_type
;
705 rpcsrv_type
= lp_parm_const_string(GLOBAL_SECTION_SNUM
,
710 ok
= svcctl_init_winreg(ep_ctx
->msg_ctx
);
715 /* initialize the control hooks */
716 init_service_op_table();
718 if (StrCaseCmp(rpcsrv_type
, "embedded") == 0 ||
719 StrCaseCmp(rpcsrv_type
, "daemon") == 0) {
722 status
= rpc_ep_setup_register(ep_ctx
->ev_ctx
,
727 if (!NT_STATUS_IS_OK(status
)) {
735 static bool svcctl_shutdown_cb(void *ptr
)
737 const char *rpcsrv_type
;
739 rpcsrv_type
= lp_parm_const_string(GLOBAL_SECTION_SNUM
,
743 shutdown_service_op_table();
745 if (StrCaseCmp(rpcsrv_type
, "embedded") == 0 ||
746 StrCaseCmp(rpcsrv_type
, "daemon") == 0) {
749 status
= _rpc_ep_unregister(&ndr_table_svcctl
);
750 if (!NT_STATUS_IS_OK(status
)) {
758 static bool ntsvcs_init_cb(void *ptr
)
760 struct dcesrv_ep_context
*ep_ctx
=
761 talloc_get_type_abort(ptr
, struct dcesrv_ep_context
);
762 const char *rpcsrv_type
;
764 rpcsrv_type
= lp_parm_const_string(GLOBAL_SECTION_SNUM
,
769 if (StrCaseCmp(rpcsrv_type
, "embedded") == 0 ||
770 StrCaseCmp(rpcsrv_type
, "daemon") == 0) {
773 status
= rpc_ep_setup_register(ep_ctx
->ev_ctx
,
778 if (!NT_STATUS_IS_OK(status
)) {
786 static bool ntsvcs_shutdown_cb(void *ptr
)
788 const char *rpcsrv_type
;
790 rpcsrv_type
= lp_parm_const_string(GLOBAL_SECTION_SNUM
,
795 if (StrCaseCmp(rpcsrv_type
, "embedded") == 0 ||
796 StrCaseCmp(rpcsrv_type
, "daemon") == 0) {
799 status
= _rpc_ep_unregister(&ndr_table_ntsvcs
);
800 if (!NT_STATUS_IS_OK(status
)) {
808 static bool eventlog_init_cb(void *ptr
)
810 struct dcesrv_ep_context
*ep_ctx
=
811 talloc_get_type_abort(ptr
, struct dcesrv_ep_context
);
812 const char *rpcsrv_type
;
815 rpcsrv_type
= lp_parm_const_string(GLOBAL_SECTION_SNUM
,
820 ok
= eventlog_init_winreg(ep_ctx
->msg_ctx
);
825 if (StrCaseCmp(rpcsrv_type
, "embedded") == 0 ||
826 StrCaseCmp(rpcsrv_type
, "daemon") == 0) {
829 status
=rpc_ep_setup_register(ep_ctx
->ev_ctx
,
834 if (!NT_STATUS_IS_OK(status
)) {
842 static bool eventlog_shutdown_cb(void *ptr
)
844 const char *rpcsrv_type
;
846 rpcsrv_type
= lp_parm_const_string(GLOBAL_SECTION_SNUM
,
851 if (StrCaseCmp(rpcsrv_type
, "embedded") == 0 ||
852 StrCaseCmp(rpcsrv_type
, "daemon") == 0) {
855 status
= _rpc_ep_unregister(&ndr_table_eventlog
);
856 if (!NT_STATUS_IS_OK(status
)) {
864 static bool initshutdown_init_cb(void *ptr
)
866 struct dcesrv_ep_context
*ep_ctx
=
867 talloc_get_type_abort(ptr
, struct dcesrv_ep_context
);
868 const char *rpcsrv_type
;
870 rpcsrv_type
= lp_parm_const_string(GLOBAL_SECTION_SNUM
,
875 if (StrCaseCmp(rpcsrv_type
, "embedded") == 0 ||
876 StrCaseCmp(rpcsrv_type
, "daemon") == 0) {
879 status
= rpc_ep_setup_register(ep_ctx
->ev_ctx
,
881 &ndr_table_initshutdown
,
884 if (!NT_STATUS_IS_OK(status
)) {
892 static bool initshutdown_shutdown_cb(void *ptr
)
894 const char *rpcsrv_type
;
896 rpcsrv_type
= lp_parm_const_string(GLOBAL_SECTION_SNUM
,
901 if (StrCaseCmp(rpcsrv_type
, "embedded") == 0 ||
902 StrCaseCmp(rpcsrv_type
, "daemon") == 0) {
905 status
= _rpc_ep_unregister(&ndr_table_initshutdown
);
906 if (!NT_STATUS_IS_OK(status
)) {
915 static bool rpcecho_init_cb(void *ptr
) {
916 struct dcesrv_ep_context
*ep_ctx
=
917 talloc_get_type_abort(ptr
, struct dcesrv_ep_context
);
918 const char *rpcsrv_type
;
921 rpcsrv_type
= lp_parm_const_string(GLOBAL_SECTION_SNUM
,
926 if (StrCaseCmp(rpcsrv_type
, "embedded") == 0 ||
927 StrCaseCmp(rpcsrv_type
, "daemon") == 0) {
930 port
= _open_sockets(ep_ctx
->ev_ctx
,
932 ndr_table_rpcecho
.syntax_id
,
938 status
= rpc_ep_setup_register(ep_ctx
->ev_ctx
,
943 if (!NT_STATUS_IS_OK(status
)) {
951 static bool rpcecho_shutdown_cb(void *ptr
)
953 const char *rpcsrv_type
;
955 rpcsrv_type
= lp_parm_const_string(GLOBAL_SECTION_SNUM
,
960 if (StrCaseCmp(rpcsrv_type
, "embedded") == 0 ||
961 StrCaseCmp(rpcsrv_type
, "daemon") == 0) {
964 status
= _rpc_ep_unregister(&ndr_table_rpcecho
);
965 if (!NT_STATUS_IS_OK(status
)) {
974 static bool netdfs_init_cb(void *ptr
)
976 struct dcesrv_ep_context
*ep_ctx
=
977 talloc_get_type_abort(ptr
, struct dcesrv_ep_context
);
978 struct ndr_syntax_id abstract_syntax
= ndr_table_netdfs
.syntax_id
;
979 const char *pipe_name
= "netdfs";
980 const char *rpcsrv_type
;
983 rpcsrv_type
= lp_parm_const_string(GLOBAL_SECTION_SNUM
,
987 if (StrCaseCmp(rpcsrv_type
, "embedded") == 0 ||
988 StrCaseCmp(rpcsrv_type
, "daemon") == 0) {
992 ok
= setup_dcerpc_ncalrpc_socket(ep_ctx
->ev_ctx
,
1000 port
= _open_sockets(ep_ctx
->ev_ctx
,
1008 status
= rpc_ep_setup_register(ep_ctx
->ev_ctx
,
1013 if (!NT_STATUS_IS_OK(status
)) {
1021 static bool netdfs_shutdown_cb(void *ptr
) {
1022 const char *rpcsrv_type
;
1024 rpcsrv_type
= lp_parm_const_string(GLOBAL_SECTION_SNUM
,
1029 if (StrCaseCmp(rpcsrv_type
, "embedded") == 0 ||
1030 StrCaseCmp(rpcsrv_type
, "daemon") == 0) {
1033 status
= _rpc_ep_unregister(&ndr_table_netdfs
);
1034 if (!NT_STATUS_IS_OK(status
)) {
1042 static bool dssetup_init_cb(void *ptr
)
1044 struct dcesrv_ep_context
*ep_ctx
=
1045 talloc_get_type_abort(ptr
, struct dcesrv_ep_context
);
1046 struct ndr_syntax_id abstract_syntax
= ndr_table_dssetup
.syntax_id
;
1047 const char *pipe_name
= "dssetup";
1048 const char *rpcsrv_type
;
1051 rpcsrv_type
= lp_parm_const_string(GLOBAL_SECTION_SNUM
,
1056 if (StrCaseCmp(rpcsrv_type
, "embedded") == 0 ||
1057 StrCaseCmp(rpcsrv_type
, "daemon") == 0) {
1061 ok
= setup_dcerpc_ncalrpc_socket(ep_ctx
->ev_ctx
,
1069 port
= _open_sockets(ep_ctx
->ev_ctx
,
1077 status
= rpc_ep_setup_register(ep_ctx
->ev_ctx
,
1082 if (!NT_STATUS_IS_OK(status
)) {
1090 static bool dssetup_shutdown_cb(void *ptr
) {
1091 const char *rpcsrv_type
;
1093 rpcsrv_type
= lp_parm_const_string(GLOBAL_SECTION_SNUM
,
1098 if (StrCaseCmp(rpcsrv_type
, "embedded") == 0 ||
1099 StrCaseCmp(rpcsrv_type
, "daemon") == 0) {
1102 status
= _rpc_ep_unregister(&ndr_table_dssetup
);
1103 if (!NT_STATUS_IS_OK(status
)) {
1111 static bool wkssvc_init_cb(void *ptr
)
1113 struct dcesrv_ep_context
*ep_ctx
=
1114 talloc_get_type_abort(ptr
, struct dcesrv_ep_context
);
1115 struct ndr_syntax_id abstract_syntax
= ndr_table_wkssvc
.syntax_id
;
1116 const char *pipe_name
= "wkssvc";
1117 const char *rpcsrv_type
;
1120 rpcsrv_type
= lp_parm_const_string(GLOBAL_SECTION_SNUM
,
1124 if (StrCaseCmp(rpcsrv_type
, "embedded") == 0 ||
1125 StrCaseCmp(rpcsrv_type
, "daemon") == 0) {
1129 ok
= setup_dcerpc_ncalrpc_socket(ep_ctx
->ev_ctx
,
1137 port
= _open_sockets(ep_ctx
->ev_ctx
,
1145 status
= rpc_ep_setup_register(ep_ctx
->ev_ctx
,
1150 if (!NT_STATUS_IS_OK(status
)) {
1158 static bool wkssvc_shutdown_cb(void *ptr
) {
1159 return NT_STATUS_IS_OK(_rpc_ep_unregister(&ndr_table_wkssvc
));
1162 bool dcesrv_ep_setup(struct tevent_context
*ev_ctx
,
1163 struct messaging_context
*msg_ctx
)
1165 struct dcesrv_ep_context
*ep_ctx
;
1167 struct rpc_srv_callbacks epmapper_cb
;
1169 struct rpc_srv_callbacks winreg_cb
;
1170 struct rpc_srv_callbacks srvsvc_cb
;
1172 struct rpc_srv_callbacks lsarpc_cb
;
1173 struct rpc_srv_callbacks samr_cb
;
1174 struct rpc_srv_callbacks netlogon_cb
;
1176 struct rpc_srv_callbacks spoolss_cb
;
1177 struct rpc_srv_callbacks svcctl_cb
;
1178 struct rpc_srv_callbacks ntsvcs_cb
;
1179 struct rpc_srv_callbacks eventlog_cb
;
1180 struct rpc_srv_callbacks initshutdown_cb
;
1181 struct rpc_srv_callbacks netdfs_cb
;
1183 struct rpc_srv_callbacks rpcecho_cb
;
1185 struct rpc_srv_callbacks dssetup_cb
;
1186 struct rpc_srv_callbacks wkssvc_cb
;
1188 const char *rpcsrv_type
;
1190 ep_ctx
= talloc(ev_ctx
, struct dcesrv_ep_context
);
1191 if (ep_ctx
== NULL
) {
1195 ep_ctx
->ev_ctx
= ev_ctx
;
1196 ep_ctx
->msg_ctx
= msg_ctx
;
1198 /* start endpoint mapper only if enabled */
1199 rpcsrv_type
= lp_parm_const_string(GLOBAL_SECTION_SNUM
,
1203 if (StrCaseCmp(rpcsrv_type
, "embedded") == 0) {
1204 epmapper_cb
.init
= epmapper_init_cb
;
1205 epmapper_cb
.shutdown
= NULL
;
1206 epmapper_cb
.private_data
= ep_ctx
;
1208 if (!NT_STATUS_IS_OK(rpc_epmapper_init(&epmapper_cb
))) {
1213 winreg_cb
.init
= winreg_init_cb
;
1214 winreg_cb
.shutdown
= winreg_shutdown_cb
;
1215 winreg_cb
.private_data
= ep_ctx
;
1216 if (!NT_STATUS_IS_OK(rpc_winreg_init(&winreg_cb
))) {
1220 srvsvc_cb
.init
= srvsvc_init_cb
;
1221 srvsvc_cb
.shutdown
= srvsvc_shutdown_cb
;
1222 srvsvc_cb
.private_data
= ep_ctx
;
1223 if (!NT_STATUS_IS_OK(rpc_srvsvc_init(&srvsvc_cb
))) {
1228 lsarpc_cb
.init
= lsarpc_init_cb
;
1229 lsarpc_cb
.shutdown
= lsarpc_shutdown_cb
;
1230 lsarpc_cb
.private_data
= ep_ctx
;
1231 if (!NT_STATUS_IS_OK(rpc_lsarpc_init(&lsarpc_cb
))) {
1235 samr_cb
.init
= samr_init_cb
;
1236 samr_cb
.shutdown
= samr_shutdown_cb
;
1237 samr_cb
.private_data
= ep_ctx
;
1238 if (!NT_STATUS_IS_OK(rpc_samr_init(&samr_cb
))) {
1242 netlogon_cb
.init
= netlogon_init_cb
;
1243 netlogon_cb
.shutdown
= netlogon_shutdown_cb
;
1244 netlogon_cb
.private_data
= ep_ctx
;
1245 if (!NT_STATUS_IS_OK(rpc_netlogon_init(&netlogon_cb
))) {
1249 spoolss_cb
.init
= spoolss_init_cb
;
1250 spoolss_cb
.shutdown
= spoolss_shutdown_cb
;
1251 spoolss_cb
.private_data
= ep_ctx
;
1252 if (!NT_STATUS_IS_OK(rpc_spoolss_init(&spoolss_cb
))) {
1257 svcctl_cb
.init
= svcctl_init_cb
;
1258 svcctl_cb
.shutdown
= svcctl_shutdown_cb
;
1259 svcctl_cb
.private_data
= ep_ctx
;
1260 if (!NT_STATUS_IS_OK(rpc_svcctl_init(&svcctl_cb
))) {
1264 ntsvcs_cb
.init
= ntsvcs_init_cb
;
1265 ntsvcs_cb
.shutdown
= ntsvcs_shutdown_cb
;
1266 ntsvcs_cb
.private_data
= ep_ctx
;
1267 if (!NT_STATUS_IS_OK(rpc_ntsvcs_init(&ntsvcs_cb
))) {
1271 eventlog_cb
.init
= eventlog_init_cb
;
1272 eventlog_cb
.shutdown
= eventlog_shutdown_cb
;
1273 eventlog_cb
.private_data
= ep_ctx
;
1274 if (!NT_STATUS_IS_OK(rpc_eventlog_init(&eventlog_cb
))) {
1278 initshutdown_cb
.init
= initshutdown_init_cb
;
1279 initshutdown_cb
.shutdown
= initshutdown_shutdown_cb
;
1280 initshutdown_cb
.private_data
= ep_ctx
;
1281 if (!NT_STATUS_IS_OK(rpc_initshutdown_init(&initshutdown_cb
))) {
1285 netdfs_cb
.init
= netdfs_init_cb
;
1286 netdfs_cb
.shutdown
= netdfs_shutdown_cb
;
1287 netdfs_cb
.private_data
= ep_ctx
;
1288 if (!NT_STATUS_IS_OK(rpc_netdfs_init(&netdfs_cb
))) {
1293 rpcecho_cb
.init
= rpcecho_init_cb
;
1294 rpcecho_cb
.shutdown
= rpcecho_shutdown_cb
;
1295 rpcecho_cb
.private_data
= ep_ctx
;
1296 if (!NT_STATUS_IS_OK(rpc_rpcecho_init(&rpcecho_cb
))) {
1301 dssetup_cb
.init
= dssetup_init_cb
;
1302 dssetup_cb
.shutdown
= dssetup_shutdown_cb
;
1303 dssetup_cb
.private_data
= ep_ctx
;
1304 if (!NT_STATUS_IS_OK(rpc_dssetup_init(&dssetup_cb
))) {
1308 wkssvc_cb
.init
= wkssvc_init_cb
;
1309 wkssvc_cb
.shutdown
= wkssvc_shutdown_cb
;
1310 wkssvc_cb
.private_data
= ep_ctx
;
1311 if (!NT_STATUS_IS_OK(rpc_wkssvc_init(&wkssvc_cb
))) {
1318 /* vim: set ts=8 sw=8 noet cindent ft=c.doxygen: */