]>
Commit | Line | Data |
---|---|---|
b684b13b MT |
1 | /* This file is part of the IPFire Firewall. |
2 | * | |
3 | * This program is distributed under the terms of the GNU General Public | |
4 | * Licence. See the file COPYING for details. | |
5 | * | |
6 | */ | |
7 | ||
8 | #include <stdlib.h> | |
9 | #include <stdio.h> | |
10 | #include <string.h> | |
11 | #include <unistd.h> | |
12 | #include <sys/types.h> | |
13 | #include <fcntl.h> | |
14 | #include "setuid.h" | |
15 | ||
16 | int main(int argc, char *argv[]) { | |
17 | ||
18 | int fd = -1; | |
19 | int enable = 0; | |
20 | ||
21 | if (!(initsetuid())) | |
22 | exit(1); | |
23 | ||
24 | if (argc < 2) { | |
cfd19520 | 25 | fprintf(stderr, "\nNo argument given.\n\nqosctrl (start|stop|restart|status|generate)\n\n"); |
b684b13b MT |
26 | exit(1); |
27 | } | |
28 | ||
7ccede9b | 29 | safe_system("chmod 755 /var/ipfire/qos/bin/qos.sh 2>&1 >/dev/null"); |
a7fb5630 MT |
30 | if (strcmp(argv[1], "start") == 0) { |
31 | if ((fd = open("/var/ipfire/qos/bin/qos.sh", O_RDONLY)) != -1) | |
32 | { | |
33 | close(fd); | |
34 | enable = 1; | |
b684b13b | 35 | } |
a7fb5630 MT |
36 | if (enable) |
37 | { | |
38 | safe_system("/var/ipfire/qos/bin/qos.sh start"); | |
39 | } | |
40 | } else if (strcmp(argv[1], "stop") == 0) { | |
41 | safe_system("/var/ipfire/qos/bin/qos.sh clear"); | |
42 | } else if (strcmp(argv[1], "status") == 0) { | |
43 | safe_system("/var/ipfire/qos/bin/qos.sh status"); | |
44 | } else if (strcmp(argv[1], "restart") == 0) { | |
45 | safe_system("/var/ipfire/qos/bin/qos.sh restart"); | |
cfd19520 | 46 | } else if (strcmp(argv[1], "generate") == 0) { |
e8babc92 | 47 | safe_system("/usr/bin/perl /var/ipfire/qos/bin/makeqosscripts.pl > /var/ipfire/qos/bin/qos.sh"); |
a7fb5630 | 48 | } else { |
cfd19520 | 49 | fprintf(stderr, "\nBad argument given.\n\nqosctrl (start|stop|restart|status|generate)\n\n"); |
a7fb5630 MT |
50 | exit(1); |
51 | } | |
b684b13b MT |
52 | |
53 | return 0; | |
54 | } |