aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar startx2017 <vradu.startx@yandex.com>2018-05-08 17:57:43 -0400
committerLibravatar startx2017 <vradu.startx@yandex.com>2018-05-08 17:57:43 -0400
commit2a0fb5c1edc4455ec7e4a0396b54433aac59d98e (patch)
tree6881815465a4b2f5fd1a0c6128f8e9f6c7bf44d2
parentmore errLogExit (diff)
downloadfirejail-2a0fb5c1edc4455ec7e4a0396b54433aac59d98e.tar.gz
firejail-2a0fb5c1edc4455ec7e4a0396b54433aac59d98e.tar.zst
firejail-2a0fb5c1edc4455ec7e4a0396b54433aac59d98e.zip
don't display firejail --list/--tree/--top processes in firemon stats
-rw-r--r--src/firemon/firemon.c8
-rw-r--r--src/firemon/firemon.h1
-rw-r--r--src/firemon/list.c2
-rw-r--r--src/firemon/top.c4
-rw-r--r--src/firemon/tree.c2
5 files changed, 17 insertions, 0 deletions
diff --git a/src/firemon/firemon.c b/src/firemon/firemon.c
index 54f0c5fc9..147b5073b 100644
--- a/src/firemon/firemon.c
+++ b/src/firemon/firemon.c
@@ -25,6 +25,7 @@
25#include <grp.h> 25#include <grp.h>
26#include <sys/stat.h> 26#include <sys/stat.h>
27 27
28pid_t skip_process = 0;
28static int arg_route = 0; 29static int arg_route = 0;
29static int arg_arp = 0; 30static int arg_arp = 0;
30static int arg_tree = 0; 31static int arg_tree = 0;
@@ -217,6 +218,13 @@ int main(int argc, char **argv) {
217 } 218 }
218 } 219 }
219 220
221
222 // if the parent is firejail, skip the process
223 pid_t ppid = getppid();
224 char *pcomm = pid_proc_comm(ppid);
225 if (pcomm && strcmp(pcomm, "firejail") == 0)
226 skip_process = ppid;
227
220 // allow only root user if /proc is mounted hidepid 228 // allow only root user if /proc is mounted hidepid
221 if (pid_hidepid() && getuid() != 0) { 229 if (pid_hidepid() && getuid() != 0) {
222 fprintf(stderr, "Error: /proc is mounted hidepid, you would need to be root to run this command\n"); 230 fprintf(stderr, "Error: /proc is mounted hidepid, you would need to be root to run this command\n");
diff --git a/src/firemon/firemon.h b/src/firemon/firemon.h
index 2e0466638..e5a528254 100644
--- a/src/firemon/firemon.h
+++ b/src/firemon/firemon.h
@@ -36,6 +36,7 @@ static inline void firemon_clrscr(void) {
36} 36}
37 37
38// firemon.c 38// firemon.c
39extern pid_t skip_process;
39extern int arg_nowrap; 40extern int arg_nowrap;
40int find_child(int id); 41int find_child(int id);
41void firemon_sleep(int st); 42void firemon_sleep(int st);
diff --git a/src/firemon/list.c b/src/firemon/list.c
index 846739af5..cc1a871c6 100644
--- a/src/firemon/list.c
+++ b/src/firemon/list.c
@@ -25,6 +25,8 @@ void list(void) {
25 // print processes 25 // print processes
26 int i; 26 int i;
27 for (i = 0; i < max_pids; i++) { 27 for (i = 0; i < max_pids; i++) {
28 if (i == skip_process)
29 continue;
28 if (pids[i].level == 1) 30 if (pids[i].level == 1)
29 pid_print_list(i, arg_nowrap); 31 pid_print_list(i, arg_nowrap);
30 } 32 }
diff --git a/src/firemon/top.c b/src/firemon/top.c
index d60a0baef..b8dd92b3c 100644
--- a/src/firemon/top.c
+++ b/src/firemon/top.c
@@ -273,6 +273,8 @@ void top(void) {
273 unsigned utime = 0; 273 unsigned utime = 0;
274 unsigned stime = 0; 274 unsigned stime = 0;
275 for (i = 0; i < max_pids; i++) { 275 for (i = 0; i < max_pids; i++) {
276 if (i == skip_process)
277 continue;
276 if (pids[i].level == 1) 278 if (pids[i].level == 1)
277 pid_store_cpu(i, 0, &utime, &stime); 279 pid_store_cpu(i, 0, &utime, &stime);
278 } 280 }
@@ -313,6 +315,8 @@ void top(void) {
313 315
314 // print processes 316 // print processes
315 for (i = 0; i < max_pids; i++) { 317 for (i = 0; i < max_pids; i++) {
318 if (i == skip_process)
319 continue;
316 if (pids[i].level == 1) { 320 if (pids[i].level == 1) {
317 float cpu = 0; 321 float cpu = 0;
318 int cnt = 0; // process count 322 int cnt = 0; // process count
diff --git a/src/firemon/tree.c b/src/firemon/tree.c
index 99a7f3d88..07680d6d5 100644
--- a/src/firemon/tree.c
+++ b/src/firemon/tree.c
@@ -25,6 +25,8 @@ void tree(pid_t pid) {
25 // print processes 25 // print processes
26 int i; 26 int i;
27 for (i = 0; i < max_pids; i++) { 27 for (i = 0; i < max_pids; i++) {
28 if (i == skip_process)
29 continue;
28 if (pids[i].level == 1) 30 if (pids[i].level == 1)
29 pid_print_tree(i, 0, arg_nowrap); 31 pid_print_tree(i, 0, arg_nowrap);
30 } 32 }