source: vendor/current/source4/winbind/winbindd.c

Last change on this file was 988, checked in by Silvan Scherrer, 9 years ago

Samba Server: update vendor to version 4.4.3

File size: 2.8 KB
Line 
1/*
2 Unix SMB/CIFS implementation.
3
4 run s3 winbindd server within Samba4
5
6 Copyright (C) Andrew Tridgell 2011
7 Copyright (C) Andrew Bartlett 2014
8
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.
13
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.
18
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/>.
21*/
22
23#include "includes.h"
24#include "talloc.h"
25#include "tevent.h"
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 "file_server/file_server.h"
31#include "dynconfig.h"
32#include "nsswitch/winbind_client.h"
33
34/*
35 called if winbindd exits
36 */
37static void winbindd_done(struct tevent_req *subreq)
38{
39 struct task_server *task =
40 tevent_req_callback_data(subreq,
41 struct task_server);
42 int sys_errno;
43 int ret;
44
45 ret = samba_runcmd_recv(subreq, &sys_errno);
46 if (ret != 0) {
47 DEBUG(0,("winbindd daemon died with exit status %d\n", sys_errno));
48 } else {
49 DEBUG(0,("winbindd daemon exited normally\n"));
50 }
51 task_server_terminate(task, "winbindd child process exited", true);
52}
53
54
55/*
56 startup a copy of winbindd as a child daemon
57*/
58static void winbindd_task_init(struct task_server *task)
59{
60 struct tevent_req *subreq;
61 const char *winbindd_path;
62 const char *winbindd_cmd[2] = { NULL, NULL };
63
64 task_server_set_title(task, "task[winbindd_parent]");
65
66 winbindd_path = talloc_asprintf(task, "%s/winbindd", dyn_SBINDIR);
67 winbindd_cmd[0] = winbindd_path;
68
69 /* start it as a child process */
70 subreq = samba_runcmd_send(task, task->event_ctx, timeval_zero(), 1, 0,
71 winbindd_cmd,
72 "-D",
73 "--option=server role check:inhibit=yes",
74 "--foreground",
75 debug_get_output_is_stdout()?"--stdout":NULL,
76 NULL);
77 if (subreq == NULL) {
78 DEBUG(0, ("Failed to start winbindd as child daemon\n"));
79 task_server_terminate(task, "Failed to startup winbindd task", true);
80 return;
81 }
82
83 tevent_req_set_callback(subreq, winbindd_done, task);
84
85 DEBUG(5,("Started winbindd as a child daemon\n"));
86}
87
88/* called at winbindd startup - register ourselves as a server service */
89NTSTATUS server_service_winbindd_init(void);
90
91NTSTATUS server_service_winbindd_init(void)
92{
93 NTSTATUS status = register_server_service("winbindd", winbindd_task_init);
94 if (!NT_STATUS_IS_OK(status)) {
95 return status;
96 }
97 return register_server_service("winbind", winbindd_task_init);
98}
Note: See TracBrowser for help on using the repository browser.