s3-utils: net - Fix one error/usage message
[Samba/gebeck_regimport.git] / source3 / rpc_server / rpc_service_setup.c
blob29d7bf238a2b84c5f1806bd6218d1376e252b7c2
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/rpc_config.h"
54 #include "rpc_server/epmapper/srv_epmapper.h"
56 static bool rpc_setup_epmapper(struct tevent_context *ev_ctx,
57 struct messaging_context *msg_ctx)
59 enum rpc_service_mode_e epm_mode = rpc_epmapper_mode();
60 enum rpc_daemon_type_e epm_type = rpc_epmapper_daemon();
61 NTSTATUS status;
63 if (epm_mode != RPC_SERVICE_MODE_DISABLED &&
64 epm_type != RPC_DAEMON_DISABLED) {
65 status = rpc_epmapper_init(NULL);
66 if (!NT_STATUS_IS_OK(status)) {
67 return false;
71 return true;
74 static bool rpc_setup_winreg(struct tevent_context *ev_ctx,
75 struct messaging_context *msg_ctx,
76 const struct dcerpc_binding_vector *v)
78 const struct ndr_interface_table *t = &ndr_table_winreg;
79 const char *pipe_name = "winreg";
80 struct dcerpc_binding_vector *v2;
81 enum rpc_service_mode_e epm_mode = rpc_epmapper_mode();
82 NTSTATUS status;
83 bool ok;
85 status = rpc_winreg_init(NULL);
86 if (!NT_STATUS_IS_OK(status)) {
87 return false;
90 if (epm_mode != RPC_SERVICE_MODE_DISABLED) {
91 v2 = dcerpc_binding_vector_dup(talloc_tos(), v);
92 if (v2 == NULL) {
93 return false;
96 status = dcerpc_binding_vector_replace_iface(t, v2);
97 if (!NT_STATUS_IS_OK(status)) {
98 return false;
101 status = dcerpc_binding_vector_add_np_default(t, v2);
102 if (!NT_STATUS_IS_OK(status)) {
103 return false;
106 ok = setup_dcerpc_ncalrpc_socket(ev_ctx,
107 msg_ctx,
108 pipe_name,
109 NULL);
110 if (!ok) {
111 return false;
114 status = dcerpc_binding_vector_add_unix(t, v2, pipe_name);
115 if (!NT_STATUS_IS_OK(status)) {
116 return false;
119 status = rpc_ep_register(ev_ctx,
120 msg_ctx,
122 v2);
123 if (!NT_STATUS_IS_OK(status)) {
124 return false;
128 return true;
131 static bool rpc_setup_srvsvc(struct tevent_context *ev_ctx,
132 struct messaging_context *msg_ctx,
133 const struct dcerpc_binding_vector *v)
135 const struct ndr_interface_table *t = &ndr_table_srvsvc;
136 const char *pipe_name = "srvsvc";
137 struct dcerpc_binding_vector *v2;
138 enum rpc_service_mode_e epm_mode = rpc_epmapper_mode();
139 NTSTATUS status;
140 bool ok;
142 status = rpc_srvsvc_init(NULL);
143 if (!NT_STATUS_IS_OK(status)) {
144 return false;
147 if (epm_mode != RPC_SERVICE_MODE_DISABLED) {
148 v2 = dcerpc_binding_vector_dup(talloc_tos(), v);
149 if (v2 == NULL) {
150 return false;
153 status = dcerpc_binding_vector_replace_iface(t, v2);
154 if (!NT_STATUS_IS_OK(status)) {
155 return false;
158 status = dcerpc_binding_vector_add_np_default(t, v2);
159 if (!NT_STATUS_IS_OK(status)) {
160 return false;
163 ok = setup_dcerpc_ncalrpc_socket(ev_ctx,
164 msg_ctx,
165 pipe_name,
166 NULL);
167 if (!ok) {
168 return false;
171 status = dcerpc_binding_vector_add_unix(t, v2, pipe_name);
172 if (!NT_STATUS_IS_OK(status)) {
173 return false;
176 status = rpc_ep_register(ev_ctx,
177 msg_ctx,
179 v2);
180 if (!NT_STATUS_IS_OK(status)) {
181 return false;
185 return true;
188 static bool rpc_setup_lsarpc(struct tevent_context *ev_ctx,
189 struct messaging_context *msg_ctx,
190 const struct dcerpc_binding_vector *v)
192 const struct ndr_interface_table *t = &ndr_table_lsarpc;
193 const char *pipe_name = "lsarpc";
194 struct dcerpc_binding_vector *v2;
195 enum rpc_service_mode_e epm_mode = rpc_epmapper_mode();
196 enum rpc_service_mode_e lsarpc_mode = rpc_lsarpc_mode();
197 enum rpc_daemon_type_e lsasd_type = rpc_lsasd_daemon();
198 NTSTATUS status;
199 bool ok;
201 status = rpc_lsarpc_init(NULL);
202 if (!NT_STATUS_IS_OK(status)) {
203 return false;
206 if (lsarpc_mode == RPC_SERVICE_MODE_EMBEDDED &&
207 lsasd_type != RPC_DAEMON_DISABLED &&
208 epm_mode != RPC_SERVICE_MODE_DISABLED) {
209 v2 = dcerpc_binding_vector_dup(talloc_tos(), v);
210 if (v2 == NULL) {
211 return false;
214 status = dcerpc_binding_vector_replace_iface(t, v2);
215 if (!NT_STATUS_IS_OK(status)) {
216 return false;
219 status = dcerpc_binding_vector_add_np_default(t, v2);
220 if (!NT_STATUS_IS_OK(status)) {
221 return false;
224 ok = setup_dcerpc_ncalrpc_socket(ev_ctx,
225 msg_ctx,
226 pipe_name,
227 NULL);
228 if (!ok) {
229 return false;
232 status = dcerpc_binding_vector_add_unix(t, v2, pipe_name);
233 if (!NT_STATUS_IS_OK(status)) {
234 return false;
237 status = rpc_ep_register(ev_ctx,
238 msg_ctx,
240 v2);
241 if (!NT_STATUS_IS_OK(status)) {
242 return false;
246 return true;
249 static bool rpc_setup_samr(struct tevent_context *ev_ctx,
250 struct messaging_context *msg_ctx,
251 const struct dcerpc_binding_vector *v)
253 const struct ndr_interface_table *t = &ndr_table_samr;
254 const char *pipe_name = "samr";
255 struct dcerpc_binding_vector *v2;
256 enum rpc_service_mode_e epm_mode = rpc_epmapper_mode();
257 enum rpc_service_mode_e samr_mode = rpc_samr_mode();
258 enum rpc_daemon_type_e lsasd_type = rpc_lsasd_daemon();
259 NTSTATUS status;
260 bool ok;
262 status = rpc_samr_init(NULL);
263 if (!NT_STATUS_IS_OK(status)) {
264 return false;
267 if (samr_mode == RPC_SERVICE_MODE_EMBEDDED &&
268 lsasd_type != RPC_DAEMON_DISABLED &&
269 epm_mode != RPC_SERVICE_MODE_DISABLED) {
270 v2 = dcerpc_binding_vector_dup(talloc_tos(), v);
271 if (v2 == NULL) {
272 return false;
275 status = dcerpc_binding_vector_replace_iface(t, v2);
276 if (!NT_STATUS_IS_OK(status)) {
277 return false;
280 status = dcerpc_binding_vector_add_np_default(t, v2);
281 if (!NT_STATUS_IS_OK(status)) {
282 return false;
285 ok = setup_dcerpc_ncalrpc_socket(ev_ctx,
286 msg_ctx,
287 pipe_name,
288 NULL);
289 if (!ok) {
290 return false;
293 status = dcerpc_binding_vector_add_unix(t, v2, pipe_name);
294 if (!NT_STATUS_IS_OK(status)) {
295 return false;
298 status = rpc_ep_register(ev_ctx,
299 msg_ctx,
301 v2);
302 if (!NT_STATUS_IS_OK(status)) {
303 return false;
307 return true;
310 static bool rpc_setup_netlogon(struct tevent_context *ev_ctx,
311 struct messaging_context *msg_ctx,
312 const struct dcerpc_binding_vector *v)
314 const struct ndr_interface_table *t = &ndr_table_netlogon;
315 const char *pipe_name = "netlogon";
316 struct dcerpc_binding_vector *v2;
317 enum rpc_service_mode_e epm_mode = rpc_epmapper_mode();
318 enum rpc_service_mode_e netlogon_mode = rpc_netlogon_mode();
319 enum rpc_daemon_type_e lsasd_type = rpc_lsasd_daemon();
320 NTSTATUS status;
321 bool ok;
323 status = rpc_netlogon_init(NULL);
324 if (!NT_STATUS_IS_OK(status)) {
325 return false;
328 if (netlogon_mode == RPC_SERVICE_MODE_EMBEDDED &&
329 lsasd_type != RPC_DAEMON_DISABLED &&
330 epm_mode != RPC_SERVICE_MODE_DISABLED) {
331 v2 = dcerpc_binding_vector_dup(talloc_tos(), v);
332 if (v2 == NULL) {
333 return false;
336 status = dcerpc_binding_vector_replace_iface(t, v2);
337 if (!NT_STATUS_IS_OK(status)) {
338 return false;
341 status = dcerpc_binding_vector_add_np_default(t, v2);
342 if (!NT_STATUS_IS_OK(status)) {
343 return false;
346 ok = setup_dcerpc_ncalrpc_socket(ev_ctx,
347 msg_ctx,
348 pipe_name,
349 NULL);
350 if (!ok) {
351 return false;
354 status = dcerpc_binding_vector_add_unix(t, v2, pipe_name);
355 if (!NT_STATUS_IS_OK(status)) {
356 return false;
359 status = rpc_ep_register(ev_ctx,
360 msg_ctx,
362 v2);
363 if (!NT_STATUS_IS_OK(status)) {
364 return false;
368 return true;
371 static bool rpc_setup_netdfs(struct tevent_context *ev_ctx,
372 struct messaging_context *msg_ctx,
373 const struct dcerpc_binding_vector *v)
375 const struct ndr_interface_table *t = &ndr_table_netdfs;
376 const char *pipe_name = "netdfs";
377 struct dcerpc_binding_vector *v2;
378 enum rpc_service_mode_e epm_mode = rpc_epmapper_mode();
379 NTSTATUS status;
380 bool ok;
382 status = rpc_netdfs_init(NULL);
383 if (!NT_STATUS_IS_OK(status)) {
384 return false;
387 if (epm_mode != RPC_SERVICE_MODE_DISABLED) {
388 v2 = dcerpc_binding_vector_dup(talloc_tos(), v);
389 if (v2 == NULL) {
390 return false;
393 status = dcerpc_binding_vector_replace_iface(t, v2);
394 if (!NT_STATUS_IS_OK(status)) {
395 return false;
398 status = dcerpc_binding_vector_add_np_default(t, v2);
399 if (!NT_STATUS_IS_OK(status)) {
400 return false;
403 ok = setup_dcerpc_ncalrpc_socket(ev_ctx,
404 msg_ctx,
405 pipe_name,
406 NULL);
407 if (!ok) {
408 return false;
411 status = dcerpc_binding_vector_add_unix(t, v2, pipe_name);
412 if (!NT_STATUS_IS_OK(status)) {
413 return false;
416 status = rpc_ep_register(ev_ctx,
417 msg_ctx,
419 v2);
420 if (!NT_STATUS_IS_OK(status)) {
421 return false;
425 return true;
428 #ifdef DEVELOPER
429 static bool rpc_setup_rpcecho(struct tevent_context *ev_ctx,
430 struct messaging_context *msg_ctx,
431 const struct dcerpc_binding_vector *v)
433 const struct ndr_interface_table *t = &ndr_table_rpcecho;
434 const char *pipe_name = "rpcecho";
435 struct dcerpc_binding_vector *v2;
436 enum rpc_service_mode_e epm_mode = rpc_epmapper_mode();
437 NTSTATUS status;
438 bool ok;
440 status = rpc_rpcecho_init(NULL);
441 if (!NT_STATUS_IS_OK(status)) {
442 return false;
445 if (epm_mode != RPC_SERVICE_MODE_DISABLED) {
446 v2 = dcerpc_binding_vector_dup(talloc_tos(), v);
447 if (v2 == NULL) {
448 return false;
451 status = dcerpc_binding_vector_replace_iface(t, v2);
452 if (!NT_STATUS_IS_OK(status)) {
453 return false;
456 status = dcerpc_binding_vector_add_np_default(t, v2);
457 if (!NT_STATUS_IS_OK(status)) {
458 return false;
461 ok = setup_dcerpc_ncalrpc_socket(ev_ctx,
462 msg_ctx,
463 pipe_name,
464 NULL);
465 if (!ok) {
466 return false;
469 status = dcerpc_binding_vector_add_unix(t, v2, pipe_name);
470 if (!NT_STATUS_IS_OK(status)) {
471 return false;
474 status = rpc_ep_register(ev_ctx,
475 msg_ctx,
477 v2);
478 if (!NT_STATUS_IS_OK(status)) {
479 return false;
483 return true;
485 #endif
487 static bool rpc_setup_dssetup(struct tevent_context *ev_ctx,
488 struct messaging_context *msg_ctx,
489 const struct dcerpc_binding_vector *v)
491 const struct ndr_interface_table *t = &ndr_table_dssetup;
492 const char *pipe_name = "dssetup";
493 struct dcerpc_binding_vector *v2;
494 enum rpc_service_mode_e epm_mode = rpc_epmapper_mode();
495 NTSTATUS status;
496 bool ok;
498 status = rpc_dssetup_init(NULL);
499 if (!NT_STATUS_IS_OK(status)) {
500 return false;
503 if (epm_mode != RPC_SERVICE_MODE_DISABLED) {
504 v2 = dcerpc_binding_vector_dup(talloc_tos(), v);
505 if (v2 == NULL) {
506 return false;
509 status = dcerpc_binding_vector_replace_iface(t, v2);
510 if (!NT_STATUS_IS_OK(status)) {
511 return false;
514 status = dcerpc_binding_vector_add_np_default(t, v2);
515 if (!NT_STATUS_IS_OK(status)) {
516 return false;
519 ok = setup_dcerpc_ncalrpc_socket(ev_ctx,
520 msg_ctx,
521 pipe_name,
522 NULL);
523 if (!ok) {
524 return false;
527 status = dcerpc_binding_vector_add_unix(t, v2, pipe_name);
528 if (!NT_STATUS_IS_OK(status)) {
529 return false;
532 status = rpc_ep_register(ev_ctx,
533 msg_ctx,
535 v2);
536 if (!NT_STATUS_IS_OK(status)) {
537 return false;
541 return true;
544 static bool rpc_setup_wkssvc(struct tevent_context *ev_ctx,
545 struct messaging_context *msg_ctx,
546 const struct dcerpc_binding_vector *v)
548 const struct ndr_interface_table *t = &ndr_table_wkssvc;
549 const char *pipe_name = "wkssvc";
550 struct dcerpc_binding_vector *v2;
551 enum rpc_service_mode_e epm_mode = rpc_epmapper_mode();
552 NTSTATUS status;
553 bool ok;
555 status = rpc_wkssvc_init(NULL);
556 if (!NT_STATUS_IS_OK(status)) {
557 return false;
560 if (epm_mode != RPC_SERVICE_MODE_DISABLED) {
561 v2 = dcerpc_binding_vector_dup(talloc_tos(), v);
562 if (v2 == NULL) {
563 return false;
566 status = dcerpc_binding_vector_replace_iface(t, v2);
567 if (!NT_STATUS_IS_OK(status)) {
568 return false;
571 status = dcerpc_binding_vector_add_np_default(t, v2);
572 if (!NT_STATUS_IS_OK(status)) {
573 return false;
576 ok = setup_dcerpc_ncalrpc_socket(ev_ctx,
577 msg_ctx,
578 pipe_name,
579 NULL);
580 if (!ok) {
581 return false;
584 status = dcerpc_binding_vector_add_unix(t, v2, pipe_name);
585 if (!NT_STATUS_IS_OK(status)) {
586 return false;
589 status = rpc_ep_register(ev_ctx,
590 msg_ctx,
592 v2);
593 if (!NT_STATUS_IS_OK(status)) {
594 return false;
598 return true;
601 static bool spoolss_init_cb(void *ptr)
603 struct messaging_context *msg_ctx =
604 talloc_get_type_abort(ptr, struct messaging_context);
605 bool ok;
608 * Migrate the printers first.
610 ok = nt_printing_tdb_migrate(msg_ctx);
611 if (!ok) {
612 return false;
615 return true;
618 static bool spoolss_shutdown_cb(void *ptr)
620 srv_spoolss_cleanup();
622 return true;
625 static bool rpc_setup_spoolss(struct tevent_context *ev_ctx,
626 struct messaging_context *msg_ctx)
628 const struct ndr_interface_table *t = &ndr_table_spoolss;
629 struct rpc_srv_callbacks spoolss_cb;
630 struct dcerpc_binding_vector *v;
631 enum rpc_service_mode_e spoolss_mode = rpc_spoolss_mode();
632 enum rpc_daemon_type_e spoolss_type = rpc_spoolss_daemon();
633 NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
635 if (_lp_disable_spoolss() ||
636 spoolss_type == RPC_DAEMON_DISABLED ||
637 spoolss_mode == RPC_SERVICE_MODE_DISABLED) {
638 return true;
641 if (spoolss_type == RPC_DAEMON_EMBEDDED) {
642 spoolss_cb.init = spoolss_init_cb;
643 spoolss_cb.shutdown = spoolss_shutdown_cb;
644 spoolss_cb.private_data = msg_ctx;
646 status = rpc_spoolss_init(&spoolss_cb);
647 } else if (spoolss_type == RPC_DAEMON_FORK) {
648 status = rpc_spoolss_init(NULL);
650 if (!NT_STATUS_IS_OK(status)) {
651 return false;
654 if (spoolss_type == RPC_DAEMON_EMBEDDED) {
655 enum rpc_service_mode_e epm_mode = rpc_epmapper_mode();
657 if (epm_mode != RPC_SERVICE_MODE_DISABLED) {
658 status = dcerpc_binding_vector_new(talloc_tos(), &v);
659 if (!NT_STATUS_IS_OK(status)) {
660 return false;
663 status = dcerpc_binding_vector_add_np_default(t, v);
664 if (!NT_STATUS_IS_OK(status)) {
665 return false;
668 status = rpc_ep_register(ev_ctx,
669 msg_ctx,
672 if (!NT_STATUS_IS_OK(status)) {
673 return false;
678 return true;
681 static bool svcctl_init_cb(void *ptr)
683 struct messaging_context *msg_ctx =
684 talloc_get_type_abort(ptr, struct messaging_context);
685 bool ok;
687 /* initialize the control hooks */
688 init_service_op_table();
690 ok = svcctl_init_winreg(msg_ctx);
691 if (!ok) {
692 return false;
695 return true;
698 static bool svcctl_shutdown_cb(void *ptr)
700 shutdown_service_op_table();
702 return true;
705 static bool rpc_setup_svcctl(struct tevent_context *ev_ctx,
706 struct messaging_context *msg_ctx)
708 const struct ndr_interface_table *t = &ndr_table_svcctl;
709 const char *pipe_name = "svcctl";
710 struct dcerpc_binding_vector *v;
711 enum rpc_service_mode_e epm_mode = rpc_epmapper_mode();
712 struct rpc_srv_callbacks svcctl_cb;
713 NTSTATUS status;
714 bool ok;
716 svcctl_cb.init = svcctl_init_cb;
717 svcctl_cb.shutdown = svcctl_shutdown_cb;
718 svcctl_cb.private_data = msg_ctx;
720 status = rpc_svcctl_init(&svcctl_cb);
721 if (!NT_STATUS_IS_OK(status)) {
722 return false;
725 if (epm_mode != RPC_SERVICE_MODE_DISABLED) {
726 status = dcerpc_binding_vector_new(talloc_tos(), &v);
727 if (!NT_STATUS_IS_OK(status)) {
728 return false;
731 status = dcerpc_binding_vector_add_np_default(t, v);
732 if (!NT_STATUS_IS_OK(status)) {
733 return false;
736 ok = setup_dcerpc_ncalrpc_socket(ev_ctx,
737 msg_ctx,
738 pipe_name,
739 NULL);
740 if (!ok) {
741 return false;
744 status = dcerpc_binding_vector_add_unix(t, v, pipe_name);
745 if (!NT_STATUS_IS_OK(status)) {
746 return false;
749 status = rpc_ep_register(ev_ctx,
750 msg_ctx,
753 if (!NT_STATUS_IS_OK(status)) {
754 return false;
758 return true;
761 static bool rpc_setup_ntsvcs(struct tevent_context *ev_ctx,
762 struct messaging_context *msg_ctx)
764 const struct ndr_interface_table *t = &ndr_table_ntsvcs;
765 struct dcerpc_binding_vector *v;
766 enum rpc_service_mode_e epm_mode = rpc_epmapper_mode();
767 NTSTATUS status;
769 status = rpc_ntsvcs_init(NULL);
770 if (!NT_STATUS_IS_OK(status)) {
771 return false;
774 if (epm_mode != RPC_SERVICE_MODE_DISABLED) {
775 status = dcerpc_binding_vector_new(talloc_tos(), &v);
776 if (!NT_STATUS_IS_OK(status)) {
777 return false;
780 status = dcerpc_binding_vector_add_np_default(t, v);
781 if (!NT_STATUS_IS_OK(status)) {
782 return false;
785 status = rpc_ep_register(ev_ctx,
786 msg_ctx,
789 if (!NT_STATUS_IS_OK(status)) {
790 return false;
794 return true;
797 static bool eventlog_init_cb(void *ptr)
799 struct messaging_context *msg_ctx =
800 talloc_get_type_abort(ptr, struct messaging_context);
801 bool ok;
803 ok = eventlog_init_winreg(msg_ctx);
804 if (!ok) {
805 return false;
808 return true;
811 static bool rpc_setup_eventlog(struct tevent_context *ev_ctx,
812 struct messaging_context *msg_ctx)
814 const struct ndr_interface_table *t = &ndr_table_eventlog;
815 struct rpc_srv_callbacks eventlog_cb;
816 struct dcerpc_binding_vector *v;
817 enum rpc_service_mode_e epm_mode = rpc_epmapper_mode();
818 NTSTATUS status;
820 eventlog_cb.init = eventlog_init_cb;
821 eventlog_cb.shutdown = NULL;
822 eventlog_cb.private_data = msg_ctx;
824 status = rpc_eventlog_init(&eventlog_cb);
825 if (!NT_STATUS_IS_OK(status)) {
826 return false;
829 if (epm_mode != RPC_SERVICE_MODE_DISABLED) {
830 status = dcerpc_binding_vector_new(talloc_tos(), &v);
831 if (!NT_STATUS_IS_OK(status)) {
832 return false;
835 status = dcerpc_binding_vector_add_np_default(t, v);
836 if (!NT_STATUS_IS_OK(status)) {
837 return false;
840 status = rpc_ep_register(ev_ctx,
841 msg_ctx,
844 if (!NT_STATUS_IS_OK(status)) {
845 return false;
849 return true;
852 static bool rpc_setup_initshutdown(struct tevent_context *ev_ctx,
853 struct messaging_context *msg_ctx)
855 const struct ndr_interface_table *t = &ndr_table_initshutdown;
856 struct dcerpc_binding_vector *v;
857 enum rpc_service_mode_e epm_mode = rpc_epmapper_mode();
858 NTSTATUS status;
860 status = rpc_initshutdown_init(NULL);
861 if (!NT_STATUS_IS_OK(status)) {
862 return false;
865 if (epm_mode != RPC_SERVICE_MODE_DISABLED) {
866 status = dcerpc_binding_vector_new(talloc_tos(), &v);
867 if (!NT_STATUS_IS_OK(status)) {
868 return false;
871 status = dcerpc_binding_vector_add_np_default(t, v);
872 if (!NT_STATUS_IS_OK(status)) {
873 return false;
876 status = rpc_ep_register(ev_ctx,
877 msg_ctx,
880 if (!NT_STATUS_IS_OK(status)) {
881 return false;
885 return true;
888 bool dcesrv_ep_setup(struct tevent_context *ev_ctx,
889 struct messaging_context *msg_ctx)
891 enum rpc_service_mode_e epm_mode = rpc_epmapper_mode();
892 struct dcerpc_binding_vector *v;
893 const char *rpcsrv_type;
894 TALLOC_CTX *tmp_ctx;
895 NTSTATUS status;
896 bool ok;
898 tmp_ctx = talloc_stackframe();
899 if (tmp_ctx == NULL) {
900 return false;
903 status = dcerpc_binding_vector_new(tmp_ctx,
904 &v);
905 if (!NT_STATUS_IS_OK(status)) {
906 ok = false;
907 goto done;
910 ok = rpc_setup_epmapper(ev_ctx, msg_ctx);
911 if (!ok) {
912 goto done;
915 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
916 "rpc_server",
917 "tcpip",
918 "no");
920 if ((strcasecmp_m(rpcsrv_type, "yes") == 0 ||
921 strcasecmp_m(rpcsrv_type, "true") == 0)
922 && epm_mode != RPC_SERVICE_MODE_DISABLED) {
923 status = rpc_setup_tcpip_sockets(ev_ctx,
924 msg_ctx,
925 &ndr_table_winreg,
928 if (!NT_STATUS_IS_OK(status)) {
929 ok = false;
930 goto done;
934 ok = rpc_setup_winreg(ev_ctx, msg_ctx, v);
935 if (!ok) {
936 goto done;
939 ok = rpc_setup_srvsvc(ev_ctx, msg_ctx, v);
940 if (!ok) {
941 goto done;
944 ok = rpc_setup_lsarpc(ev_ctx, msg_ctx, v);
945 if (!ok) {
946 goto done;
949 ok = rpc_setup_samr(ev_ctx, msg_ctx, v);
950 if (!ok) {
951 goto done;
954 ok = rpc_setup_netlogon(ev_ctx, msg_ctx, v);
955 if (!ok) {
956 goto done;
959 ok = rpc_setup_netdfs(ev_ctx, msg_ctx, v);
960 if (!ok) {
961 goto done;
964 #ifdef DEVELOPER
965 ok = rpc_setup_rpcecho(ev_ctx, msg_ctx, v);
966 if (!ok) {
967 goto done;
969 #endif
971 ok = rpc_setup_dssetup(ev_ctx, msg_ctx, v);
972 if (!ok) {
973 goto done;
976 ok = rpc_setup_wkssvc(ev_ctx, msg_ctx, v);
977 if (!ok) {
978 goto done;
981 ok = rpc_setup_spoolss(ev_ctx, msg_ctx);
982 if (!ok) {
983 goto done;
986 ok = rpc_setup_svcctl(ev_ctx, msg_ctx);
987 if (!ok) {
988 goto done;
991 ok = rpc_setup_ntsvcs(ev_ctx, msg_ctx);
992 if (!ok) {
993 goto done;
996 ok = rpc_setup_eventlog(ev_ctx, msg_ctx);
997 if (!ok) {
998 goto done;
1001 ok = rpc_setup_initshutdown(ev_ctx, msg_ctx);
1002 if (!ok) {
1003 goto done;
1006 done:
1007 talloc_free(tmp_ctx);
1008 return ok;
1011 /* vim: set ts=8 sw=8 noet cindent ft=c.doxygen: */