WHATSNEW: Start release notes for Samba 3.6.18.
[Samba.git] / source4 / rpc_server / service_rpc.c
blobdfe25b75c661a04d17faed9a7130f58d1bb4ed6e
1 /*
2 Unix SMB/CIFS implementation.
4 smbd-specific dcerpc server code
6 Copyright (C) Andrew Tridgell 2003-2005
7 Copyright (C) Stefan (metze) Metzmacher 2004-2005
8 Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2004,2007
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 3 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program. If not, see <http://www.gnu.org/licenses/>.
24 #include "includes.h"
25 #include "librpc/gen_ndr/ndr_dcerpc.h"
26 #include "auth/auth.h"
27 #include "../lib/util/dlinklist.h"
28 #include "rpc_server/dcerpc_server.h"
29 #include "rpc_server/dcerpc_server_proto.h"
30 #include "system/filesys.h"
31 #include "lib/messaging/irpc.h"
32 #include "system/network.h"
33 #include "lib/socket/netif.h"
34 #include "param/param.h"
35 #include "../lib/tsocket/tsocket.h"
36 #include "librpc/rpc/dcerpc_proto.h"
37 #include "../lib/util/tevent_ntstatus.h"
38 #include "libcli/raw/smb.h"
39 #include "../libcli/named_pipe_auth/npa_tstream.h"
40 #include "smbd/process_model.h"
44 open the dcerpc server sockets
46 static void dcesrv_task_init(struct task_server *task)
48 NTSTATUS status;
49 struct dcesrv_context *dce_ctx;
50 struct dcesrv_endpoint *e;
51 const struct model_ops *model_ops;
53 dcerpc_server_init(task->lp_ctx);
55 task_server_set_title(task, "task[dcesrv]");
57 /* run the rpc server as a single process to allow for shard
58 * handles, and sharing of ldb contexts */
59 model_ops = process_model_startup("single");
60 if (!model_ops) goto failed;
62 status = dcesrv_init_context(task->event_ctx,
63 task->lp_ctx,
64 lpcfg_dcerpc_endpoint_servers(task->lp_ctx),
65 &dce_ctx);
66 if (!NT_STATUS_IS_OK(status)) goto failed;
68 /* Make sure the directory for NCALRPC exists */
69 if (!directory_exist(lpcfg_ncalrpc_dir(task->lp_ctx))) {
70 mkdir(lpcfg_ncalrpc_dir(task->lp_ctx), 0755);
73 for (e=dce_ctx->endpoint_list;e;e=e->next) {
74 status = dcesrv_add_ep(dce_ctx, task->lp_ctx, e, task->event_ctx, model_ops);
75 if (!NT_STATUS_IS_OK(status)) goto failed;
78 return;
79 failed:
80 task_server_terminate(task, "Failed to startup dcerpc server task", true);
83 NTSTATUS server_service_rpc_init(void)
85 return register_server_service("rpc", dcesrv_task_init);