diff options
-rw-r--r-- | src/firemon/cgroup.c | 63 | ||||
-rw-r--r-- | src/firemon/firemon.c | 18 | ||||
-rw-r--r-- | src/firemon/x11.c | 55 | ||||
-rw-r--r-- | src/man/firemon.txt | 7 |
4 files changed, 1 insertions, 142 deletions
diff --git a/src/firemon/cgroup.c b/src/firemon/cgroup.c deleted file mode 100644 index 8dbf85824..000000000 --- a/src/firemon/cgroup.c +++ /dev/null | |||
@@ -1,63 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2014-2018 Firejail Authors | ||
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 | #define MAXBUF 4098 | ||
22 | |||
23 | static void print_cgroup(int pid) { | ||
24 | char *file; | ||
25 | if (asprintf(&file, "/proc/%d/cgroup", 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 | if (fgets(buf, MAXBUF, fp)) { | ||
39 | printf(" %s", buf); | ||
40 | fflush(0); | ||
41 | } | ||
42 | |||
43 | fclose(fp); | ||
44 | free(file); | ||
45 | } | ||
46 | |||
47 | void cgroup(pid_t pid, int print_procs) { | ||
48 | pid_read(pid); | ||
49 | |||
50 | // print processes | ||
51 | printf(" cgroup: "); | ||
52 | int i; | ||
53 | for (i = 0; i < max_pids; i++) { | ||
54 | if (pids[i].level == 1) { | ||
55 | if (print_procs || pid == 0) | ||
56 | pid_print_list(i, arg_nowrap); | ||
57 | int child = find_child(i); | ||
58 | if (child != -1) | ||
59 | print_cgroup(child); | ||
60 | } | ||
61 | } | ||
62 | printf("\n"); | ||
63 | } | ||
diff --git a/src/firemon/firemon.c b/src/firemon/firemon.c index 147b5073b..6124310b1 100644 --- a/src/firemon/firemon.c +++ b/src/firemon/firemon.c | |||
@@ -33,8 +33,6 @@ static int arg_interface = 0; | |||
33 | static int arg_seccomp = 0; | 33 | static int arg_seccomp = 0; |
34 | static int arg_caps = 0; | 34 | static int arg_caps = 0; |
35 | static int arg_cpu = 0; | 35 | static int arg_cpu = 0; |
36 | static int arg_cgroup = 0; | ||
37 | static int arg_x11 = 0; | ||
38 | static int arg_top = 0; | 36 | static int arg_top = 0; |
39 | static int arg_list = 0; | 37 | static int arg_list = 0; |
40 | static int arg_netstats = 0; | 38 | static int arg_netstats = 0; |
@@ -159,10 +157,6 @@ int main(int argc, char **argv) { | |||
159 | 157 | ||
160 | 158 | ||
161 | // cumulative options with or without a pid argument | 159 | // cumulative options with or without a pid argument |
162 | else if (strcmp(argv[i], "--x11") == 0) | ||
163 | arg_x11 = 1; | ||
164 | else if (strcmp(argv[i], "--cgroup") == 0) | ||
165 | arg_cgroup = 1; | ||
166 | else if (strcmp(argv[i], "--cpu") == 0) | 160 | else if (strcmp(argv[i], "--cpu") == 0) |
167 | arg_cpu = 1; | 161 | arg_cpu = 1; |
168 | else if (strcmp(argv[i], "--seccomp") == 0) | 162 | else if (strcmp(argv[i], "--seccomp") == 0) |
@@ -250,13 +244,11 @@ int main(int argc, char **argv) { | |||
250 | 244 | ||
251 | // if --name requested without other options, print all data | 245 | // if --name requested without other options, print all data |
252 | if (pid && !arg_cpu && !arg_seccomp && !arg_caps && !arg_apparmor && | 246 | if (pid && !arg_cpu && !arg_seccomp && !arg_caps && !arg_apparmor && |
253 | !arg_cgroup && !arg_x11 && !arg_interface && !arg_route && !arg_arp) { | 247 | !arg_interface && !arg_route && !arg_arp) { |
254 | arg_tree = 1; | 248 | arg_tree = 1; |
255 | arg_cpu = 1; | 249 | arg_cpu = 1; |
256 | arg_seccomp = 1; | 250 | arg_seccomp = 1; |
257 | arg_caps = 1; | 251 | arg_caps = 1; |
258 | arg_cgroup = 1; | ||
259 | arg_x11 = 1; | ||
260 | arg_interface = 1; | 252 | arg_interface = 1; |
261 | arg_route = 1; | 253 | arg_route = 1; |
262 | arg_arp = 1; | 254 | arg_arp = 1; |
@@ -281,14 +273,6 @@ int main(int argc, char **argv) { | |||
281 | apparmor((pid_t) pid, print_procs); | 273 | apparmor((pid_t) pid, print_procs); |
282 | print_procs = 0; | 274 | print_procs = 0; |
283 | } | 275 | } |
284 | if (arg_cgroup) { | ||
285 | cgroup((pid_t) pid, print_procs); | ||
286 | print_procs = 0; | ||
287 | } | ||
288 | if (arg_x11) { | ||
289 | x11((pid_t) pid, print_procs); | ||
290 | print_procs = 0; | ||
291 | } | ||
292 | if (arg_interface && getuid() == 0) { | 276 | if (arg_interface && getuid() == 0) { |
293 | interface((pid_t) pid, print_procs); | 277 | interface((pid_t) pid, print_procs); |
294 | print_procs = 0; | 278 | print_procs = 0; |
diff --git a/src/firemon/x11.c b/src/firemon/x11.c deleted file mode 100644 index 09eb3cd06..000000000 --- a/src/firemon/x11.c +++ /dev/null | |||
@@ -1,55 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2014-2018 Firejail Authors | ||
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 | #include <sys/types.h> | ||
22 | #include <sys/stat.h> | ||
23 | #include <unistd.h> | ||
24 | |||
25 | void x11(pid_t pid, int print_procs) { | ||
26 | pid_read(pid); | ||
27 | |||
28 | // print processes | ||
29 | int i; | ||
30 | for (i = 0; i < max_pids; i++) { | ||
31 | if (pids[i].level == 1) { | ||
32 | if (print_procs || pid == 0) | ||
33 | pid_print_list(i, arg_nowrap); | ||
34 | |||
35 | char *x11file; | ||
36 | // todo: use macro from src/firejail/firejail.h for /run/firejail/x11 directory | ||
37 | if (asprintf(&x11file, "/run/firejail/x11/%d", i) == -1) | ||
38 | errExit("asprintf"); | ||
39 | |||
40 | FILE *fp = fopen(x11file, "r"); | ||
41 | if (!fp) { | ||
42 | free(x11file); | ||
43 | continue; | ||
44 | } | ||
45 | |||
46 | int display; | ||
47 | int rv = fscanf(fp, "%d", &display); | ||
48 | if (rv == 1) | ||
49 | printf(" DISPLAY :%d\n", display); | ||
50 | fclose(fp); | ||
51 | free(x11file); | ||
52 | } | ||
53 | } | ||
54 | printf("\n"); | ||
55 | } | ||
diff --git a/src/man/firemon.txt b/src/man/firemon.txt index bcc1820bf..a83b0e816 100644 --- a/src/man/firemon.txt +++ b/src/man/firemon.txt | |||
@@ -19,9 +19,6 @@ Print ARP table for each sandbox. | |||
19 | \fB\-\-caps | 19 | \fB\-\-caps |
20 | Print capabilities configuration for each sandbox. | 20 | Print capabilities configuration for each sandbox. |
21 | .TP | 21 | .TP |
22 | \fB\-\-cgroup | ||
23 | Print control group information for each sandbox. | ||
24 | .TP | ||
25 | \fB\-\-cpu | 22 | \fB\-\-cpu |
26 | Print CPU affinity for each sandbox. | 23 | Print CPU affinity for each sandbox. |
27 | .TP | 24 | .TP |
@@ -59,10 +56,6 @@ Print a tree of all sandboxed processes. | |||
59 | \fB\-\-version | 56 | \fB\-\-version |
60 | Print program version and exit. | 57 | Print program version and exit. |
61 | 58 | ||
62 | .TP | ||
63 | \fB\-\-x11 | ||
64 | Print X11 display number. | ||
65 | |||
66 | .PP | 59 | .PP |
67 | The format for each listed sandbox entry is as follows: | 60 | The format for each listed sandbox entry is as follows: |
68 | 61 | ||