aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/firejail/usage.c1
-rw-r--r--src/firemon/cgroup.c63
-rw-r--r--src/firemon/firemon.c10
-rw-r--r--src/firemon/firemon.h3
-rw-r--r--src/firemon/usage.c1
-rw-r--r--src/man/firejail-profile.txt8
-rw-r--r--src/man/firejail.txt15
-rw-r--r--src/man/firemon.txt3
-rwxr-xr-xtest/utils/firemon-cgroup.exp40
-rwxr-xr-xtest/utils/utils.sh3
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
23static 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
47void 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;
34static int arg_seccomp = 0; 34static int arg_seccomp = 0;
35static int arg_caps = 0; 35static int arg_caps = 0;
36static int arg_cpu = 0; 36static int arg_cpu = 0;
37static int arg_cgroup = 0;
38static int arg_x11 = 0; 37static int arg_x11 = 0;
39static int arg_top = 0; 38static int arg_top = 0;
40static int arg_list = 0; 39static 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
76void cpu(pid_t pid, int print_procs); 76void cpu(pid_t pid, int print_procs);
77 77
78// cgroup.c
79void cgroup(pid_t pid, int print_procs);
80
81// tree.c 78// tree.c
82void tree(pid_t pid); 79void 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
687These profile entries define the limits on system resources (rlimits) for the processes inside the sandbox. 687These profile entries define the limits on system resources (rlimits) for the processes inside the sandbox.
688The limits can be modified inside the sandbox using the regular \fBulimit\fR command. \fBcpu\fR command 688The limits can be modified inside the sandbox using the regular \fBulimit\fR command. \fBcpu\fR command
689configures the CPU cores available, and \fBcgroup\fR command 689configures the CPU cores available.
690place the sandbox in an existing control group.
691 690
692Examples: 691Examples:
693 692
694.TP 693.TP
695\fBcgroup /sys/fs/cgroup/g1/tasks
696The sandbox is placed in g1 control group.
697.TP
698\fBcpu 0,1,2 694\fBcpu 0,1,2
699Use only CPU cores 0, 1 and 2. 695Use 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
290Print content of file from sandbox container, see FILE TRANSFER section for more details. 290Print content of file from sandbox container, see FILE TRANSFER section for more details.
291#endif 291#endif
292.TP
293\fB\-\-cgroup=file
294Place the sandbox in the specified control group. file is the full path of a tasks or cgroup.procs file.
295.br
296
297.br
298Example:
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
994Join the sandbox identified by name or by PID. By default a /bin/bash shell is started after joining the sandbox. 985Join the sandbox identified by name or by PID. By default a /bin/bash shell is started after joining the sandbox.
995If a program is specified, the program is run in the sandbox. If \-\-join command is issued as a regular user, 986If a program is specified, the program is run in the sandbox. If \-\-join command is issued as a regular user,
996all security filters are configured for the new process the same they are configured in the sandbox. 987all security filters are configured for the new process the same they are configured in the sandbox.
997If \-\-join command is issued as root, the security filters, cgroups and cpus configurations are not applied 988If \-\-join command is issued as root, the security filters and cpus configurations are not applied
998to the process joining the sandbox. 989to 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
1020Join the mount namespace of the sandbox identified by name or PID. By default a /bin/bash shell is started after joining the sandbox. 1011Join the mount namespace of the sandbox identified by name or PID. By default a /bin/bash shell is started after joining the sandbox.
1021If a program is specified, the program is run in the sandbox. This command is available only to root user. 1012If a program is specified, the program is run in the sandbox. This command is available only to root user.
1022Security filters, cgroups and cpus configurations are not applied to the process joining the sandbox. 1013Security 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
1026Join the network namespace of the sandbox identified by name. By default a /bin/bash shell is started after joining the sandbox. 1017Join the network namespace of the sandbox identified by name. By default a /bin/bash shell is started after joining the sandbox.
1027If a program is specified, the program is run in the sandbox. This command is available only to root user. 1018If a program is specified, the program is run in the sandbox. This command is available only to root user.
1028Security filters, cgroups and cpus configurations are not applied to the process joining the sandbox. Example: 1019Security 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
22Print capabilities configuration for each sandbox. 22Print capabilities configuration for each sandbox.
23.TP 23.TP
24\fB\-\-cgroup
25Print control group information for each sandbox.
26.TP
27\fB\-\-cpu 24\fB\-\-cpu
28Print CPU affinity for each sandbox. 25Print 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
6set timeout 10
7spawn $env(SHELL)
8match_max 100000
9
10send -- "firejail --name=test1\r"
11expect {
12 timeout {puts "TESTING ERROR 0\n";exit}
13 -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
14}
15sleep 1
16
17spawn $env(SHELL)
18send -- "firejail --name=test2\r"
19expect {
20 timeout {puts "TESTING ERROR 1\n";exit}
21 -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
22}
23sleep 1
24
25spawn $env(SHELL)
26send -- "firemon --cgroup\r"
27sleep 4
28expect {
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}
33expect {
34 timeout {puts "TESTING ERROR 3\n";exit}
35 "name=test2"
36}
37
38after 100
39
40puts "\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
129echo "TESTING: firemon cpu (test/utils/firemon-cpu.exp)" 129echo "TESTING: firemon cpu (test/utils/firemon-cpu.exp)"
130./firemon-cpu.exp 130./firemon-cpu.exp
131 131
132echo "TESTING: firemon cgroup (test/utils/firemon-cgroup.exp)"
133./firemon-cgroup.exp
134
135echo "TESTING: firemon version (test/utils/firemon-version.exp)" 132echo "TESTING: firemon version (test/utils/firemon-version.exp)"
136./firemon-version.exp 133./firemon-version.exp
137 134