Alte Initscripts entfernt...
[people/pmueller/ipfire-2.x.git] / src / misc-progs / restartntpd.c
CommitLineData
cd1a2927
MT
1/* Ipcop helper program - restartntpd\r
2 *\r
3 * Starts or stops the ntpd daemon\r
4 *\r
5 * (c) Darren Critchley 2003\r
6 * \r
7 * $Id: restartntpd.c,v 1.5 2003/12/19 14:29:09 riddles Exp $\r
8 * \r
9 */\r
10 \r
11#include <stdio.h>\r
12#include <string.h>\r
13#include <unistd.h>\r
14#include <stdlib.h>\r
15#include <sys/types.h>\r
16#include <fcntl.h>\r
17#include "setuid.h"\r
18\r
19\r
20int main(void)\r
21{\r
22 int fd = -1;\r
23 int enable = 0;\r
24\r
25 if (!(initsetuid()))\r
26 exit(1);\r
27 \r
28 safe_system("/bin/killall ntpd 2> /dev/null");\r
29 sleep(3);\r
30\r
31 if ((fd = open(CONFIG_ROOT "/time/allowclients", O_RDONLY)) != -1)\r
32 {\r
33 close(fd);\r
34 enable = 1;\r
35 }\r
36\r
37 if (enable)\r
38 {\r
39 safe_system("/usr/bin/ntpd -Ap /var/run/ntpd.pid -u ntp:ntp");\r
40 }\r
41 return 0;\r
42}\r