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