]>
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) { | |
25 | fprintf(stderr, "\nNo argument given.\n\nqosctrl (start|clear|status)\n\n"); | |
26 | exit(1); | |
27 | } | |
28 | ||
29 | ||
30 | if (strcmp(argv[1], "start") == 0) { | |
31 | if ((fd = open("/var/ipfire/qos/enable", O_RDONLY)) != -1) | |
32 | { | |
33 | close(fd); | |
34 | enable = 1; | |
35 | } | |
36 | ||
37 | if (enable) | |
38 | { | |
39 | safe_system("/var/ipfire/qos/bin/qos.sh start"); | |
40 | } | |
41 | } else if (strcmp(argv[1], "clear") == 0) { | |
42 | safe_system("/var/ipfire/qos/bin/qos.sh clear"); | |
43 | } else if (strcmp(argv[1], "status") == 0) { | |
44 | safe_system("/var/ipfire/qos/bin/qos.sh status"); | |
45 | } else { | |
46 | fprintf(stderr, "\nBad argument given.\n\nqosctrl (start|clear|status)\n\n"); | |
47 | exit(1); | |
48 | } | |
49 | ||
50 | return 0; | |
51 | } |