-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshow_rule.c
More file actions
55 lines (39 loc) · 981 Bytes
/
show_rule.c
File metadata and controls
55 lines (39 loc) · 981 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
int main (int argc, char *argv[]) {
printf("Content-type: text/html\n\n");
printf("<html>\n");
printf("<body>\n");
printf("<h1>Content of rule</h1>\n");
char *data = malloc(200);
data = getenv("QUERY_STRING");
printf("%s<br><br>", data);
const char delim[2] = "=";
char* token = strtok(data, delim);
token = strtok(NULL, delim);
int c;
FILE *file;
char *kat = "/usr/lib/nagios/plugins/firewall/";
char buf[256];
snprintf(buf, sizeof buf, "%s%s", kat, token);
FILE * fp;
char * line = NULL;
size_t len = 0;
ssize_t read;
fp = fopen(buf, "r");
if (fp == NULL)
exit(EXIT_FAILURE);
printf("<pre>");
while ((read = getline(&line, &len, fp)) != -1) {
printf("%s<br>", line);
}
printf("</pre>");
fclose(fp);
if (line)
free(line);
printf("</body>\n");
printf("</html>\n");
return 0;
}