]> git.ipfire.org Git - ipfire-2.x.git/blame - src/misc-progs/getconntracktable.c
misc-progs: Sync STRING_SIZE.
[ipfire-2.x.git] / src / misc-progs / getconntracktable.c
CommitLineData
75bc929e
MT
1/* IPFire helper program - getconntracktable\r
2 *\r
3 * This program is distributed under the terms of the GNU General Public\r
4 * Licence. See the file COPYING for details.\r
5 *\r
6 * The kernel's connection tracking table is not readable by\r
7 * non-root users. So this helper will just read and output it.\r
8 */\r
9\r
10#include <stdio.h>\r
11#include <stdlib.h>\r
12#include "setuid.h"\r
13\r
14int main(void) {\r
15 if (!(initsetuid()))\r
16 exit(1);\r
17\r
18 FILE *fp = fopen("/proc/net/nf_conntrack", "r");\r
19 if (fp == NULL) {\r
20 exit(1);\r
21 }\r
22\r
23 /* Read content line by line and write it to stdout. */\r
24 char linebuf[STRING_SIZE];\r
25 while (fgets(linebuf, STRING_SIZE, fp)) {\r
26 printf("%s", linebuf);\r
27 }\r
28\r
29 fclose(fp);\r
30 return 0;\r
31}\r