aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar netblue30 <netblue30@yahoo.com>2018-03-21 08:56:54 -0400
committerLibravatar netblue30 <netblue30@yahoo.com>2018-03-21 08:56:54 -0400
commit57ffc35a8e0264507118b9839a499375f416260c (patch)
tree7f406d1be0674ee964c300910f10480c68191708
parentMerge pull request #1820 from g3ngr33n/master (diff)
downloadfirejail-57ffc35a8e0264507118b9839a499375f416260c.tar.gz
firejail-57ffc35a8e0264507118b9839a499375f416260c.tar.zst
firejail-57ffc35a8e0264507118b9839a499375f416260c.zip
added sandbox name support in firemon
-rw-r--r--RELNOTES1
-rw-r--r--src/firejail/firejail.h2
-rw-r--r--src/lib/pid.c35
-rw-r--r--src/man/firejail.txt29
-rw-r--r--src/man/firemon.txt22
5 files changed, 60 insertions, 29 deletions
diff --git a/RELNOTES b/RELNOTES
index bc18cfd83..e7852663e 100644
--- a/RELNOTES
+++ b/RELNOTES
@@ -23,6 +23,7 @@ firejail (0.9.53) baseline; urgency=low
23 * whitelist support for overlay and chroot sandboxes 23 * whitelist support for overlay and chroot sandboxes
24 * private-dev support for overlay and chroot sandboxes 24 * private-dev support for overlay and chroot sandboxes
25 * private-tmp support for overlay and chroot sandboxes 25 * private-tmp support for overlay and chroot sandboxes
26 * added sandbox name support in firemon
26 * new profiles: basilisk, Tor Browser language packs, PlayOnLinux, sylpheed, 27 * new profiles: basilisk, Tor Browser language packs, PlayOnLinux, sylpheed,
27 * new profiles: discord-canary, pycharm-community, pycharm-professional, 28 * new profiles: discord-canary, pycharm-community, pycharm-professional,
28 * new profiles: pdfchain, tilp, vivaldi-snapshot, bitcoin-qt, kaffeine, VS Code, 29 * new profiles: pdfchain, tilp, vivaldi-snapshot, bitcoin-qt, kaffeine, VS Code,
diff --git a/src/firejail/firejail.h b/src/firejail/firejail.h
index ca3cf18ac..5af141289 100644
--- a/src/firejail/firejail.h
+++ b/src/firejail/firejail.h
@@ -31,7 +31,7 @@
31#define RUN_FIREJAIL_BASEDIR "/run" 31#define RUN_FIREJAIL_BASEDIR "/run"
32#define RUN_FIREJAIL_DIR "/run/firejail" 32#define RUN_FIREJAIL_DIR "/run/firejail"
33#define RUN_FIREJAIL_APPIMAGE_DIR "/run/firejail/appimage" 33#define RUN_FIREJAIL_APPIMAGE_DIR "/run/firejail/appimage"
34#define RUN_FIREJAIL_NAME_DIR "/run/firejail/name" 34#define RUN_FIREJAIL_NAME_DIR "/run/firejail/name" // also used in src/lib/pid.c - todo: move it in a common place
35#define RUN_FIREJAIL_X11_DIR "/run/firejail/x11" 35#define RUN_FIREJAIL_X11_DIR "/run/firejail/x11"
36#define RUN_FIREJAIL_NETWORK_DIR "/run/firejail/network" 36#define RUN_FIREJAIL_NETWORK_DIR "/run/firejail/network"
37#define RUN_FIREJAIL_BANDWIDTH_DIR "/run/firejail/bandwidth" 37#define RUN_FIREJAIL_BANDWIDTH_DIR "/run/firejail/bandwidth"
diff --git a/src/lib/pid.c b/src/lib/pid.c
index 0b2f402d1..f138efc8c 100644
--- a/src/lib/pid.c
+++ b/src/lib/pid.c
@@ -21,6 +21,7 @@
21#include "../include/pid.h" 21#include "../include/pid.h"
22#include <string.h> 22#include <string.h>
23#include <sys/types.h> 23#include <sys/types.h>
24#include <sys/stat.h>
24#include <pwd.h> 25#include <pwd.h>
25#include <sys/ioctl.h> 26#include <sys/ioctl.h>
26#include <dirent.h> 27#include <dirent.h>
@@ -165,6 +166,10 @@ doexit:
165 return rv; 166 return rv;
166} 167}
167 168
169// todo: RUN_FIREJAIL_NAME_DIR is borrowed from src/firejail/firejail.h
170// move it in a common place
171#define RUN_FIREJAIL_NAME_DIR "/run/firejail/name"
172
168static void print_elem(unsigned index, int nowrap) { 173static void print_elem(unsigned index, int nowrap) {
169 // get terminal size 174 // get terminal size
170 struct winsize sz; 175 struct winsize sz;
@@ -184,14 +189,40 @@ static void print_elem(unsigned index, int nowrap) {
184 char *cmd = pid_proc_cmdline(index); 189 char *cmd = pid_proc_cmdline(index);
185 char *user = pid_get_user_name(uid); 190 char *user = pid_get_user_name(uid);
186 char *allocated = user; 191 char *allocated = user;
192
193 // extract sandbox name - pid == index
194 char *sandbox_name = "";
195 char *fname;
196 if (asprintf(&fname, "%s/%d", RUN_FIREJAIL_NAME_DIR, index) == -1)
197 errExit("asprintf");
198 struct stat s;
199 if (stat(fname, &s) == 0) {
200 FILE *fp = fopen(fname, "r");
201 if (fp) {
202 sandbox_name = malloc(s.st_size + 1);
203 if (!sandbox_name)
204 errExit("malloc");
205 char *rv = fgets(sandbox_name, s.st_size + 1, fp);
206 if (!rv)
207 *sandbox_name = '\0';
208 else {
209 char *ptr = strchr(sandbox_name, '\n');
210 if (ptr)
211 *ptr = '\0';
212 }
213 fclose(fp);
214 }
215 }
216 free(fname);
217
187 if (user ==NULL) 218 if (user ==NULL)
188 user = ""; 219 user = "";
189 if (cmd) { 220 if (cmd) {
190 if (col < 4 || nowrap) 221 if (col < 4 || nowrap)
191 printf("%s%u:%s:%s\n", indent, index, user, cmd); 222 printf("%s%u:%s:%s:%s\n", indent, index, user, sandbox_name, cmd);
192 else { 223 else {
193 char *out; 224 char *out;
194 if (asprintf(&out, "%s%u:%s:%s\n", indent, index, user, cmd) == -1) 225 if (asprintf(&out, "%s%u:%s:%s:%s\n", indent, index, user, sandbox_name, cmd) == -1)
195 errExit("asprintf"); 226 errExit("asprintf");
196 int len = strlen(out); 227 int len = strlen(out);
197 if (len > col) { 228 if (len > col) {
diff --git a/src/man/firejail.txt b/src/man/firejail.txt
index b05a5a722..34e4102f6 100644
--- a/src/man/firejail.txt
+++ b/src/man/firejail.txt
@@ -254,7 +254,7 @@ Example:
254.br 254.br
255$ firejail \-\-list 255$ firejail \-\-list
256.br 256.br
2573272:netblue:firejail \-\-private firefox 2573272:netblue::firejail \-\-private firefox
258.br 258.br
259$ firejail \-\-caps.print=3272 259$ firejail \-\-caps.print=3272
260 260
@@ -309,7 +309,7 @@ Example:
309.br 309.br
310$ firejail \-\-list 310$ firejail \-\-list
311.br 311.br
3123272:netblue:firejail \-\-private firefox 3123272:netblue::firejail \-\-private firefox
313.br 313.br
314$ firejail \-\-cpu.print=3272 314$ firejail \-\-cpu.print=3272
315 315
@@ -453,7 +453,7 @@ Example:
453.br 453.br
454$ firejail \-\-list 454$ firejail \-\-list
455.br 455.br
4563272:netblue:firejail \-\-private firefox 4563272:netblue::firejail \-\-private firefox
457.br 457.br
458$ firejail \-\-dns.print=3272 458$ firejail \-\-dns.print=3272
459 459
@@ -492,7 +492,7 @@ Example:
492.br 492.br
493$ firejail \-\-list 493$ firejail \-\-list
494.br 494.br
4953272:netblue:firejail \-\-private firefox 4953272:netblue::firejail \-\-private firefox
496.br 496.br
497$ firejail \-\-fs.print=3272 497$ firejail \-\-fs.print=3272
498 498
@@ -662,7 +662,7 @@ Example:
662.br 662.br
663$ firejail \-\-list 663$ firejail \-\-list
664.br 664.br
6653272:netblue:firejail \-\-private firefox 6653272:netblue::firejail \-\-private firefox
666.br 666.br
667$ firejail \-\-join=3272 667$ firejail \-\-join=3272
668 668
@@ -749,11 +749,11 @@ Example:
749.br 749.br
750$ firejail \-\-list 750$ firejail \-\-list
751.br 751.br
7527015:netblue:firejail firefox 7527015:netblue:browser:firejail firefox
753.br 753.br
7547056:netblue:firejail \-\-net=eth0 transmission-gtk 7547056:netblue:torrent:firejail \-\-net=eth0 transmission-gtk
755.br 755.br
7567064:netblue:firejail \-\-noroot xterm 7567064:netblue::firejail \-\-noroot xterm
757.br 757.br
758$ 758$
759.TP 759.TP
@@ -1543,7 +1543,7 @@ Example:
1543.br 1543.br
1544$ firejail \-\-list 1544$ firejail \-\-list
1545.br 1545.br
15463272:netblue:firejail \-\-private firefox 15463272:netblue::firejail \-\-private firefox
1547.br 1547.br
1548$ firejail \-\-protocol.print=3272 1548$ firejail \-\-protocol.print=3272
1549.br 1549.br
@@ -1992,7 +1992,7 @@ Example:
1992.br 1992.br
1993$ firejail \-\-list 1993$ firejail \-\-list
1994.br 1994.br
19953272:netblue:firejail \-\-private firefox 19953272:netblue::firejail \-\-private firefox
1996.br 1996.br
1997$ firejail \-\-shutdown=3272 1997$ firejail \-\-shutdown=3272
1998.TP 1998.TP
@@ -2598,12 +2598,12 @@ Limitations: audit feature is not implemented for --x11 commands.
2598Option \-\-list prints a list of all sandboxes. The format 2598Option \-\-list prints a list of all sandboxes. The format
2599for each process entry is as follows: 2599for each process entry is as follows:
2600 2600
2601 PID:USER:Command 2601 PID:USER:Sandbox Name:Command
2602 2602
2603Option \-\-tree prints the tree of processes running in the sandbox. The format 2603Option \-\-tree prints the tree of processes running in the sandbox. The format
2604for each process entry is as follows: 2604for each process entry is as follows:
2605 2605
2606 PID:USER:Command 2606 PID:USER:Sandbox Name:Command
2607 2607
2608Option \-\-top is similar to the UNIX top command, however it applies only to 2608Option \-\-top is similar to the UNIX top command, however it applies only to
2609sandboxes. 2609sandboxes.
@@ -2635,6 +2635,9 @@ It is a sum of the RES values for all processes running in the sandbox.
2635RX(KB/s) 2635RX(KB/s)
2636Network receive speed. 2636Network receive speed.
2637.TP 2637.TP
2638Sandbox Name
2639The name of the sandbox, if any.
2640.TP
2638SHR 2641SHR
2639Shared Memory Size (KiB), it reflects memory shared with other 2642Shared Memory Size (KiB), it reflects memory shared with other
2640processes. It is a sum of the SHR values for all processes running 2643processes. It is a sum of the SHR values for all processes running
@@ -2646,7 +2649,7 @@ Network transmit speed.
2646Uptime 2649Uptime
2647Sandbox running time in hours:minutes:seconds format. 2650Sandbox running time in hours:minutes:seconds format.
2648.TP 2651.TP
2649User 2652USER
2650The owner of the sandbox. 2653The owner of the sandbox.
2651 2654
2652.SH SECURITY PROFILES 2655.SH SECURITY PROFILES
diff --git a/src/man/firemon.txt b/src/man/firemon.txt
index 4827bbbeb..91c59af4d 100644
--- a/src/man/firemon.txt
+++ b/src/man/firemon.txt
@@ -50,7 +50,8 @@ Print route table for each sandbox.
50Print seccomp configuration for each sandbox. 50Print seccomp configuration for each sandbox.
51.TP 51.TP
52\fB\-\-top 52\fB\-\-top
53Monitor the most CPU-intensive sandboxes. 53Monitor the most CPU-intensive sandboxes. This command is similar to
54the regular UNIX top command, however it applies only to sandboxes.
54.TP 55.TP
55\fB\-\-tree 56\fB\-\-tree
56Print a tree of all sandboxed processes. 57Print a tree of all sandboxed processes.
@@ -63,19 +64,11 @@ Print program version and exit.
63Print X11 display number. 64Print X11 display number.
64 65
65.PP 66.PP
66Option \-\-list prints a list of all sandboxes. The format 67The format for each listed sandbox entry is as follows:
67for each entry is as follows:
68 68
69 PID:USER:Command 69 PID:USER:Sandbox Name:Command
70 70
71Option \-\-tree prints the tree of processes running in the sandbox. The format 71Listed below are the available fields (columns) in various firemon commands in alphabetical order:
72for each process entry is as follows:
73
74 PID:USER:Command
75
76Option \-\-top is similar to the UNIX top command, however it applies only to
77sandboxes. Listed below are the available fields (columns) in alphabetical
78order:
79 72
80.TP 73.TP
81Command 74Command
@@ -95,6 +88,9 @@ RES
95Resident Memory Size (KiB), sandbox non-swapped physical memory. 88Resident Memory Size (KiB), sandbox non-swapped physical memory.
96It is a sum of the RES values for all processes running in the sandbox. 89It is a sum of the RES values for all processes running in the sandbox.
97.TP 90.TP
91Sandbox Name
92The name of the sandbox, if any.
93.TP
98SHR 94SHR
99Shared Memory Size (KiB), it reflects memory shared with other 95Shared Memory Size (KiB), it reflects memory shared with other
100processes. It is a sum of the SHR values for all processes running 96processes. It is a sum of the SHR values for all processes running
@@ -103,7 +99,7 @@ in the sandbox, including the controlling process.
103Uptime 99Uptime
104Sandbox running time in hours:minutes:seconds format. 100Sandbox running time in hours:minutes:seconds format.
105.TP 101.TP
106User 102USER
107The owner of the sandbox. 103The owner of the sandbox.
108 104
109.SH LICENSE 105.SH LICENSE