aboutsummaryrefslogtreecommitdiffstats
path: root/src/firemon/seccomp.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/firemon/seccomp.c')
-rw-r--r--src/firemon/seccomp.c69
1 files changed, 69 insertions, 0 deletions
diff --git a/src/firemon/seccomp.c b/src/firemon/seccomp.c
new file mode 100644
index 000000000..4ffc93f2e
--- /dev/null
+++ b/src/firemon/seccomp.c
@@ -0,0 +1,69 @@
1/*
2 * Copyright (C) 2014, 2015 netblue30 (netblue30@yahoo.com)
3 *
4 * This file is part of firejail project
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19*/
20#include "firemon.h"
21
22#define MAXBUF 4098
23static void print_seccomp(int pid) {
24 char *file;
25 if (asprintf(&file, "/proc/%d/status", pid) == -1) {
26 errExit("asprintf");
27 exit(1);
28 }
29
30 FILE *fp = fopen(file, "r");
31 if (!fp) {
32 printf(" Error: cannot open %s\n", file);
33 free(file);
34 return;
35 }
36
37 char buf[MAXBUF];
38 while (fgets(buf, MAXBUF, fp)) {
39 if (strncmp(buf, "Seccomp:", 8) == 0) {
40 printf(" %s", buf);
41 fflush(0);
42 fclose(fp);
43 free(file);
44 return;
45 }
46 }
47 fclose(fp);
48 free(file);
49}
50
51void seccomp(pid_t pid) {
52 if (getuid() == 0)
53 firemon_drop_privs();
54
55 pid_read(pid); // include all processes
56
57 // print processes
58 int i;
59 for (i = 0; i < max_pids; i++) {
60 if (pids[i].level == 1) {
61 pid_print_list(i, 0);
62 int child = find_child(i);
63 if (child != -1)
64 print_seccomp(child);
65 }
66 }
67 printf("\n");
68}
69