2 Unix SMB/CIFS implementation.
4 run s3 winbindd server within Samba4
6 Copyright (C) Andrew Tridgell 2011
7 Copyright (C) Andrew Bartlett 2014
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>.
26 #include "system/filesys.h"
27 #include "lib/param/param.h"
28 #include "source4/smbd/service.h"
29 #include "source4/smbd/process_model.h"
30 #include "dynconfig.h"
31 #include "nsswitch/winbind_client.h"
34 called if winbindd exits
36 static void winbindd_done(struct tevent_req *subreq)
38 struct task_server *task =
39 tevent_req_callback_data(subreq,
44 ret = samba_runcmd_recv(subreq, &sys_errno);
46 DEBUG(0,("winbindd daemon died with exit status %d\n", sys_errno));
48 DEBUG(0,("winbindd daemon exited normally\n"));
50 task_server_terminate(task, "winbindd child process exited", true);
55 startup a copy of winbindd as a child daemon
57 static void winbindd_task_init(struct task_server *task)
59 struct tevent_req *subreq;
60 const char *winbindd_path;
61 const char *winbindd_cmd[2] = { NULL, NULL };
63 task_server_set_title(task, "task[winbindd_parent]");
65 winbindd_path = talloc_asprintf(task, "%s/winbindd", dyn_SBINDIR);
66 winbindd_cmd[0] = winbindd_path;
68 /* start it as a child process */
69 subreq = samba_runcmd_send(task, task->event_ctx, timeval_zero(), 1, 0,
72 "--option=server role check:inhibit=yes",
74 debug_get_output_is_stdout()?"--stdout":NULL,
77 DEBUG(0, ("Failed to start winbindd as child daemon\n"));
78 task_server_terminate(task, "Failed to startup winbindd task", true);
82 tevent_req_set_callback(subreq, winbindd_done, task);
84 DEBUG(5,("Started winbindd as a child daemon\n"));
87 /* called at winbindd startup - register ourselves as a server service */
88 NTSTATUS server_service_winbindd_init(TALLOC_CTX *);
90 NTSTATUS server_service_winbindd_init(TALLOC_CTX *ctx)
92 static const struct service_details details = {
93 .inhibit_fork_on_accept = true,
94 .inhibit_pre_fork = true,
97 NTSTATUS status = register_server_service(ctx, "winbindd",
98 winbindd_task_init, &details);
99 if (!NT_STATUS_IS_OK(status)) {
102 return register_server_service(ctx, "winbind", winbindd_task_init,