diff options
author | netblue30 <netblue30@protonmail.com> | 2022-06-13 09:26:37 -0400 |
---|---|---|
committer | netblue30 <netblue30@protonmail.com> | 2022-06-13 09:26:37 -0400 |
commit | 95544a17fac7e5fb2b0eabe3d96305813fc96a1b (patch) | |
tree | ca0259eb8523de487c297f2a14e23f87d512b17d | |
parent | disable cgroup code (diff) | |
download | firejail-95544a17fac7e5fb2b0eabe3d96305813fc96a1b.tar.gz firejail-95544a17fac7e5fb2b0eabe3d96305813fc96a1b.tar.zst firejail-95544a17fac7e5fb2b0eabe3d96305813fc96a1b.zip |
more on disable cgroups
-rw-r--r-- | src/firejail/usage.c | 1 | ||||
-rw-r--r-- | src/firemon/cgroup.c | 63 | ||||
-rw-r--r-- | src/firemon/firemon.c | 10 | ||||
-rw-r--r-- | src/firemon/firemon.h | 3 | ||||
-rw-r--r-- | src/firemon/usage.c | 1 | ||||
-rw-r--r-- | src/man/firejail-profile.txt | 8 | ||||
-rw-r--r-- | src/man/firejail.txt | 15 | ||||
-rw-r--r-- | src/man/firemon.txt | 3 | ||||
-rwxr-xr-x | test/utils/firemon-cgroup.exp | 40 | ||||
-rwxr-xr-x | test/utils/utils.sh | 3 |
10 files changed, 6 insertions, 141 deletions
diff --git a/src/firejail/usage.c b/src/firejail/usage.c index 7a545982b..c379c2ab4 100644 --- a/src/firejail/usage.c +++ b/src/firejail/usage.c | |||
@@ -49,7 +49,6 @@ static char *usage_str = | |||
49 | #ifdef HAVE_FILE_TRANSFER | 49 | #ifdef HAVE_FILE_TRANSFER |
50 | " --cat=name|pid filename - print content of file from sandbox container.\n" | 50 | " --cat=name|pid filename - print content of file from sandbox container.\n" |
51 | #endif | 51 | #endif |
52 | " --cgroup=tasks-file - place the sandbox in the specified control group.\n" | ||
53 | #ifdef HAVE_CHROOT | 52 | #ifdef HAVE_CHROOT |
54 | " --chroot=dirname - chroot into directory.\n" | 53 | " --chroot=dirname - chroot into directory.\n" |
55 | #endif | 54 | #endif |
diff --git a/src/firemon/cgroup.c b/src/firemon/cgroup.c deleted file mode 100644 index 7ef76fa46..000000000 --- a/src/firemon/cgroup.c +++ /dev/null | |||
@@ -1,63 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2014-2022 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_wrap); | ||
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 91406d6a7..4ee319a7e 100644 --- a/src/firemon/firemon.c +++ b/src/firemon/firemon.c | |||
@@ -34,7 +34,6 @@ static int arg_interface = 0; | |||
34 | static int arg_seccomp = 0; | 34 | static int arg_seccomp = 0; |
35 | static int arg_caps = 0; | 35 | static int arg_caps = 0; |
36 | static int arg_cpu = 0; | 36 | static int arg_cpu = 0; |
37 | static int arg_cgroup = 0; | ||
38 | static int arg_x11 = 0; | 37 | static int arg_x11 = 0; |
39 | static int arg_top = 0; | 38 | static int arg_top = 0; |
40 | static int arg_list = 0; | 39 | static int arg_list = 0; |
@@ -173,8 +172,6 @@ int main(int argc, char **argv) { | |||
173 | // cumulative options with or without a pid argument | 172 | // cumulative options with or without a pid argument |
174 | else if (strcmp(argv[i], "--x11") == 0) | 173 | else if (strcmp(argv[i], "--x11") == 0) |
175 | arg_x11 = 1; | 174 | arg_x11 = 1; |
176 | else if (strcmp(argv[i], "--cgroup") == 0) | ||
177 | arg_cgroup = 1; | ||
178 | else if (strcmp(argv[i], "--cpu") == 0) | 175 | else if (strcmp(argv[i], "--cpu") == 0) |
179 | arg_cpu = 1; | 176 | arg_cpu = 1; |
180 | else if (strcmp(argv[i], "--seccomp") == 0) | 177 | else if (strcmp(argv[i], "--seccomp") == 0) |
@@ -264,12 +261,11 @@ int main(int argc, char **argv) { | |||
264 | 261 | ||
265 | // if --name requested without other options, print all data | 262 | // if --name requested without other options, print all data |
266 | if (pid && !arg_cpu && !arg_seccomp && !arg_caps && !arg_apparmor && | 263 | if (pid && !arg_cpu && !arg_seccomp && !arg_caps && !arg_apparmor && |
267 | !arg_cgroup && !arg_x11 && !arg_interface && !arg_route && !arg_arp) { | 264 | !arg_x11 && !arg_interface && !arg_route && !arg_arp) { |
268 | arg_tree = 1; | 265 | arg_tree = 1; |
269 | arg_cpu = 1; | 266 | arg_cpu = 1; |
270 | arg_seccomp = 1; | 267 | arg_seccomp = 1; |
271 | arg_caps = 1; | 268 | arg_caps = 1; |
272 | arg_cgroup = 1; | ||
273 | arg_x11 = 1; | 269 | arg_x11 = 1; |
274 | arg_interface = 1; | 270 | arg_interface = 1; |
275 | arg_route = 1; | 271 | arg_route = 1; |
@@ -295,10 +291,6 @@ int main(int argc, char **argv) { | |||
295 | apparmor((pid_t) pid, print_procs); | 291 | apparmor((pid_t) pid, print_procs); |
296 | print_procs = 0; | 292 | print_procs = 0; |
297 | } | 293 | } |
298 | if (arg_cgroup) { | ||
299 | cgroup((pid_t) pid, print_procs); | ||
300 | print_procs = 0; | ||
301 | } | ||
302 | if (arg_x11) { | 294 | if (arg_x11) { |
303 | x11((pid_t) pid, print_procs); | 295 | x11((pid_t) pid, print_procs); |
304 | print_procs = 0; | 296 | print_procs = 0; |
diff --git a/src/firemon/firemon.h b/src/firemon/firemon.h index 2fa294e8d..d12091217 100644 --- a/src/firemon/firemon.h +++ b/src/firemon/firemon.h | |||
@@ -75,9 +75,6 @@ void seccomp(pid_t pid, int print_procs); | |||
75 | // cpu.c | 75 | // cpu.c |
76 | void cpu(pid_t pid, int print_procs); | 76 | void cpu(pid_t pid, int print_procs); |
77 | 77 | ||
78 | // cgroup.c | ||
79 | void cgroup(pid_t pid, int print_procs); | ||
80 | |||
81 | // tree.c | 78 | // tree.c |
82 | void tree(pid_t pid); | 79 | void tree(pid_t pid); |
83 | 80 | ||
diff --git a/src/firemon/usage.c b/src/firemon/usage.c index c6a664790..a1b6098ef 100644 --- a/src/firemon/usage.c +++ b/src/firemon/usage.c | |||
@@ -29,7 +29,6 @@ static char *help_str = | |||
29 | "\t--apparmor - print AppArmor confinement status for each sandbox.\n\n" | 29 | "\t--apparmor - print AppArmor confinement status for each sandbox.\n\n" |
30 | "\t--arp - print ARP table for each sandbox.\n\n" | 30 | "\t--arp - print ARP table for each sandbox.\n\n" |
31 | "\t--caps - print capabilities configuration for each sandbox.\n\n" | 31 | "\t--caps - print capabilities configuration for each sandbox.\n\n" |
32 | "\t--cgroup - print control group information for each sandbox.\n\n" | ||
33 | "\t--cpu - print CPU affinity for each sandbox.\n\n" | 32 | "\t--cpu - print CPU affinity for each sandbox.\n\n" |
34 | "\t--debug - print debug messages.\n\n" | 33 | "\t--debug - print debug messages.\n\n" |
35 | "\t--help, -? - this help screen.\n\n" | 34 | "\t--help, -? - this help screen.\n\n" |
diff --git a/src/man/firejail-profile.txt b/src/man/firejail-profile.txt index 0fe434fac..5c8b6031d 100644 --- a/src/man/firejail-profile.txt +++ b/src/man/firejail-profile.txt | |||
@@ -683,18 +683,14 @@ ignore dbus-user.talk org.freedesktop.Notifications | |||
683 | .br | 683 | .br |
684 | [...] | 684 | [...] |
685 | #endif | 685 | #endif |
686 | .SH Resource limits, CPU affinity, Control Groups | 686 | .SH Resource limits, CPU affinity |
687 | These profile entries define the limits on system resources (rlimits) for the processes inside the sandbox. | 687 | These profile entries define the limits on system resources (rlimits) for the processes inside the sandbox. |
688 | The limits can be modified inside the sandbox using the regular \fBulimit\fR command. \fBcpu\fR command | 688 | The limits can be modified inside the sandbox using the regular \fBulimit\fR command. \fBcpu\fR command |
689 | configures the CPU cores available, and \fBcgroup\fR command | 689 | configures the CPU cores available. |
690 | place the sandbox in an existing control group. | ||
691 | 690 | ||
692 | Examples: | 691 | Examples: |
693 | 692 | ||
694 | .TP | 693 | .TP |
695 | \fBcgroup /sys/fs/cgroup/g1/tasks | ||
696 | The sandbox is placed in g1 control group. | ||
697 | .TP | ||
698 | \fBcpu 0,1,2 | 694 | \fBcpu 0,1,2 |
699 | Use only CPU cores 0, 1 and 2. | 695 | Use only CPU cores 0, 1 and 2. |
700 | .TP | 696 | .TP |
diff --git a/src/man/firejail.txt b/src/man/firejail.txt index a18b53fea..c2c0bc297 100644 --- a/src/man/firejail.txt +++ b/src/man/firejail.txt | |||
@@ -289,15 +289,6 @@ $ firejail \-\-caps.print=3272 | |||
289 | \fB\-\-cat=name|pid filename | 289 | \fB\-\-cat=name|pid filename |
290 | Print content of file from sandbox container, see FILE TRANSFER section for more details. | 290 | Print content of file from sandbox container, see FILE TRANSFER section for more details. |
291 | #endif | 291 | #endif |
292 | .TP | ||
293 | \fB\-\-cgroup=file | ||
294 | Place the sandbox in the specified control group. file is the full path of a tasks or cgroup.procs file. | ||
295 | .br | ||
296 | |||
297 | .br | ||
298 | Example: | ||
299 | .br | ||
300 | # firejail \-\-cgroup=/sys/fs/cgroup/g1/tasks | ||
301 | #ifdef HAVE_CHROOT | 292 | #ifdef HAVE_CHROOT |
302 | .TP | 293 | .TP |
303 | \fB\-\-chroot=dirname | 294 | \fB\-\-chroot=dirname |
@@ -994,7 +985,7 @@ $ firejail \-\-ipc-namespace firefox | |||
994 | Join the sandbox identified by name or by PID. By default a /bin/bash shell is started after joining the sandbox. | 985 | Join the sandbox identified by name or by PID. By default a /bin/bash shell is started after joining the sandbox. |
995 | If a program is specified, the program is run in the sandbox. If \-\-join command is issued as a regular user, | 986 | If a program is specified, the program is run in the sandbox. If \-\-join command is issued as a regular user, |
996 | all security filters are configured for the new process the same they are configured in the sandbox. | 987 | all security filters are configured for the new process the same they are configured in the sandbox. |
997 | If \-\-join command is issued as root, the security filters, cgroups and cpus configurations are not applied | 988 | If \-\-join command is issued as root, the security filters and cpus configurations are not applied |
998 | to the process joining the sandbox. | 989 | to the process joining the sandbox. |
999 | .br | 990 | .br |
1000 | 991 | ||
@@ -1019,13 +1010,13 @@ $ firejail \-\-join=3272 | |||
1019 | \fB\-\-join-filesystem=name|pid | 1010 | \fB\-\-join-filesystem=name|pid |
1020 | Join the mount namespace of the sandbox identified by name or PID. By default a /bin/bash shell is started after joining the sandbox. | 1011 | Join the mount namespace of the sandbox identified by name or PID. By default a /bin/bash shell is started after joining the sandbox. |
1021 | If a program is specified, the program is run in the sandbox. This command is available only to root user. | 1012 | If a program is specified, the program is run in the sandbox. This command is available only to root user. |
1022 | Security filters, cgroups and cpus configurations are not applied to the process joining the sandbox. | 1013 | Security filters and cpus configurations are not applied to the process joining the sandbox. |
1023 | #ifdef HAVE_NETWORK | 1014 | #ifdef HAVE_NETWORK |
1024 | .TP | 1015 | .TP |
1025 | \fB\-\-join-network=name|pid | 1016 | \fB\-\-join-network=name|pid |
1026 | Join the network namespace of the sandbox identified by name. By default a /bin/bash shell is started after joining the sandbox. | 1017 | Join the network namespace of the sandbox identified by name. By default a /bin/bash shell is started after joining the sandbox. |
1027 | If a program is specified, the program is run in the sandbox. This command is available only to root user. | 1018 | If a program is specified, the program is run in the sandbox. This command is available only to root user. |
1028 | Security filters, cgroups and cpus configurations are not applied to the process joining the sandbox. Example: | 1019 | Security filters and cpus configurations are not applied to the process joining the sandbox. Example: |
1029 | .br | 1020 | .br |
1030 | 1021 | ||
1031 | .br | 1022 | .br |
diff --git a/src/man/firemon.txt b/src/man/firemon.txt index c4e6e15b3..fd58a7168 100644 --- a/src/man/firemon.txt +++ b/src/man/firemon.txt | |||
@@ -21,9 +21,6 @@ Print ARP table for each sandbox. | |||
21 | \fB\-\-caps | 21 | \fB\-\-caps |
22 | Print capabilities configuration for each sandbox. | 22 | Print capabilities configuration for each sandbox. |
23 | .TP | 23 | .TP |
24 | \fB\-\-cgroup | ||
25 | Print control group information for each sandbox. | ||
26 | .TP | ||
27 | \fB\-\-cpu | 24 | \fB\-\-cpu |
28 | Print CPU affinity for each sandbox. | 25 | Print CPU affinity for each sandbox. |
29 | .TP | 26 | .TP |
diff --git a/test/utils/firemon-cgroup.exp b/test/utils/firemon-cgroup.exp deleted file mode 100755 index 2dbc04a50..000000000 --- a/test/utils/firemon-cgroup.exp +++ /dev/null | |||
@@ -1,40 +0,0 @@ | |||
1 | #!/usr/bin/expect -f | ||
2 | # This file is part of Firejail project | ||
3 | # Copyright (C) 2014-2022 Firejail Authors | ||
4 | # License GPL v2 | ||
5 | |||
6 | set timeout 10 | ||
7 | spawn $env(SHELL) | ||
8 | match_max 100000 | ||
9 | |||
10 | send -- "firejail --name=test1\r" | ||
11 | expect { | ||
12 | timeout {puts "TESTING ERROR 0\n";exit} | ||
13 | -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms" | ||
14 | } | ||
15 | sleep 1 | ||
16 | |||
17 | spawn $env(SHELL) | ||
18 | send -- "firejail --name=test2\r" | ||
19 | expect { | ||
20 | timeout {puts "TESTING ERROR 1\n";exit} | ||
21 | -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms" | ||
22 | } | ||
23 | sleep 1 | ||
24 | |||
25 | spawn $env(SHELL) | ||
26 | send -- "firemon --cgroup\r" | ||
27 | sleep 4 | ||
28 | expect { | ||
29 | timeout {puts "TESTING ERROR 2\n";exit} | ||
30 | "need to be root" {puts "TESTING SKIP: /proc mounted as hidepid\n"; exit} | ||
31 | "name=test1" | ||
32 | } | ||
33 | expect { | ||
34 | timeout {puts "TESTING ERROR 3\n";exit} | ||
35 | "name=test2" | ||
36 | } | ||
37 | |||
38 | after 100 | ||
39 | |||
40 | puts "\nall done\n" | ||
diff --git a/test/utils/utils.sh b/test/utils/utils.sh index 18f749ed8..102c8df17 100755 --- a/test/utils/utils.sh +++ b/test/utils/utils.sh | |||
@@ -129,9 +129,6 @@ fi | |||
129 | echo "TESTING: firemon cpu (test/utils/firemon-cpu.exp)" | 129 | echo "TESTING: firemon cpu (test/utils/firemon-cpu.exp)" |
130 | ./firemon-cpu.exp | 130 | ./firemon-cpu.exp |
131 | 131 | ||
132 | echo "TESTING: firemon cgroup (test/utils/firemon-cgroup.exp)" | ||
133 | ./firemon-cgroup.exp | ||
134 | |||
135 | echo "TESTING: firemon version (test/utils/firemon-version.exp)" | 132 | echo "TESTING: firemon version (test/utils/firemon-version.exp)" |
136 | ./firemon-version.exp | 133 | ./firemon-version.exp |
137 | 134 | ||