aboutsummaryrefslogtreecommitdiffstats
path: root/src/firemon
diff options
context:
space:
mode:
authorLibravatar startx2017 <vradu.startx@yandex.com>2017-07-07 08:53:30 -0400
committerLibravatar startx2017 <vradu.startx@yandex.com>2017-07-07 08:53:30 -0400
commit4a270c553b4edc0e745759670ba0c2b2ca814e1b (patch)
treed69c669fb96b1a88339d2274bd580f3d9df16913 /src/firemon
parentrun --netstats on 1s interval; caching user name. (diff)
downloadfirejail-4a270c553b4edc0e745759670ba0c2b2ca814e1b.tar.gz
firejail-4a270c553b4edc0e745759670ba0c2b2ca814e1b.tar.zst
firejail-4a270c553b4edc0e745759670ba0c2b2ca814e1b.zip
fix firemon --name
Diffstat (limited to 'src/firemon')
-rw-r--r--src/firemon/cgroup.c1
-rw-r--r--src/firemon/firemon.c26
-rw-r--r--src/firemon/procevent.c14
3 files changed, 22 insertions, 19 deletions
diff --git a/src/firemon/cgroup.c b/src/firemon/cgroup.c
index 41afa41fd..8cf8d14f7 100644
--- a/src/firemon/cgroup.c
+++ b/src/firemon/cgroup.c
@@ -48,6 +48,7 @@ void cgroup(pid_t pid, int print_procs) {
48 pid_read(pid); 48 pid_read(pid);
49 49
50 // print processes 50 // print processes
51 printf(" cgroup: ");
51 int i; 52 int i;
52 for (i = 0; i < max_pids; i++) { 53 for (i = 0; i < max_pids; i++) {
53 if (pids[i].level == 1) { 54 if (pids[i].level == 1) {
diff --git a/src/firemon/firemon.c b/src/firemon/firemon.c
index aaeffdbd2..5861e35ee 100644
--- a/src/firemon/firemon.c
+++ b/src/firemon/firemon.c
@@ -201,18 +201,32 @@ int main(int argc, char **argv) {
201 } 201 }
202 202
203 if (arg_top) { 203 if (arg_top) {
204 top(); 204 top(); // print all sandboxes, --name disregarded
205 return 0; 205 return 0;
206 } 206 }
207 if (arg_list) { 207 if (arg_list) {
208 list(); 208 list(); // print all sandboxes, --name disregarded
209 return 0; 209 return 0;
210 } 210 }
211 if (arg_netstats) { 211 if (arg_netstats) {
212 netstats(); 212 netstats(); // print all sandboxes, --name disregarded
213 return 0; 213 return 0;
214 } 214 }
215 215
216 // if --name requested without other options, print all data
217 if (pid && !arg_tree && !arg_cpu && !arg_seccomp && !arg_caps &&
218 !arg_cgroup && !arg_x11 && !arg_interface && !arg_route && !arg_arp) {
219 arg_tree = 1;
220 arg_cpu = 1;
221 arg_seccomp = 1;
222 arg_caps = 1;
223 arg_cgroup = 1;
224 arg_x11 = 1;
225 arg_interface = 1;
226 arg_route = 1;
227 arg_arp = 1;
228 }
229
216 // cumulative options 230 // cumulative options
217 int print_procs = 1; 231 int print_procs = 1;
218 if (arg_tree) { 232 if (arg_tree) {
@@ -239,7 +253,7 @@ int main(int argc, char **argv) {
239 x11((pid_t) pid, print_procs); 253 x11((pid_t) pid, print_procs);
240 print_procs = 0; 254 print_procs = 0;
241 } 255 }
242 if (arg_interface) { 256 if (arg_interface && getuid() == 0) {
243 interface((pid_t) pid, print_procs); 257 interface((pid_t) pid, print_procs);
244 print_procs = 0; 258 print_procs = 0;
245 } 259 }
@@ -252,7 +266,9 @@ int main(int argc, char **argv) {
252 print_procs = 0; 266 print_procs = 0;
253 } 267 }
254 268
255 if (print_procs) 269 if (getuid() == 0)
270 if (!arg_tree)
271 tree((pid_t) pid);
256 procevent((pid_t) pid); 272 procevent((pid_t) pid);
257 273
258 return 0; 274 return 0;
diff --git a/src/firemon/procevent.c b/src/firemon/procevent.c
index d6afed93a..27c0e2b3f 100644
--- a/src/firemon/procevent.c
+++ b/src/firemon/procevent.c
@@ -449,16 +449,6 @@ static int procevent_monitor(const int sock, pid_t mypid) {
449 return 0; 449 return 0;
450} 450}
451 451
452static void procevent_print_pids(void) {
453 // print files
454 int i;
455 for (i = 0; i < max_pids; i++) {
456 if (pids[i].level == 1)
457 pid_print_tree(i, 0, 1);
458 }
459 printf("\n");
460}
461
462void procevent(pid_t pid) { 452void procevent(pid_t pid) {
463 // need to be root for this 453 // need to be root for this
464 if (getuid() != 0) { 454 if (getuid() != 0) {
@@ -466,10 +456,6 @@ void procevent(pid_t pid) {
466 exit(1); 456 exit(1);
467 } 457 }
468 458
469 // read and print sandboxed processes
470 pid_read(pid);
471 procevent_print_pids();
472
473 // monitor using netlink 459 // monitor using netlink
474 int sock = procevent_netlink_setup(); 460 int sock = procevent_netlink_setup();
475 if (sock < 0) { 461 if (sock < 0) {