source: trunk/server/source3/web/startstop.c@ 920

Last change on this file since 920 was 745, checked in by Silvan Scherrer, 13 years ago

Samba Server: updated trunk to 3.6.0

File size: 3.7 KB
Line 
1/*
2 Unix SMB/CIFS implementation.
3 start/stop nmbd and smbd
4 Copyright (C) Andrew Tridgell 1998
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18*/
19
20#include "includes.h"
21
22#ifdef __OS2__
23 /* fork() in klibc on OS/2 ends all children when parent
24 is closed, therefore we use spawn() */
25#include "process.h"
26#define SWAT_HELPER(WHAT, WHO) \
27 asprintf(&binfile, "%s/swathelp.cmd", getcwd(NULL, _MAX_PATH)); \
28 int rc; \
29 rc=spawnl(P_NOWAIT, binfile, binfile, #WHAT, #WHO, NULL);
30#endif
31
32#include "web/swat_proto.h"
33#include "dynconfig.h"
34
35
36/** Startup smbd from web interface. */
37void start_smbd(void)
38{
39 char *binfile = NULL;
40
41 if (geteuid() != 0) {
42 return;
43 }
44
45#ifdef __OS2__
46 /* fork() in klibc on OS/2 ends all children when parent
47 is closed, therefore we use spawn() */
48 SWAT_HELPER(start, smbd)
49#else
50 if (fork()) {
51 return;
52 }
53
54 if (asprintf(&binfile, "%s/smbd", get_dyn_SBINDIR()) > 0) {
55 become_daemon(true, false, false);
56 execl(binfile, binfile, "-D", NULL);
57 }
58 exit(0);
59#endif
60}
61
62/* startup nmbd */
63void start_nmbd(void)
64{
65 char *binfile = NULL;
66
67 if (geteuid() != 0) {
68 return;
69 }
70
71#ifdef __OS2__
72 /* fork() in klibc on OS/2 ends all children when parent
73 is closed, therefore we use spawn() */
74 SWAT_HELPER(start, nmbd)
75#else
76 if (fork()) {
77 return;
78 }
79
80 if (asprintf(&binfile, "%s/nmbd", get_dyn_SBINDIR()) > 0) {
81 become_daemon(true, false, false);
82 execl(binfile, binfile, "-D", NULL);
83 }
84 exit(0);
85#endif
86}
87
88/** Startup winbindd from web interface. */
89void start_winbindd(void)
90{
91 char *binfile = NULL;
92
93 if (geteuid() != 0) {
94 return;
95 }
96
97#ifdef __OS2__
98 /* fork() in klibc on OS/2 ends all children when parent
99 is closed, therefore we use spawn() */
100 SWAT_HELPER(start, winbindd)
101#else