]> git.ipfire.org Git - ipfire-2.x.git/blob - src/misc-progs/restartntpd.c
Connections.cgi neu geschrieben.
[ipfire-2.x.git] / src / misc-progs / restartntpd.c
1 /* IPFire helper program - restartntpd
2 *
3 * Starts or stops the ntpd daemon
4 *
5 */
6
7 #include <stdio.h>
8 #include <string.h>
9 #include <unistd.h>
10 #include <stdlib.h>
11 #include <sys/types.h>
12 #include <fcntl.h>
13 #include "setuid.h"
14
15
16 int main(void)
17 {
18 int fd = -1;
19 int enable = 0;
20
21 if (!(initsetuid()))
22 exit(1);
23
24 safe_system("/etc/rc.d/init.d/ntp stop 2>&1 >/dev/null");
25 sleep(3);
26
27 if ((fd = open(CONFIG_ROOT "/time/allowclients", O_RDONLY)) != -1)
28 {
29 close(fd);
30 enable = 1;
31 }
32
33 if (enable)
34 {
35 safe_system("/etc/rc.d/init.d/ntp start 2>&1 >/dev/null");
36 }
37 return 0;
38 }