s3-rpc_server: Disable listening on tcpip ports by default.
[Samba/gebeck_regimport.git] / source3 / rpc_server / rpc_service_setup.c
bloba9633fb35522411f6e78cf23f837bc0abcb653aa
1 /*
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/>.
22 #include "includes.h"
23 #include "ntdomain.h"
25 #include "../librpc/gen_ndr/ndr_epmapper_c.h"
26 #include "../librpc/gen_ndr/srv_epmapper.h"
27 #include "../librpc/gen_ndr/srv_srvsvc.h"
28 #include "../librpc/gen_ndr/srv_winreg.h"
29 #include "../librpc/gen_ndr/srv_dfs.h"
30 #include "../librpc/gen_ndr/srv_dssetup.h"
31 #include "../librpc/gen_ndr/srv_echo.h"
32 #include "../librpc/gen_ndr/srv_eventlog.h"
33 #include "../librpc/gen_ndr/srv_initshutdown.h"
34 #include "../librpc/gen_ndr/srv_lsa.h"
35 #include "../librpc/gen_ndr/srv_netlogon.h"
36 #include "../librpc/gen_ndr/srv_ntsvcs.h"
37 #include "../librpc/gen_ndr/srv_samr.h"
38 #include "../librpc/gen_ndr/srv_spoolss.h"
39 #include "../librpc/gen_ndr/srv_svcctl.h"
40 #include "../librpc/gen_ndr/srv_wkssvc.h"
42 #include "printing/nt_printing_migrate_internal.h"
43 #include "rpc_server/eventlog/srv_eventlog_reg.h"
44 #include "rpc_server/svcctl/srv_svcctl_reg.h"
45 #include "rpc_server/spoolss/srv_spoolss_nt.h"
46 #include "rpc_server/svcctl/srv_svcctl_nt.h"
48 #include "librpc/rpc/dcerpc_ep.h"
49 #include "rpc_server/rpc_sock_helper.h"
50 #include "rpc_server/rpc_service_setup.h"
51 #include "rpc_server/rpc_ep_register.h"
52 #include "rpc_server/rpc_server.h"
53 #include "rpc_server/epmapper/srv_epmapper.h"
55 static bool rpc_setup_epmapper(struct tevent_context *ev_ctx,
56 struct messaging_context *msg_ctx)
58 const char *rpcsrv_type;
59 NTSTATUS status;
61 /* start endpoint mapper only if enabled */
62 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
63 "rpc_server",
64 "epmapper",
65 "none");
67 if (strcasecmp_m(rpcsrv_type, "none") == 0) {
68 status = rpc_epmapper_init(NULL);
69 if (!NT_STATUS_IS_OK(rpc_epmapper_init(NULL))) {
70 return false;
74 if (strcasecmp_m(rpcsrv_type, "embedded") == 0) {
75 status = rpc_setup_tcpip_sockets(ev_ctx,
76 msg_ctx,
77 &ndr_table_epmapper,
78 NULL,
79 135);
80 if (!NT_STATUS_IS_OK(status)) {
81 return false;
85 return true;
88 static bool rpc_setup_winreg(struct tevent_context *ev_ctx,
89 struct messaging_context *msg_ctx,
90 const struct dcerpc_binding_vector *v)
92 const struct ndr_interface_table *t = &ndr_table_winreg;
93 const char *pipe_name = "winreg";
94 struct dcerpc_binding_vector *v2;
95 const char *rpcsrv_type;
96 NTSTATUS status;
97 bool ok;
99 status = rpc_winreg_init(NULL);
100 if (!NT_STATUS_IS_OK(status)) {
101 return false;
104 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
105 "rpc_server",
106 "epmapper",
107 "none");
109 if (strcasecmp_m(rpcsrv_type, "embedded") == 0 ||
110 strcasecmp_m(rpcsrv_type, "daemon") == 0) {
111 v2 = dcerpc_binding_vector_dup(talloc_tos(), v);
112 if (v2 == NULL) {
113 return false;
116 status = dcerpc_binding_vector_replace_iface(t, v2);
117 if (!NT_STATUS_IS_OK(status)) {
118 return false;
121 status = dcerpc_binding_vector_add_np_default(t, v2);
122 if (!NT_STATUS_IS_OK(status)) {
123 return false;
126 ok = setup_dcerpc_ncalrpc_socket(ev_ctx,
127 msg_ctx,
128 pipe_name,
129 NULL);
130 if (!ok) {
131 return false;
134 status = dcerpc_binding_vector_add_unix(t, v2, pipe_name);
135 if (!NT_STATUS_IS_OK(status)) {
136 return false;
139 status = rpc_ep_register(ev_ctx,
140 msg_ctx,
142 v2);
143 if (!NT_STATUS_IS_OK(status)) {
144 return false;
148 return true;
151 static bool rpc_setup_srvsvc(struct tevent_context *ev_ctx,
152 struct messaging_context *msg_ctx,
153 const struct dcerpc_binding_vector *v)
155 const struct ndr_interface_table *t = &ndr_table_srvsvc;
156 const char *pipe_name = "srvsvc";
157 struct dcerpc_binding_vector *v2;
158 const char *rpcsrv_type;
159 NTSTATUS status;
160 bool ok;
162 status = rpc_srvsvc_init(NULL);
163 if (!NT_STATUS_IS_OK(status)) {
164 return false;
167 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
168 "rpc_server",
169 "epmapper",
170 "none");
172 if (strcasecmp_m(rpcsrv_type, "embedded") == 0 ||
173 strcasecmp_m(rpcsrv_type, "daemon") == 0) {
174 v2 = dcerpc_binding_vector_dup(talloc_tos(), v);
175 if (v2 == NULL) {
176 return false;
179 status = dcerpc_binding_vector_replace_iface(t, v2);
180 if (!NT_STATUS_IS_OK(status)) {
181 return false;
184 status = dcerpc_binding_vector_add_np_default(t, v2);
185 if (!NT_STATUS_IS_OK(status)) {
186 return false;
189 ok = setup_dcerpc_ncalrpc_socket(ev_ctx,
190 msg_ctx,
191 pipe_name,
192 NULL);
193 if (!ok) {
194 return false;
197 status = dcerpc_binding_vector_add_unix(t, v2, pipe_name);
198 if (!NT_STATUS_IS_OK(status)) {
199 return false;
202 status = rpc_ep_register(ev_ctx,
203 msg_ctx,
205 v2);
206 if (!NT_STATUS_IS_OK(status)) {
207 return false;
211 return true;
214 static bool rpc_setup_lsarpc(struct tevent_context *ev_ctx,
215 struct messaging_context *msg_ctx,
216 const struct dcerpc_binding_vector *v)
218 const struct ndr_interface_table *t = &ndr_table_lsarpc;
219 const char *pipe_name = "lsarpc";
220 struct dcerpc_binding_vector *v2;
221 const char *rpcsrv_type;
222 NTSTATUS status;
223 bool ok;
225 status = rpc_lsarpc_init(NULL);
226 if (!NT_STATUS_IS_OK(status)) {
227 return false;
230 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
231 "rpc_server",
232 "epmapper",
233 "none");
235 if (strcasecmp_m(rpcsrv_type, "embedded") == 0 ||
236 strcasecmp_m(rpcsrv_type, "daemon") == 0) {
237 v2 = dcerpc_binding_vector_dup(talloc_tos(), v);
238 if (v2 == NULL) {
239 return false;
242 status = dcerpc_binding_vector_replace_iface(t, v2);
243 if (!NT_STATUS_IS_OK(status)) {
244 return false;
247 status = dcerpc_binding_vector_add_np_default(t, v2);
248 if (!NT_STATUS_IS_OK(status)) {
249 return false;
252 ok = setup_dcerpc_ncalrpc_socket(ev_ctx,
253 msg_ctx,
254 pipe_name,
255 NULL);
256 if (!ok) {
257 return false;
260 status = dcerpc_binding_vector_add_unix(t, v2, pipe_name);
261 if (!NT_STATUS_IS_OK(status)) {
262 return false;
265 status = rpc_ep_register(ev_ctx,
266 msg_ctx,
268 v2);
269 if (!NT_STATUS_IS_OK(status)) {
270 return false;
274 return true;
277 static bool rpc_setup_samr(struct tevent_context *ev_ctx,
278 struct messaging_context *msg_ctx,
279 const struct dcerpc_binding_vector *v)
281 const struct ndr_interface_table *t = &ndr_table_samr;
282 const char *pipe_name = "samr";
283 struct dcerpc_binding_vector *v2;
284 const char *rpcsrv_type;
285 NTSTATUS status;
286 bool ok;
288 status = rpc_samr_init(NULL);
289 if (!NT_STATUS_IS_OK(status)) {
290 return false;
293 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
294 "rpc_server",
295 "epmapper",
296 "none");
298 if (strcasecmp_m(rpcsrv_type, "embedded") == 0 ||
299 strcasecmp_m(rpcsrv_type, "daemon") == 0) {
300 v2 = dcerpc_binding_vector_dup(talloc_tos(), v);
301 if (v2 == NULL) {
302 return false;
305 status = dcerpc_binding_vector_replace_iface(t, v2);
306 if (!NT_STATUS_IS_OK(status)) {
307 return false;
310 status = dcerpc_binding_vector_add_np_default(t, v2);
311 if (!NT_STATUS_IS_OK(status)) {
312 return false;
315 ok = setup_dcerpc_ncalrpc_socket(ev_ctx,
316 msg_ctx,
317 pipe_name,
318 NULL);
319 if (!ok) {
320 return false;
323 status = dcerpc_binding_vector_add_unix(t, v2, pipe_name);
324 if (!NT_STATUS_IS_OK(status)) {
325 return false;
328 status = rpc_ep_register(ev_ctx,
329 msg_ctx,
331 v2);
332 if (!NT_STATUS_IS_OK(status)) {
333 return false;
337 return true;
340 static bool rpc_setup_netlogon(struct tevent_context *ev_ctx,
341 struct messaging_context *msg_ctx,
342 const struct dcerpc_binding_vector *v)
344 const struct ndr_interface_table *t = &ndr_table_netlogon;
345 const char *pipe_name = "netlogon";
346 struct dcerpc_binding_vector *v2;
347 const char *rpcsrv_type;
348 NTSTATUS status;
349 bool ok;
351 status = rpc_netlogon_init(NULL);
352 if (!NT_STATUS_IS_OK(status)) {
353 return false;
356 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
357 "rpc_server",
358 "epmapper",
359 "none");
361 if (strcasecmp_m(rpcsrv_type, "embedded") == 0 ||
362 strcasecmp_m(rpcsrv_type, "daemon") == 0) {
363 v2 = dcerpc_binding_vector_dup(talloc_tos(), v);
364 if (v2 == NULL) {
365 return false;
368 status = dcerpc_binding_vector_replace_iface(t, v2);
369 if (!NT_STATUS_IS_OK(status)) {
370 return false;
373 status = dcerpc_binding_vector_add_np_default(t, v2);
374 if (!NT_STATUS_IS_OK(status)) {
375 return false;
378 ok = setup_dcerpc_ncalrpc_socket(ev_ctx,
379 msg_ctx,
380 pipe_name,
381 NULL);
382 if (!ok) {
383 return false;
386 status = dcerpc_binding_vector_add_unix(t, v2, pipe_name);
387 if (!NT_STATUS_IS_OK(status)) {
388 return false;
391 status = rpc_ep_register(ev_ctx,
392 msg_ctx,
394 v2);
395 if (!NT_STATUS_IS_OK(status)) {
396 return false;
400 return true;
403 static bool rpc_setup_netdfs(struct tevent_context *ev_ctx,
404 struct messaging_context *msg_ctx,
405 const struct dcerpc_binding_vector *v)
407 const struct ndr_interface_table *t = &ndr_table_netdfs;
408 const char *pipe_name = "netdfs";
409 struct dcerpc_binding_vector *v2;
410 const char *rpcsrv_type;
411 NTSTATUS status;
412 bool ok;
414 status = rpc_netdfs_init(NULL);
415 if (!NT_STATUS_IS_OK(status)) {
416 return false;
419 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
420 "rpc_server",
421 "epmapper",
422 "none");
424 if (strcasecmp_m(rpcsrv_type, "embedded") == 0 ||
425 strcasecmp_m(rpcsrv_type, "daemon") == 0) {
426 v2 = dcerpc_binding_vector_dup(talloc_tos(), v);
427 if (v2 == NULL) {
428 return false;
431 status = dcerpc_binding_vector_replace_iface(t, v2);
432 if (!NT_STATUS_IS_OK(status)) {
433 return false;
436 status = dcerpc_binding_vector_add_np_default(t, v2);
437 if (!NT_STATUS_IS_OK(status)) {
438 return false;
441 ok = setup_dcerpc_ncalrpc_socket(ev_ctx,
442 msg_ctx,
443 pipe_name,
444 NULL);
445 if (!ok) {
446 return false;
449 status = dcerpc_binding_vector_add_unix(t, v2, pipe_name);
450 if (!NT_STATUS_IS_OK(status)) {
451 return false;
454 status = rpc_ep_register(ev_ctx,
455 msg_ctx,
457 v2);
458 if (!NT_STATUS_IS_OK(status)) {
459 return false;
463 return true;
466 #ifdef DEVELOPER
467 static bool rpc_setup_rpcecho(struct tevent_context *ev_ctx,
468 struct messaging_context *msg_ctx,
469 const struct dcerpc_binding_vector *v)
471 const struct ndr_interface_table *t = &ndr_table_rpcecho;
472 const char *pipe_name = "rpcecho";
473 struct dcerpc_binding_vector *v2;
474 const char *rpcsrv_type;
475 NTSTATUS status;
476 bool ok;
478 status = rpc_rpcecho_init(NULL);
479 if (!NT_STATUS_IS_OK(status)) {
480 return false;
483 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
484 "rpc_server",
485 "epmapper",
486 "none");
488 if (strcasecmp_m(rpcsrv_type, "embedded") == 0 ||
489 strcasecmp_m(rpcsrv_type, "daemon") == 0) {
490 v2 = dcerpc_binding_vector_dup(talloc_tos(), v);
491 if (v2 == NULL) {
492 return false;
495 status = dcerpc_binding_vector_replace_iface(t, v2);
496 if (!NT_STATUS_IS_OK(status)) {
497 return false;
500 status = dcerpc_binding_vector_add_np_default(t, v2);
501 if (!NT_STATUS_IS_OK(status)) {
502 return false;
505 ok = setup_dcerpc_ncalrpc_socket(ev_ctx,
506 msg_ctx,
507 pipe_name,
508 NULL);
509 if (!ok) {
510 return false;
513 status = dcerpc_binding_vector_add_unix(t, v2, pipe_name);
514 if (!NT_STATUS_IS_OK(status)) {
515 return false;
518 status = rpc_ep_register(ev_ctx,
519 msg_ctx,
521 v2);
522 if (!NT_STATUS_IS_OK(status)) {
523 return false;
527 return true;
529 #endif
531 static bool rpc_setup_dssetup(struct tevent_context *ev_ctx,
532 struct messaging_context *msg_ctx,
533 const struct dcerpc_binding_vector *v)
535 const struct ndr_interface_table *t = &ndr_table_dssetup;
536 const char *pipe_name = "dssetup";
537 struct dcerpc_binding_vector *v2;
538 const char *rpcsrv_type;
539 NTSTATUS status;
540 bool ok;
542 status = rpc_dssetup_init(NULL);
543 if (!NT_STATUS_IS_OK(status)) {
544 return false;
547 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
548 "rpc_server",
549 "epmapper",
550 "none");
552 if (strcasecmp_m(rpcsrv_type, "embedded") == 0 ||
553 strcasecmp_m(rpcsrv_type, "daemon") == 0) {
554 v2 = dcerpc_binding_vector_dup(talloc_tos(), v);
555 if (v2 == NULL) {
556 return false;
559 status = dcerpc_binding_vector_replace_iface(t, v2);
560 if (!NT_STATUS_IS_OK(status)) {
561 return false;
564 status = dcerpc_binding_vector_add_np_default(t, v2);
565 if (!NT_STATUS_IS_OK(status)) {
566 return false;
569 ok = setup_dcerpc_ncalrpc_socket(ev_ctx,
570 msg_ctx,
571 pipe_name,
572 NULL);
573 if (!ok) {
574 return false;
577 status = dcerpc_binding_vector_add_unix(t, v2, pipe_name);
578 if (!NT_STATUS_IS_OK(status)) {
579 return false;
582 status = rpc_ep_register(ev_ctx,
583 msg_ctx,
585 v2);
586 if (!NT_STATUS_IS_OK(status)) {
587 return false;
591 return true;
594 static bool rpc_setup_wkssvc(struct tevent_context *ev_ctx,
595 struct messaging_context *msg_ctx,
596 const struct dcerpc_binding_vector *v)
598 const struct ndr_interface_table *t = &ndr_table_wkssvc;
599 const char *pipe_name = "wkssvc";
600 struct dcerpc_binding_vector *v2;
601 const char *rpcsrv_type;
602 NTSTATUS status;
603 bool ok;
605 status = rpc_wkssvc_init(NULL);
606 if (!NT_STATUS_IS_OK(status)) {
607 return false;
610 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
611 "rpc_server",
612 "epmapper",
613 "none");
615 if (strcasecmp_m(rpcsrv_type, "embedded") == 0 ||
616 strcasecmp_m(rpcsrv_type, "daemon") == 0) {
617 v2 = dcerpc_binding_vector_dup(talloc_tos(), v);
618 if (v2 == NULL) {
619 return false;
622 status = dcerpc_binding_vector_replace_iface(t, v2);
623 if (!NT_STATUS_IS_OK(status)) {
624 return false;
627 status = dcerpc_binding_vector_add_np_default(t, v2);
628 if (!NT_STATUS_IS_OK(status)) {
629 return false;
632 ok = setup_dcerpc_ncalrpc_socket(ev_ctx,
633 msg_ctx,
634 pipe_name,
635 NULL);
636 if (!ok) {
637 return false;
640 status = dcerpc_binding_vector_add_unix(t, v2, pipe_name);
641 if (!NT_STATUS_IS_OK(status)) {
642 return false;
645 status = rpc_ep_register(ev_ctx,
646 msg_ctx,
648 v2);
649 if (!NT_STATUS_IS_OK(status)) {
650 return false;
654 return true;
657 static bool spoolss_init_cb(void *ptr)
659 struct messaging_context *msg_ctx =
660 talloc_get_type_abort(ptr, struct messaging_context);
661 bool ok;
664 * Migrate the printers first.
666 ok = nt_printing_tdb_migrate(msg_ctx);
667 if (!ok) {
668 return false;
671 return true;
674 static bool spoolss_shutdown_cb(void *ptr)
676 srv_spoolss_cleanup();
678 return true;
681 static bool rpc_setup_spoolss(struct tevent_context *ev_ctx,
682 struct messaging_context *msg_ctx)
684 const struct ndr_interface_table *t = &ndr_table_spoolss;
685 struct rpc_srv_callbacks spoolss_cb;
686 const char *rpcsrv_type;
687 struct dcerpc_binding_vector *v;
688 NTSTATUS status;
690 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
691 "rpc_server",
692 "spoolss",
693 "embedded");
695 if (strcasecmp_m(rpcsrv_type, "embedded") == 0) {
696 spoolss_cb.init = spoolss_init_cb;
697 spoolss_cb.shutdown = spoolss_shutdown_cb;
698 spoolss_cb.private_data = msg_ctx;
700 status = rpc_spoolss_init(&spoolss_cb);
701 } else if (strcasecmp_m(rpcsrv_type, "daemon") == 0 ||
702 strcasecmp_m(rpcsrv_type, "external") == 0) {
703 status = rpc_spoolss_init(NULL);
705 if (!NT_STATUS_IS_OK(status)) {
706 return false;
709 if (strcasecmp_m(rpcsrv_type, "embedded")) {
710 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
711 "rpc_server",
712 "epmapper",
713 "none");
715 if (strcasecmp_m(rpcsrv_type, "embedded") == 0 ||
716 strcasecmp_m(rpcsrv_type, "daemon") == 0) {
717 status = dcerpc_binding_vector_new(talloc_tos(), &v);
718 if (!NT_STATUS_IS_OK(status)) {
719 return false;
722 status = dcerpc_binding_vector_add_np_default(t, v);
723 if (!NT_STATUS_IS_OK(status)) {
724 return false;
727 status = rpc_ep_register(ev_ctx,
728 msg_ctx,
731 if (!NT_STATUS_IS_OK(status)) {
732 return false;
737 return true;
740 static bool svcctl_init_cb(void *ptr)
742 struct messaging_context *msg_ctx =
743 talloc_get_type_abort(ptr, struct messaging_context);
744 bool ok;
746 /* initialize the control hooks */
747 init_service_op_table();
749 ok = svcctl_init_winreg(msg_ctx);
750 if (!ok) {
751 return false;
754 return true;
757 static bool svcctl_shutdown_cb(void *ptr)
759 shutdown_service_op_table();
761 return true;
764 static bool rpc_setup_svcctl(struct tevent_context *ev_ctx,
765 struct messaging_context *msg_ctx)
767 const struct ndr_interface_table *t = &ndr_table_svcctl;
768 const char *pipe_name = "svcctl";
769 struct dcerpc_binding_vector *v;
770 struct rpc_srv_callbacks svcctl_cb;
771 const char *rpcsrv_type;
772 NTSTATUS status;
773 bool ok;
775 svcctl_cb.init = svcctl_init_cb;
776 svcctl_cb.shutdown = svcctl_shutdown_cb;
777 svcctl_cb.private_data = msg_ctx;
779 status = rpc_svcctl_init(&svcctl_cb);
780 if (!NT_STATUS_IS_OK(status)) {
781 return false;
784 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
785 "rpc_server",
786 "epmapper",
787 "none");
789 if (strcasecmp_m(rpcsrv_type, "embedded") == 0 ||
790 strcasecmp_m(rpcsrv_type, "daemon") == 0) {
791 status = dcerpc_binding_vector_new(talloc_tos(), &v);
792 if (!NT_STATUS_IS_OK(status)) {
793 return false;
796 status = dcerpc_binding_vector_add_np_default(t, v);
797 if (!NT_STATUS_IS_OK(status)) {
798 return false;
801 ok = setup_dcerpc_ncalrpc_socket(ev_ctx,
802 msg_ctx,
803 pipe_name,
804 NULL);
805 if (!ok) {
806 return false;
809 status = dcerpc_binding_vector_add_unix(t, v, pipe_name);
810 if (!NT_STATUS_IS_OK(status)) {
811 return false;
814 status = rpc_ep_register(ev_ctx,
815 msg_ctx,
818 if (!NT_STATUS_IS_OK(status)) {
819 return false;
823 return true;
826 static bool rpc_setup_ntsvcs(struct tevent_context *ev_ctx,
827 struct messaging_context *msg_ctx)
829 const struct ndr_interface_table *t = &ndr_table_ntsvcs;
830 struct dcerpc_binding_vector *v;
831 const char *rpcsrv_type;
832 NTSTATUS status;
834 status = rpc_ntsvcs_init(NULL);
835 if (!NT_STATUS_IS_OK(status)) {
836 return false;
839 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
840 "rpc_server",
841 "epmapper",
842 "none");
844 if (strcasecmp_m(rpcsrv_type, "embedded") == 0 ||
845 strcasecmp_m(rpcsrv_type, "daemon") == 0) {
846 status = dcerpc_binding_vector_new(talloc_tos(), &v);
847 if (!NT_STATUS_IS_OK(status)) {
848 return false;
851 status = dcerpc_binding_vector_add_np_default(t, v);
852 if (!NT_STATUS_IS_OK(status)) {
853 return false;
856 status = rpc_ep_register(ev_ctx,
857 msg_ctx,
860 if (!NT_STATUS_IS_OK(status)) {
861 return false;
865 return true;
868 static bool eventlog_init_cb(void *ptr)
870 struct messaging_context *msg_ctx =
871 talloc_get_type_abort(ptr, struct messaging_context);
872 bool ok;
874 ok = eventlog_init_winreg(msg_ctx);
875 if (!ok) {
876 return false;
879 return true;
882 static bool rpc_setup_eventlog(struct tevent_context *ev_ctx,
883 struct messaging_context *msg_ctx)
885 const struct ndr_interface_table *t = &ndr_table_eventlog;
886 struct rpc_srv_callbacks eventlog_cb;
887 struct dcerpc_binding_vector *v;
888 const char *rpcsrv_type;
889 NTSTATUS status;
891 eventlog_cb.init = eventlog_init_cb;
892 eventlog_cb.shutdown = NULL;
893 eventlog_cb.private_data = msg_ctx;
895 status = rpc_eventlog_init(&eventlog_cb);
896 if (!NT_STATUS_IS_OK(status)) {
897 return false;
900 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
901 "rpc_server",
902 "epmapper",
903 "none");
905 if (strcasecmp_m(rpcsrv_type, "embedded") == 0 ||
906 strcasecmp_m(rpcsrv_type, "daemon") == 0) {
907 status = dcerpc_binding_vector_new(talloc_tos(), &v);
908 if (!NT_STATUS_IS_OK(status)) {
909 return false;
912 status = dcerpc_binding_vector_add_np_default(t, v);
913 if (!NT_STATUS_IS_OK(status)) {
914 return false;
917 status = rpc_ep_register(ev_ctx,
918 msg_ctx,
921 if (!NT_STATUS_IS_OK(status)) {
922 return false;
926 return true;
929 static bool rpc_setup_initshutdown(struct tevent_context *ev_ctx,
930 struct messaging_context *msg_ctx)
932 const struct ndr_interface_table *t = &ndr_table_initshutdown;
933 struct dcerpc_binding_vector *v;
934 const char *rpcsrv_type;
935 NTSTATUS status;
937 status = rpc_initshutdown_init(NULL);
938 if (!NT_STATUS_IS_OK(status)) {
939 return false;
942 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
943 "rpc_server",
944 "epmapper",
945 "none");
947 if (strcasecmp_m(rpcsrv_type, "embedded") == 0 ||
948 strcasecmp_m(rpcsrv_type, "daemon") == 0) {
949 status = dcerpc_binding_vector_new(talloc_tos(), &v);
950 if (!NT_STATUS_IS_OK(status)) {
951 return false;
954 status = dcerpc_binding_vector_add_np_default(t, v);
955 if (!NT_STATUS_IS_OK(status)) {
956 return false;
959 status = rpc_ep_register(ev_ctx,
960 msg_ctx,
963 if (!NT_STATUS_IS_OK(status)) {
964 return false;
968 return true;
971 bool dcesrv_ep_setup(struct tevent_context *ev_ctx,
972 struct messaging_context *msg_ctx)
974 struct dcerpc_binding_vector *v;
975 const char *rpcsrv_type;
976 TALLOC_CTX *tmp_ctx;
977 NTSTATUS status;
978 bool ok;
980 tmp_ctx = talloc_stackframe();
981 if (tmp_ctx == NULL) {
982 return false;
985 status = dcerpc_binding_vector_new(tmp_ctx,
986 &v);
987 if (!NT_STATUS_IS_OK(status)) {
988 ok = false;
989 goto done;
992 ok = rpc_setup_epmapper(ev_ctx, msg_ctx);
993 if (!ok) {
994 goto done;
997 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
998 "rpc_server",
999 "tcpip",
1000 "no");
1002 if (strcasecmp_m(rpcsrv_type, "yes") == 0 ||
1003 strcasecmp_m(rpcsrv_type, "true") == 0) {
1004 status = rpc_setup_tcpip_sockets(ev_ctx,
1005 msg_ctx,
1006 &ndr_table_winreg,
1009 if (!NT_STATUS_IS_OK(status)) {
1010 ok = false;
1011 goto done;
1015 ok = rpc_setup_winreg(ev_ctx, msg_ctx, v);
1016 if (!ok) {
1017 goto done;
1020 ok = rpc_setup_srvsvc(ev_ctx, msg_ctx, v);
1021 if (!ok) {
1022 goto done;
1025 ok = rpc_setup_lsarpc(ev_ctx, msg_ctx, v);
1026 if (!ok) {
1027 goto done;
1030 ok = rpc_setup_samr(ev_ctx, msg_ctx, v);
1031 if (!ok) {
1032 goto done;
1035 ok = rpc_setup_netlogon(ev_ctx, msg_ctx, v);
1036 if (!ok) {
1037 goto done;
1040 ok = rpc_setup_netdfs(ev_ctx, msg_ctx, v);
1041 if (!ok) {
1042 goto done;
1045 #ifdef DEVELOPER
1046 ok = rpc_setup_rpcecho(ev_ctx, msg_ctx, v);
1047 if (!ok) {
1048 goto done;
1050 #endif
1052 ok = rpc_setup_dssetup(ev_ctx, msg_ctx, v);
1053 if (!ok) {
1054 goto done;
1057 ok = rpc_setup_wkssvc(ev_ctx, msg_ctx, v);
1058 if (!ok) {
1059 goto done;
1062 ok = rpc_setup_spoolss(ev_ctx, msg_ctx);
1063 if (!ok) {
1064 goto done;
1067 ok = rpc_setup_svcctl(ev_ctx, msg_ctx);
1068 if (!ok) {
1069 goto done;
1072 ok = rpc_setup_ntsvcs(ev_ctx, msg_ctx);
1073 if (!ok) {
1074 goto done;
1077 ok = rpc_setup_eventlog(ev_ctx, msg_ctx);
1078 if (!ok) {
1079 goto done;
1082 ok = rpc_setup_initshutdown(ev_ctx, msg_ctx);
1083 if (!ok) {
1084 goto done;
1087 done:
1088 talloc_free(tmp_ctx);
1089 return ok;
1092 /* vim: set ts=8 sw=8 noet cindent ft=c.doxygen: */