s3-rpc_server: Rename req to subreq.
[nivanova/samba-autobuild/.git] / source3 / rpc_server / rpc_ep_setup.c
1 /*
2  *  Unix SMB/CIFS implementation.
3  *
4  *  SMBD RPC service callbacks
5  *
6  *  Copyright (c) 2011      Andreas Schneider <asn@samba.org>
7  *
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.
12  *
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.
17  *
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/>.
20  */
21
22 #include "includes.h"
23
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"
40
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"
44
45 #include "librpc/rpc/dcerpc_ep.h"
46
47 #include "rpc_server/rpc_ep_setup.h"
48 #include "rpc_server/rpc_server.h"
49 #include "rpc_server/epmapper/srv_epmapper.h"
50
51 struct dcesrv_ep_context {
52         struct tevent_context *ev_ctx;
53         struct messaging_context *msg_ctx;
54 };
55
56 static uint16_t _open_sockets(struct tevent_context *ev_ctx,
57                               struct messaging_context *msg_ctx,
58                               struct ndr_syntax_id syntax_id,
59                               uint16_t port)
60 {
61         uint32_t num_ifs = iface_count();
62         uint32_t i;
63         uint16_t p = 0;
64
65         if (lp_interfaces() && lp_bind_interfaces_only()) {
66                 /*
67                  * We have been given an interfaces line, and been told to only
68                  * bind to those interfaces. Create a socket per interface and
69                  * bind to only these.
70                  */
71
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);
76
77                         p = setup_dcerpc_ncacn_tcpip_socket(ev_ctx,
78                                                             msg_ctx,
79                                                             syntax_id,
80                                                             ifss,
81                                                             port);
82                         if (p == 0) {
83                                 return 0;
84                         }
85                         port = p;
86                 }
87         } else {
88                 const char *sock_addr = lp_socket_address();
89                 const char *sock_ptr;
90                 char *sock_tok;
91
92                 if (strequal(sock_addr, "0.0.0.0") ||
93                     strequal(sock_addr, "::")) {
94 #if HAVE_IPV6
95                         sock_addr = "::";
96 #else
97                         sock_addr = "0.0.0.0";
98 #endif
99                 }
100
101                 for (sock_ptr = sock_addr;
102                      next_token_talloc(talloc_tos(), &sock_ptr, &sock_tok, " \t,");
103                     ) {
104                         struct sockaddr_storage ss;
105
106                         /* open an incoming socket */
107                         if (!interpret_string_addr(&ss,
108                                                    sock_tok,
109                                                    AI_NUMERICHOST|AI_PASSIVE)) {
110                                 continue;
111                         }
112
113                         p = setup_dcerpc_ncacn_tcpip_socket(ev_ctx,
114                                                             msg_ctx,
115                                                             syntax_id,
116                                                             &ss,
117                                                             port);
118                         if (p == 0) {
119                                 return 0;
120                         }
121                         port = p;
122                 }
123         }
124
125         return p;
126 }
127
128 static NTSTATUS _rpc_ep_unregister(const struct ndr_interface_table *iface)
129 {
130         struct dcerpc_binding_vector *v = NULL;
131         NTSTATUS status;
132
133         status = dcerpc_binding_vector_create(talloc_tos(),
134                                               iface,
135                                               0,
136                                               NULL,
137                                               &v);
138         if (!NT_STATUS_IS_OK(status)) {
139                 return status;
140         }
141
142         status = dcerpc_ep_unregister(iface,
143                                       v,
144                                       &iface->syntax_id.uuid);
145         if (!NT_STATUS_IS_OK(status)) {
146                 return status;
147         }
148
149         return status;
150 }
151
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,
157                                           const char *name,
158                                           uint16_t port,
159                                           struct dcerpc_binding_handle **pbh);
160
161 struct rpc_ep_regsiter_state {
162         struct dcerpc_binding_handle *h;
163
164         TALLOC_CTX *mem_ctx;
165         struct tevent_context *ev_ctx;
166         struct messaging_context *msg_ctx;
167
168         const struct ndr_interface_table *iface;
169
170         const char *ncalrpc;
171         uint16_t port;
172
173         uint32_t wait_time;
174 };
175
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,
179                                       const char *ncalrpc,
180                                       uint16_t port)
181 {
182         struct rpc_ep_regsiter_state *state;
183         struct tevent_req *req;
184
185         state = talloc(ev_ctx, struct rpc_ep_regsiter_state);
186         if (state == NULL) {
187                 return NT_STATUS_NO_MEMORY;
188         }
189
190         state->mem_ctx = talloc_named(state,
191                                       0,
192                                       "ep %s %p",
193                                       iface->name, state);
194         if (state->mem_ctx == NULL) {
195                 talloc_free(state);
196                 return NT_STATUS_NO_MEMORY;
197         }
198
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);
204         state->port = port;
205
206         req = tevent_wakeup_send(state->mem_ctx,
207                                  state->ev_ctx,
208                                  timeval_current_ofs(1, 0));
209         if (tevent_req_nomem(state->mem_ctx, req)) {
210                 talloc_free(state);
211                 return NT_STATUS_NO_MEMORY;
212         }
213
214         tevent_req_set_callback(req, rpc_ep_setup_register_loop, state);
215
216         return NT_STATUS_OK;
217 }
218
219 #define MONITOR_WAIT_TIME 15
220 static void rpc_ep_setup_monitor_loop(struct tevent_req *subreq);
221
222 static void rpc_ep_setup_register_loop(struct tevent_req *subreq)
223 {
224         struct rpc_ep_regsiter_state *state =
225                 tevent_req_callback_data(subreq, struct rpc_ep_regsiter_state);
226         NTSTATUS status;
227         bool ok;
228
229         ok = tevent_wakeup_recv(subreq);
230         TALLOC_FREE(subreq);
231         if (!ok) {
232                 talloc_free(state);
233                 return;
234         }
235
236         status = rpc_ep_setup_try_register(state->mem_ctx,
237                                            state->ev_ctx,
238                                            state->msg_ctx,
239                                            state->iface,
240                                            state->ncalrpc,
241                                            state->port,
242                                            &state->h);
243         if (NT_STATUS_IS_OK(status)) {
244                 /* endpoint registered, monitor the connnection. */
245                 subreq = tevent_wakeup_send(state->mem_ctx,
246                                             state->ev_ctx,
247                                             timeval_current_ofs(MONITOR_WAIT_TIME, 0));
248                 if (tevent_req_nomem(state->mem_ctx, subreq)) {
249                         talloc_free(state);
250                         return;
251                 }
252
253                 tevent_req_set_callback(subreq, rpc_ep_setup_monitor_loop, state);
254                 return;
255         }
256
257         state->wait_time = state->wait_time * 2;
258         if (state->wait_time > 16) {
259                 talloc_free(state);
260                 return;
261         }
262
263         subreq = tevent_wakeup_send(state->mem_ctx,
264                                     state->ev_ctx,
265                                     timeval_current_ofs(state->wait_time, 0));
266         if (tevent_req_nomem(state->mem_ctx, subreq)) {
267                 talloc_free(state);
268                 return;
269         }
270
271         tevent_req_set_callback(subreq, rpc_ep_setup_register_loop, state);
272         return;
273 }
274
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,
279                                           const char *name,
280                                           uint16_t port,
281                                           struct dcerpc_binding_handle **pbh)
282 {
283         struct dcerpc_binding_vector *v = NULL;
284         NTSTATUS status;
285
286         status = dcerpc_binding_vector_create(mem_ctx,
287                                               iface,
288                                               port,
289                                               name,
290                                               &v);
291         if (!NT_STATUS_IS_OK(status)) {
292                 return status;
293         }
294
295         status = dcerpc_ep_register(mem_ctx,
296                                     iface,
297                                     v,
298                                     &iface->syntax_id.uuid,
299                                     name,
300                                     pbh);
301         talloc_free(v);
302         if (!NT_STATUS_IS_OK(status)) {
303                 return status;
304         }
305
306         return status;
307 }
308
309 /*
310  * Monitor the connection to the endpoint mapper and if it goes away, try to
311  * register the endpoint.
312  */
313 static void rpc_ep_setup_monitor_loop(struct tevent_req *subreq)
314 {
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;
322         struct GUID object;
323         NTSTATUS status;
324         uint32_t result = EPMAPPER_STATUS_CANT_PERFORM_OP;
325         TALLOC_CTX *tmp_ctx;
326         bool ok;
327
328         ZERO_STRUCT(object);
329         ZERO_STRUCT(entry_handle);
330
331         tmp_ctx = talloc_stackframe();
332         if (tmp_ctx == NULL) {
333                 talloc_free(state);
334                 return;
335         }
336
337         ok = tevent_wakeup_recv(subreq);
338         TALLOC_FREE(subreq);
339         if (!ok) {
340                 talloc_free(state);
341                 return;
342         }
343
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 = "";
349
350         map_tower = talloc_zero(tmp_ctx, struct epm_twr_t);
351         if (map_tower == NULL) {
352                 talloc_free(tmp_ctx);
353                 talloc_free(state);
354                 return;
355         }
356
357         status = dcerpc_binding_build_tower(map_tower, &map_binding,
358                                             &map_tower->tower);
359         if (!NT_STATUS_IS_OK(status)) {
360                 talloc_free(tmp_ctx);
361                 talloc_free(state);
362                 return;
363         }
364
365         ok = false;
366         status = dcerpc_epm_Map(state->h,
367                                 tmp_ctx,
368                                 &object,
369                                 map_tower,
370                                 &entry_handle,
371                                 10,
372                                 &num_towers,
373                                 towers,
374                                 &result);
375         if (NT_STATUS_IS_OK(status)) {
376                 ok = true;
377         }
378         if (result == EPMAPPER_STATUS_OK ||
379             result == EPMAPPER_STATUS_NO_MORE_ENTRIES) {
380                 ok = true;
381         }
382         if (num_towers == 0) {
383                 ok = false;
384         }
385
386         talloc_free(tmp_ctx);
387
388         subreq = tevent_wakeup_send(state->mem_ctx,
389                                     state->ev_ctx,
390                                     timeval_current_ofs(MONITOR_WAIT_TIME, 0));
391         if (tevent_req_nomem(state->mem_ctx, subreq)) {
392                 talloc_free(state);
393                 return;
394         }
395
396         if (ok) {
397                 tevent_req_set_callback(subreq, rpc_ep_setup_monitor_loop, state);
398         } else {
399                 TALLOC_FREE(state->h);
400                 state->wait_time = 1;
401
402                 tevent_req_set_callback(subreq, rpc_ep_setup_register_loop, state);
403         }
404
405         return;
406 }
407
408 static bool epmapper_init_cb(void *ptr)
409 {
410         struct dcesrv_ep_context *ep_ctx =
411                 talloc_get_type_abort(ptr, struct dcesrv_ep_context);
412         uint16_t port;
413
414         port = _open_sockets(ep_ctx->ev_ctx,
415                              ep_ctx->msg_ctx,
416                              ndr_table_epmapper.syntax_id,
417                              135);
418         if (port == 135) {
419                 return true;
420         }
421
422         return false;
423 }
424
425 static bool epmapper_shutdown_cb(void *ptr)
426 {
427         srv_epmapper_cleanup();
428
429         return true;
430 }
431
432 static bool winreg_init_cb(void *ptr)
433 {
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;
439         uint16_t port;
440
441         rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
442                                            "rpc_server",
443                                            "epmapper",
444                                            "none");
445
446         if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
447             StrCaseCmp(rpcsrv_type, "daemon") == 0) {
448                 NTSTATUS status;
449                 bool ok;
450
451                 ok = setup_dcerpc_ncalrpc_socket(ep_ctx->ev_ctx,
452                                                  ep_ctx->msg_ctx,
453                                                  abstract_syntax,
454                                                  pipe_name);
455                 if (!ok) {
456                         return false;
457                 }
458                 port = _open_sockets(ep_ctx->ev_ctx,
459                                      ep_ctx->msg_ctx,
460                                      abstract_syntax,
461                                      0);
462                 if (port == 0) {
463                         return false;
464                 }
465
466                 status = rpc_ep_setup_register(ep_ctx->ev_ctx,
467                                                 ep_ctx->msg_ctx,
468                                                 &ndr_table_winreg,
469                                                 pipe_name,
470                                                 port);
471                 if (!NT_STATUS_IS_OK(status)) {
472                         return false;
473                 }
474         }
475
476         return true;
477 }
478
479 static bool winreg_shutdown_cb(void *ptr)
480 {
481         const char *rpcsrv_type;
482
483         rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
484                                            "rpc_server",
485                                            "epmapper",
486                                            "none");
487
488         if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
489             StrCaseCmp(rpcsrv_type, "daemon") == 0) {
490                 NTSTATUS status;
491
492                 status = _rpc_ep_unregister(&ndr_table_winreg);
493                 if (!NT_STATUS_IS_OK(status)) {
494                         return false;
495                 }
496         }
497
498         return true;
499 }
500
501 static bool srvsvc_init_cb(void *ptr)
502 {
503         struct dcesrv_ep_context *ep_ctx =
504                 talloc_get_type_abort(ptr, struct dcesrv_ep_context);
505         struct ndr_syntax_id abstract_syntax = ndr_table_srvsvc.syntax_id;
506         const char *pipe_name = "srvsvc";
507         const char *rpcsrv_type;
508         uint16_t port;
509
510         rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
511                                            "rpc_server",
512                                            "epmapper",
513                                            "none");
514
515         if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
516             StrCaseCmp(rpcsrv_type, "daemon") == 0) {
517                 NTSTATUS status;
518                 bool ok;
519
520                 ok = setup_dcerpc_ncalrpc_socket(ep_ctx->ev_ctx,
521                                                  ep_ctx->msg_ctx,
522                                                  abstract_syntax,
523                                                  pipe_name);
524                 if (!ok) {
525                         return false;
526                 }
527
528                 port = _open_sockets(ep_ctx->ev_ctx,
529                                      ep_ctx->msg_ctx,
530                                      abstract_syntax,
531                                      0);
532                 if (port == 0) {
533                         return false;
534                 }
535
536                 status = rpc_ep_setup_register(ep_ctx->ev_ctx,
537                                           ep_ctx->msg_ctx,
538                                           &ndr_table_srvsvc,
539                                           pipe_name,
540                                           port);
541                 if (!NT_STATUS_IS_OK(status)) {
542                         return false;
543                 }
544         }
545
546         return true;
547 }
548
549 static bool srvsvc_shutdown_cb(void *ptr)
550 {
551         const char *rpcsrv_type;
552
553         rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
554                                            "rpc_server",
555                                            "epmapper",
556                                            "none");
557
558         if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
559             StrCaseCmp(rpcsrv_type, "daemon") == 0) {
560                 NTSTATUS status;
561
562                 status =_rpc_ep_unregister(&ndr_table_srvsvc);
563                 if (!NT_STATUS_IS_OK(status)) {
564                         return false;
565                 }
566         }
567
568         return true;
569 }
570
571 static bool lsarpc_init_cb(void *ptr)
572 {
573         struct dcesrv_ep_context *ep_ctx =
574                 talloc_get_type_abort(ptr, struct dcesrv_ep_context);
575         struct ndr_syntax_id abstract_syntax = ndr_table_lsarpc.syntax_id;
576         const char *pipe_name = "lsarpc";
577         const char *rpcsrv_type;
578         uint16_t port;
579
580         rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
581                                            "rpc_server",
582                                            "epmapper",
583                                            "none");
584
585         if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
586             StrCaseCmp(rpcsrv_type, "daemon") == 0) {
587                 NTSTATUS status;
588                 bool ok;
589
590                 ok = setup_dcerpc_ncalrpc_socket(ep_ctx->ev_ctx,
591                                                  ep_ctx->msg_ctx,
592                                                  abstract_syntax,
593                                                  pipe_name);
594                 if (!ok) {
595                         return false;
596                 }
597
598                 port = _open_sockets(ep_ctx->ev_ctx,
599                                      ep_ctx->msg_ctx,
600                                      abstract_syntax,
601                                      0);
602                 if (port == 0) {
603                         return false;
604                 }
605
606                 status = rpc_ep_setup_register(ep_ctx->ev_ctx,
607                                           ep_ctx->msg_ctx,
608                                           &ndr_table_lsarpc,
609                                           pipe_name,
610                                           port);
611                 if (!NT_STATUS_IS_OK(status)) {
612                         return false;
613                 }
614         }
615
616         return true;
617 }
618
619 static bool lsarpc_shutdown_cb(void *ptr)
620 {
621         const char *rpcsrv_type;
622
623         rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
624                                            "rpc_server",
625                                            "epmapper",
626                                            "none");
627
628         if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
629             StrCaseCmp(rpcsrv_type, "daemon") == 0) {
630                 NTSTATUS status;
631
632                 status = _rpc_ep_unregister(&ndr_table_lsarpc);
633                 if (!NT_STATUS_IS_OK(status)) {
634                         return false;
635                 }
636         }
637
638         return true;
639 }
640
641 static bool samr_init_cb(void *ptr)
642 {
643         struct dcesrv_ep_context *ep_ctx =
644                 talloc_get_type_abort(ptr, struct dcesrv_ep_context);
645         struct ndr_syntax_id abstract_syntax = ndr_table_samr.syntax_id;
646         const char *pipe_name = "samr";
647         const char *rpcsrv_type;
648         uint16_t port;
649
650         rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
651                                            "rpc_server",
652                                            "epmapper",
653                                            "none");
654
655         if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
656             StrCaseCmp(rpcsrv_type, "daemon") == 0) {
657                 NTSTATUS status;
658                 bool ok;
659
660                 ok = setup_dcerpc_ncalrpc_socket(ep_ctx->ev_ctx,
661                                                  ep_ctx->msg_ctx,
662                                                  abstract_syntax,
663                                                  pipe_name);
664                 if (!ok) {
665                         return false;
666                 }
667
668                 port = _open_sockets(ep_ctx->ev_ctx,
669                                      ep_ctx->msg_ctx,
670                                      abstract_syntax,
671                                      0);
672                 if (port == 0) {
673                         return false;
674                 }
675
676                 status = rpc_ep_setup_register(ep_ctx->ev_ctx,
677                                           ep_ctx->msg_ctx,
678                                           &ndr_table_samr,
679                                           pipe_name,
680                                           port);
681                 if (!NT_STATUS_IS_OK(status)) {
682                         return false;
683                 }
684         }
685
686         return true;
687 }
688
689 static bool samr_shutdown_cb(void *ptr)
690 {
691         const char *rpcsrv_type;
692
693         rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
694                                            "rpc_server",
695                                            "epmapper",
696                                            "none");
697
698         if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
699             StrCaseCmp(rpcsrv_type, "daemon") == 0) {
700                 NTSTATUS status;
701
702                 status = _rpc_ep_unregister(&ndr_table_samr);
703                 if (!NT_STATUS_IS_OK(status)) {
704                         return false;
705                 }
706         }
707
708         return true;
709 }
710
711 static bool netlogon_init_cb(void *ptr)
712 {
713         struct dcesrv_ep_context *ep_ctx =
714                 talloc_get_type_abort(ptr, struct dcesrv_ep_context);
715         struct ndr_syntax_id abstract_syntax = ndr_table_netlogon.syntax_id;
716         const char *pipe_name = "netlogon";
717         const char *rpcsrv_type;
718         uint16_t port;
719
720         rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
721                                            "rpc_server",
722                                            "epmapper",
723                                            "none");
724
725         if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
726             StrCaseCmp(rpcsrv_type, "daemon") == 0) {
727                 NTSTATUS status;
728                 bool ok;
729
730                 ok = setup_dcerpc_ncalrpc_socket(ep_ctx->ev_ctx,
731                                                  ep_ctx->msg_ctx,
732                                                  abstract_syntax,
733                                                  pipe_name);
734                 if (!ok) {
735                         return false;
736                 }
737
738                 port = _open_sockets(ep_ctx->ev_ctx,
739                                      ep_ctx->msg_ctx,
740                                      abstract_syntax,
741                                      0);
742                 if (port == 0) {
743                         return false;
744                 }
745
746                 status = rpc_ep_setup_register(ep_ctx->ev_ctx,
747                                           ep_ctx->msg_ctx,
748                                           &ndr_table_netlogon,
749                                           pipe_name,
750                                           port);
751                 if (!NT_STATUS_IS_OK(status)) {
752                         return false;
753                 }
754         }
755
756         return true;
757 }
758
759 static bool netlogon_shutdown_cb(void *ptr)
760 {
761         const char *rpcsrv_type;
762
763         rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
764                                            "rpc_server",
765                                            "epmapper",
766                                            "none");
767
768         if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
769             StrCaseCmp(rpcsrv_type, "daemon") == 0) {
770                 NTSTATUS status;
771
772                 status = _rpc_ep_unregister(&ndr_table_netlogon);
773                 if (!NT_STATUS_IS_OK(status)) {
774                         return false;
775                 }
776         }
777
778         return true;
779 }
780
781 static bool spoolss_init_cb(void *ptr)
782 {
783         struct dcesrv_ep_context *ep_ctx =
784                 talloc_get_type_abort(ptr, struct dcesrv_ep_context);
785         const char *rpcsrv_type;
786         bool ok;
787
788         rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
789                                            "rpc_server",
790                                            "epmapper",
791                                            "none");
792
793         /*
794          * Migrate the printers first.
795          */
796         ok = nt_printing_tdb_migrate(ep_ctx->msg_ctx);
797         if (!ok) {
798                 return false;
799         }
800
801         if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
802             StrCaseCmp(rpcsrv_type, "daemon") == 0) {
803                 NTSTATUS status;
804
805                 status =rpc_ep_setup_register(ep_ctx->ev_ctx,
806                                          ep_ctx->msg_ctx,
807                                          &ndr_table_spoolss,
808                                          "spoolss",
809                                          0);
810                 if (!NT_STATUS_IS_OK(status)) {
811                         return false;
812                 }
813         }
814
815         return true;
816 }
817
818 static bool spoolss_shutdown_cb(void *ptr)
819 {
820         const char *rpcsrv_type;
821
822         rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
823                                            "rpc_server",
824                                            "epmapper",
825                                            "none");
826
827         srv_spoolss_cleanup();
828
829         if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
830             StrCaseCmp(rpcsrv_type, "daemon") == 0) {
831                 NTSTATUS status;
832
833                 status = _rpc_ep_unregister(&ndr_table_spoolss);
834                 if (!NT_STATUS_IS_OK(status)) {
835                         return false;
836                 }
837         }
838
839         return true;
840 }
841
842 static bool svcctl_init_cb(void *ptr)
843 {
844         struct dcesrv_ep_context *ep_ctx =
845                 talloc_get_type_abort(ptr, struct dcesrv_ep_context);
846         const char *rpcsrv_type;
847         bool ok;
848
849         rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
850                                            "rpc_server",
851                                            "epmapper",
852                                            "none");
853
854         ok = svcctl_init_winreg(ep_ctx->msg_ctx);
855         if (!ok) {
856                 return false;
857         }
858
859         /* initialize the control hooks */
860         init_service_op_table();
861
862         if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
863             StrCaseCmp(rpcsrv_type, "daemon") == 0) {
864                 NTSTATUS status;
865
866                 status = rpc_ep_setup_register(ep_ctx->ev_ctx,
867                                           ep_ctx->msg_ctx,
868                                           &ndr_table_svcctl,
869                                           "svcctl",
870                                           0);
871                 if (!NT_STATUS_IS_OK(status)) {
872                         return false;
873                 }
874         }
875
876         return true;
877 }
878
879 static bool svcctl_shutdown_cb(void *ptr)
880 {
881         const char *rpcsrv_type;
882
883         rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
884                                            "rpc_server",
885                                            "epmapper",
886                                            "none");
887         shutdown_service_op_table();
888
889         if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
890             StrCaseCmp(rpcsrv_type, "daemon") == 0) {
891                 NTSTATUS status;
892
893                 status = _rpc_ep_unregister(&ndr_table_svcctl);
894                 if (!NT_STATUS_IS_OK(status)) {
895                         return false;
896                 }
897         }
898
899         return true;
900 }
901
902 static bool ntsvcs_init_cb(void *ptr)
903 {
904         struct dcesrv_ep_context *ep_ctx =
905                 talloc_get_type_abort(ptr, struct dcesrv_ep_context);
906         const char *rpcsrv_type;
907
908         rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
909                                            "rpc_server",
910                                            "epmapper",
911                                            "none");
912
913         if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
914             StrCaseCmp(rpcsrv_type, "daemon") == 0) {
915                 NTSTATUS status;
916
917                 status = rpc_ep_setup_register(ep_ctx->ev_ctx,
918                                           ep_ctx->msg_ctx,
919                                           &ndr_table_ntsvcs,
920                                           "ntsvcs",
921                                           0);
922                 if (!NT_STATUS_IS_OK(status)) {
923                         return false;
924                 }
925         }
926
927         return true;
928 }
929
930 static bool ntsvcs_shutdown_cb(void *ptr)
931 {
932         const char *rpcsrv_type;
933
934         rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
935                                            "rpc_server",
936                                            "epmapper",
937                                            "none");
938
939         if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
940             StrCaseCmp(rpcsrv_type, "daemon") == 0) {
941                 NTSTATUS status;
942
943                 status = _rpc_ep_unregister(&ndr_table_ntsvcs);
944                 if (!NT_STATUS_IS_OK(status)) {
945                         return false;
946                 }
947         }
948
949         return true;
950 }
951
952 static bool eventlog_init_cb(void *ptr)
953 {
954         struct dcesrv_ep_context *ep_ctx =
955                 talloc_get_type_abort(ptr, struct dcesrv_ep_context);
956         const char *rpcsrv_type;
957         bool ok;
958
959         rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
960                                            "rpc_server",
961                                            "epmapper",
962                                            "none");
963
964         ok = eventlog_init_winreg(ep_ctx->msg_ctx);
965         if (!ok) {
966                 return false;
967         }
968
969         if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
970             StrCaseCmp(rpcsrv_type, "daemon") == 0) {
971                 NTSTATUS status;
972
973                 status =rpc_ep_setup_register(ep_ctx->ev_ctx,
974                                          ep_ctx->msg_ctx,
975                                          &ndr_table_eventlog,
976                                          "eventlog",
977                                          0);
978                 if (!NT_STATUS_IS_OK(status)) {
979                         return false;
980                 }
981         }
982
983         return true;
984 }
985
986 static bool eventlog_shutdown_cb(void *ptr)
987 {
988         const char *rpcsrv_type;
989
990         rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
991                                            "rpc_server",
992                                            "epmapper",
993                                            "none");
994
995         if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
996             StrCaseCmp(rpcsrv_type, "daemon") == 0) {
997                 NTSTATUS status;
998
999                 status = _rpc_ep_unregister(&ndr_table_eventlog);
1000                 if (!NT_STATUS_IS_OK(status)) {
1001                         return false;
1002                 }
1003         }
1004
1005         return true;
1006 }
1007
1008 static bool initshutdown_init_cb(void *ptr)
1009 {
1010         struct dcesrv_ep_context *ep_ctx =
1011                 talloc_get_type_abort(ptr, struct dcesrv_ep_context);
1012         const char *rpcsrv_type;
1013
1014         rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
1015                                            "rpc_server",
1016                                            "epmapper",
1017                                            "none");
1018
1019         if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
1020             StrCaseCmp(rpcsrv_type, "daemon") == 0) {
1021                 NTSTATUS status;
1022
1023                 status = rpc_ep_setup_register(ep_ctx->ev_ctx,
1024                                           ep_ctx->msg_ctx,
1025                                           &ndr_table_initshutdown,
1026                                           "initshutdown",
1027                                           0);
1028                 if (!NT_STATUS_IS_OK(status)) {
1029                         return false;
1030                 }
1031         }
1032
1033         return true;
1034 }
1035
1036 static bool initshutdown_shutdown_cb(void *ptr)
1037 {
1038         const char *rpcsrv_type;
1039
1040         rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
1041                                            "rpc_server",
1042                                            "epmapper",
1043                                            "none");
1044
1045         if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
1046             StrCaseCmp(rpcsrv_type, "daemon") == 0) {
1047                 NTSTATUS status;
1048
1049                 status = _rpc_ep_unregister(&ndr_table_initshutdown);
1050                 if (!NT_STATUS_IS_OK(status)) {
1051                         return false;
1052                 }
1053         }
1054
1055         return true;
1056 }
1057
1058 #ifdef DEVELOPER
1059 static bool rpcecho_init_cb(void *ptr) {
1060         struct dcesrv_ep_context *ep_ctx =
1061                 talloc_get_type_abort(ptr, struct dcesrv_ep_context);
1062         const char *rpcsrv_type;
1063         uint16_t port;
1064
1065         rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
1066                                            "rpc_server",
1067                                            "epmapper",
1068                                            "none");
1069
1070         if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
1071             StrCaseCmp(rpcsrv_type, "daemon") == 0) {
1072                 NTSTATUS status;
1073
1074                 port = _open_sockets(ep_ctx->ev_ctx,
1075                                      ep_ctx->msg_ctx,
1076                                      ndr_table_rpcecho.syntax_id,
1077                                      0);
1078                 if (port == 0) {
1079                         return false;
1080                 }
1081
1082                 status = rpc_ep_setup_register(ep_ctx->ev_ctx,
1083                                           ep_ctx->msg_ctx,
1084                                           &ndr_table_rpcecho,
1085                                           "rpcecho",
1086                                           port);
1087                 if (!NT_STATUS_IS_OK(status)) {
1088                         return false;
1089                 }
1090         }
1091
1092         return true;
1093 }
1094
1095 static bool rpcecho_shutdown_cb(void *ptr)
1096 {
1097         const char *rpcsrv_type;
1098
1099         rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
1100                                            "rpc_server",
1101                                            "epmapper",
1102                                            "none");
1103
1104         if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
1105             StrCaseCmp(rpcsrv_type, "daemon") == 0) {
1106                 NTSTATUS status;
1107
1108                 status = _rpc_ep_unregister(&ndr_table_rpcecho);
1109                 if (!NT_STATUS_IS_OK(status)) {
1110                         return false;
1111                 }
1112         }
1113
1114         return true;
1115 }
1116 #endif
1117
1118 static bool netdfs_init_cb(void *ptr)
1119 {
1120         struct dcesrv_ep_context *ep_ctx =
1121                 talloc_get_type_abort(ptr, struct dcesrv_ep_context);
1122         struct ndr_syntax_id abstract_syntax = ndr_table_netdfs.syntax_id;
1123         const char *pipe_name = "netdfs";
1124         const char *rpcsrv_type;
1125         uint16_t port;
1126
1127         rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
1128                                            "rpc_server",
1129                                            "epmapper",
1130                                            "none");
1131         if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
1132             StrCaseCmp(rpcsrv_type, "daemon") == 0) {
1133                 NTSTATUS status;
1134                 bool ok;
1135
1136                 ok = setup_dcerpc_ncalrpc_socket(ep_ctx->ev_ctx,
1137                                                  ep_ctx->msg_ctx,
1138                                                  abstract_syntax,
1139                                                  pipe_name);
1140                 if (!ok) {
1141                         return false;
1142                 }
1143
1144                 port = _open_sockets(ep_ctx->ev_ctx,
1145                                      ep_ctx->msg_ctx,
1146                                      abstract_syntax,
1147                                      0);
1148                 if (port == 0) {
1149                         return false;
1150                 }
1151
1152                 status = rpc_ep_setup_register(ep_ctx->ev_ctx,
1153                                           ep_ctx->msg_ctx,
1154                                           &ndr_table_netdfs,
1155                                           pipe_name,
1156                                           port);
1157                 if (!NT_STATUS_IS_OK(status)) {
1158                         return false;
1159                 }
1160         }
1161
1162         return true;
1163 }
1164
1165 static bool netdfs_shutdown_cb(void *ptr) {
1166         const char *rpcsrv_type;
1167
1168         rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
1169                                            "rpc_server",
1170                                            "epmapper",
1171                                            "none");
1172
1173         if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
1174             StrCaseCmp(rpcsrv_type, "daemon") == 0) {
1175                 NTSTATUS status;
1176
1177                 status = _rpc_ep_unregister(&ndr_table_netdfs);
1178                 if (!NT_STATUS_IS_OK(status)) {
1179                         return false;
1180                 }
1181         }
1182
1183         return true;
1184 }
1185
1186 static bool dssetup_init_cb(void *ptr)
1187 {
1188         struct dcesrv_ep_context *ep_ctx =
1189                 talloc_get_type_abort(ptr, struct dcesrv_ep_context);
1190         struct ndr_syntax_id abstract_syntax = ndr_table_dssetup.syntax_id;
1191         const char *pipe_name = "dssetup";
1192         const char *rpcsrv_type;
1193         uint16_t port;
1194
1195         rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
1196                                            "rpc_server",
1197                                            "epmapper",
1198                                            "none");
1199
1200         if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
1201             StrCaseCmp(rpcsrv_type, "daemon") == 0) {
1202                 NTSTATUS status;
1203                 bool ok;
1204
1205                 ok = setup_dcerpc_ncalrpc_socket(ep_ctx->ev_ctx,
1206                                                  ep_ctx->msg_ctx,
1207                                                  abstract_syntax,
1208                                                  pipe_name);
1209                 if (!ok) {
1210                         return false;
1211                 }
1212
1213                 port = _open_sockets(ep_ctx->ev_ctx,
1214                                      ep_ctx->msg_ctx,
1215                                      abstract_syntax,
1216                                      0);
1217                 if (port == 0) {
1218                         return false;
1219                 }
1220
1221                 status = rpc_ep_setup_register(ep_ctx->ev_ctx,
1222                                           ep_ctx->msg_ctx,
1223                                           &ndr_table_dssetup,
1224                                           "dssetup",
1225                                           port);
1226                 if (!NT_STATUS_IS_OK(status)) {
1227                         return false;
1228                 }
1229         }
1230
1231         return true;
1232 }
1233
1234 static bool dssetup_shutdown_cb(void *ptr) {
1235         const char *rpcsrv_type;
1236
1237         rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
1238                                            "rpc_server",
1239                                            "epmapper",
1240                                            "none");
1241
1242         if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
1243             StrCaseCmp(rpcsrv_type, "daemon") == 0) {
1244                 NTSTATUS status;
1245
1246                 status = _rpc_ep_unregister(&ndr_table_dssetup);
1247                 if (!NT_STATUS_IS_OK(status)) {
1248                         return false;
1249                 }
1250         }
1251
1252         return true;
1253 }
1254
1255 static bool wkssvc_init_cb(void *ptr)
1256 {
1257         struct dcesrv_ep_context *ep_ctx =
1258                 talloc_get_type_abort(ptr, struct dcesrv_ep_context);
1259         struct ndr_syntax_id abstract_syntax = ndr_table_wkssvc.syntax_id;
1260         const char *pipe_name = "wkssvc";
1261         const char *rpcsrv_type;
1262         uint16_t port;
1263
1264         rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
1265                                            "rpc_server",
1266                                            "epmapper",
1267                                            "none");
1268         if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
1269             StrCaseCmp(rpcsrv_type, "daemon") == 0) {
1270                 NTSTATUS status;
1271                 bool ok;
1272
1273                 ok = setup_dcerpc_ncalrpc_socket(ep_ctx->ev_ctx,
1274                                                  ep_ctx->msg_ctx,
1275                                                  abstract_syntax,
1276                                                  pipe_name);
1277                 if (!ok) {
1278                         return false;
1279                 }
1280
1281                 port = _open_sockets(ep_ctx->ev_ctx,
1282                                      ep_ctx->msg_ctx,
1283                                      abstract_syntax,
1284                                      0);
1285                 if (port == 0) {
1286                         return false;
1287                 }
1288
1289                 status = rpc_ep_setup_register(ep_ctx->ev_ctx,
1290                                           ep_ctx->msg_ctx,
1291                                           &ndr_table_wkssvc,
1292                                           "wkssvc",
1293                                           port);
1294                 if (!NT_STATUS_IS_OK(status)) {
1295                         return false;
1296                 }
1297         }
1298
1299         return true;
1300 }
1301
1302 static bool wkssvc_shutdown_cb(void *ptr) {
1303         return NT_STATUS_IS_OK(_rpc_ep_unregister(&ndr_table_wkssvc));
1304 }
1305
1306 bool dcesrv_ep_setup(struct tevent_context *ev_ctx,
1307                      struct messaging_context *msg_ctx)
1308 {
1309         struct dcesrv_ep_context *ep_ctx;
1310
1311         struct rpc_srv_callbacks epmapper_cb;
1312
1313         struct rpc_srv_callbacks winreg_cb;
1314         struct rpc_srv_callbacks srvsvc_cb;
1315
1316         struct rpc_srv_callbacks lsarpc_cb;
1317         struct rpc_srv_callbacks samr_cb;
1318         struct rpc_srv_callbacks netlogon_cb;
1319
1320         struct rpc_srv_callbacks spoolss_cb;
1321         struct rpc_srv_callbacks svcctl_cb;
1322         struct rpc_srv_callbacks ntsvcs_cb;
1323         struct rpc_srv_callbacks eventlog_cb;
1324         struct rpc_srv_callbacks initshutdown_cb;
1325         struct rpc_srv_callbacks netdfs_cb;
1326 #ifdef DEVELOPER
1327         struct rpc_srv_callbacks rpcecho_cb;
1328 #endif
1329         struct rpc_srv_callbacks dssetup_cb;
1330         struct rpc_srv_callbacks wkssvc_cb;
1331
1332         const char *rpcsrv_type;
1333
1334         ep_ctx = talloc(ev_ctx, struct dcesrv_ep_context);
1335         if (ep_ctx == NULL) {
1336                 return false;
1337         }
1338
1339         ep_ctx->ev_ctx = ev_ctx;
1340         ep_ctx->msg_ctx = msg_ctx;
1341
1342         /* start endpoint mapper only if enabled */
1343         rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
1344                                            "rpc_server",
1345                                            "epmapper",
1346                                            "none");
1347         if (StrCaseCmp(rpcsrv_type, "embedded") == 0) {
1348                 epmapper_cb.init         = epmapper_init_cb;
1349                 epmapper_cb.shutdown     = epmapper_shutdown_cb;
1350                 epmapper_cb.private_data = ep_ctx;
1351
1352                 if (!NT_STATUS_IS_OK(rpc_epmapper_init(&epmapper_cb))) {
1353                         return false;
1354                 }
1355         }
1356
1357         winreg_cb.init         = winreg_init_cb;
1358         winreg_cb.shutdown     = winreg_shutdown_cb;
1359         winreg_cb.private_data = ep_ctx;
1360         if (!NT_STATUS_IS_OK(rpc_winreg_init(&winreg_cb))) {
1361                 return false;
1362         }
1363
1364         srvsvc_cb.init         = srvsvc_init_cb;
1365         srvsvc_cb.shutdown     = srvsvc_shutdown_cb;
1366         srvsvc_cb.private_data = ep_ctx;
1367         if (!NT_STATUS_IS_OK(rpc_srvsvc_init(&srvsvc_cb))) {
1368                 return false;
1369         }
1370
1371
1372         lsarpc_cb.init         = lsarpc_init_cb;
1373         lsarpc_cb.shutdown     = lsarpc_shutdown_cb;
1374         lsarpc_cb.private_data = ep_ctx;
1375         if (!NT_STATUS_IS_OK(rpc_lsarpc_init(&lsarpc_cb))) {
1376                 return false;
1377         }
1378
1379         samr_cb.init         = samr_init_cb;
1380         samr_cb.shutdown     = samr_shutdown_cb;
1381         samr_cb.private_data = ep_ctx;
1382         if (!NT_STATUS_IS_OK(rpc_samr_init(&samr_cb))) {
1383                 return false;
1384         }
1385
1386         netlogon_cb.init         = netlogon_init_cb;
1387         netlogon_cb.shutdown     = netlogon_shutdown_cb;
1388         netlogon_cb.private_data = ep_ctx;
1389         if (!NT_STATUS_IS_OK(rpc_netlogon_init(&netlogon_cb))) {
1390                 return false;
1391         }
1392
1393         spoolss_cb.init         = spoolss_init_cb;
1394         spoolss_cb.shutdown     = spoolss_shutdown_cb;
1395         spoolss_cb.private_data = ep_ctx;
1396         if (!NT_STATUS_IS_OK(rpc_spoolss_init(&spoolss_cb))) {
1397                 return false;
1398         }
1399
1400
1401         svcctl_cb.init         = svcctl_init_cb;
1402         svcctl_cb.shutdown     = svcctl_shutdown_cb;
1403         svcctl_cb.private_data = ep_ctx;
1404         if (!NT_STATUS_IS_OK(rpc_svcctl_init(&svcctl_cb))) {
1405                 return false;
1406         }
1407
1408         ntsvcs_cb.init         = ntsvcs_init_cb;
1409         ntsvcs_cb.shutdown     = ntsvcs_shutdown_cb;
1410         ntsvcs_cb.private_data = ep_ctx;
1411         if (!NT_STATUS_IS_OK(rpc_ntsvcs_init(&ntsvcs_cb))) {
1412                 return false;
1413         }
1414
1415         eventlog_cb.init         = eventlog_init_cb;
1416         eventlog_cb.shutdown     = eventlog_shutdown_cb;
1417         eventlog_cb.private_data = ep_ctx;
1418         if (!NT_STATUS_IS_OK(rpc_eventlog_init(&eventlog_cb))) {
1419                 return false;
1420         }
1421
1422         initshutdown_cb.init         = initshutdown_init_cb;
1423         initshutdown_cb.shutdown     = initshutdown_shutdown_cb;
1424         initshutdown_cb.private_data = ep_ctx;
1425         if (!NT_STATUS_IS_OK(rpc_initshutdown_init(&initshutdown_cb))) {
1426                 return false;
1427         }
1428
1429         netdfs_cb.init         = netdfs_init_cb;
1430         netdfs_cb.shutdown     = netdfs_shutdown_cb;
1431         netdfs_cb.private_data = ep_ctx;
1432         if (!NT_STATUS_IS_OK(rpc_netdfs_init(&netdfs_cb))) {
1433                 return false;
1434         }
1435 #ifdef DEVELOPER
1436
1437         rpcecho_cb.init         = rpcecho_init_cb;
1438         rpcecho_cb.shutdown     = rpcecho_shutdown_cb;
1439         rpcecho_cb.private_data = ep_ctx;
1440         if (!NT_STATUS_IS_OK(rpc_rpcecho_init(&rpcecho_cb))) {
1441                 return false;
1442         }
1443 #endif
1444
1445         dssetup_cb.init         = dssetup_init_cb;
1446         dssetup_cb.shutdown     = dssetup_shutdown_cb;
1447         dssetup_cb.private_data = ep_ctx;
1448         if (!NT_STATUS_IS_OK(rpc_dssetup_init(&dssetup_cb))) {
1449                 return false;
1450         }
1451
1452         wkssvc_cb.init         = wkssvc_init_cb;
1453         wkssvc_cb.shutdown     = wkssvc_shutdown_cb;
1454         wkssvc_cb.private_data = ep_ctx;
1455         if (!NT_STATUS_IS_OK(rpc_wkssvc_init(&wkssvc_cb))) {
1456                 return false;
1457         }
1458
1459         return true;
1460 }
1461
1462 /* vim: set ts=8 sw=8 noet cindent ft=c.doxygen: */