ctdbd_conn: let register_with_ctdbd() call CTDB_CONTROL_REGISTER_SRVID just once
[Samba.git] / source3 / rpc_server / rpcd_classic.c
blob9766d0a760b6063c69616cf3e0c5461810ee3233
1 /*
2 * Unix SMB/CIFS implementation.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, see <http://www.gnu.org/licenses/>.
18 #include "includes.h"
19 #include "rpc_worker.h"
20 #include "librpc/gen_ndr/ndr_srvsvc.h"
21 #include "librpc/gen_ndr/ndr_srvsvc_scompat.h"
22 #include "librpc/gen_ndr/ndr_dfs.h"
23 #include "librpc/gen_ndr/ndr_dfs_scompat.h"
24 #include "librpc/gen_ndr/ndr_wkssvc.h"
25 #include "librpc/gen_ndr/ndr_wkssvc_scompat.h"
26 #include "librpc/gen_ndr/ndr_svcctl.h"
27 #include "librpc/gen_ndr/ndr_svcctl_scompat.h"
28 #include "librpc/gen_ndr/ndr_ntsvcs.h"
29 #include "librpc/gen_ndr/ndr_ntsvcs_scompat.h"
30 #include "librpc/gen_ndr/ndr_eventlog.h"
31 #include "librpc/gen_ndr/ndr_eventlog_scompat.h"
32 #include "librpc/gen_ndr/ndr_initshutdown.h"
33 #include "librpc/gen_ndr/ndr_initshutdown_scompat.h"
34 #include "source3/include/secrets.h"
35 #include "locking/share_mode_lock.h"
36 #include "source3/smbd/proto.h"
38 static size_t classic_interfaces(
39 const struct ndr_interface_table ***pifaces,
40 void *private_data)
42 static const struct ndr_interface_table *ifaces[] = {
43 &ndr_table_srvsvc,
44 &ndr_table_netdfs,
45 &ndr_table_initshutdown,
46 &ndr_table_svcctl,
47 &ndr_table_ntsvcs,
48 &ndr_table_eventlog,
50 * This last item is truncated from the list by the
51 * num_ifaces -= 1 below. Take care when adding new
52 * services.
54 &ndr_table_wkssvc,
56 size_t num_ifaces = ARRAY_SIZE(ifaces);
58 switch(lp_server_role()) {
59 case ROLE_ACTIVE_DIRECTORY_DC:
61 * On the AD DC wkssvc is provided by the 'samba'
62 * binary from source4/
64 num_ifaces -= 1;
65 break;
66 default:
67 break;
70 *pifaces = ifaces;
71 return num_ifaces;
75 static NTSTATUS classic_servers(
76 struct dcesrv_context *dce_ctx,
77 const struct dcesrv_endpoint_server ***_ep_servers,
78 size_t *_num_ep_servers,
79 void *private_data)
81 static const struct dcesrv_endpoint_server *ep_servers[7] = { NULL };
82 size_t num_servers = ARRAY_SIZE(ep_servers);
83 NTSTATUS status;
84 bool ok;
86 ep_servers[0] = srvsvc_get_ep_server();
87 ep_servers[1] = netdfs_get_ep_server();
88 ep_servers[2] = initshutdown_get_ep_server();
89 ep_servers[3] = svcctl_get_ep_server();
90 ep_servers[4] = ntsvcs_get_ep_server();
91 ep_servers[5] = eventlog_get_ep_server();
92 ep_servers[6] = wkssvc_get_ep_server();
94 switch(lp_server_role()) {
95 case ROLE_ACTIVE_DIRECTORY_DC:
97 * On the AD DC wkssvc is provided by the 'samba'
98 * binary from source4/
100 num_servers -= 1;
101 break;
102 default:
103 break;
106 ok = secrets_init();
107 if (!ok) {
108 DBG_ERR("secrets_init() failed\n");
109 exit(1);
112 ok = locking_init();
113 if (!ok) {
114 DBG_ERR("locking_init() failed\n");
115 exit(1);
118 lp_load_with_shares(get_dyn_CONFIGFILE());
120 mangle_reset_cache();
122 status = dcesrv_register_default_auth_types_machine_principal(dce_ctx);
123 if (!NT_STATUS_IS_OK(status)) {
124 return status;
127 *_ep_servers = ep_servers;
128 *_num_ep_servers = num_servers;
129 return NT_STATUS_OK;
132 int main(int argc, const char *argv[])
134 return rpc_worker_main(
135 argc,
136 argv,
137 "rpcd_classic",
140 classic_interfaces,
141 classic_servers,
142 NULL);