aboutsummaryrefslogtreecommitdiffstats
path: root/src/firemon/firemon.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/firemon/firemon.c')
-rw-r--r--src/firemon/firemon.c71
1 files changed, 47 insertions, 24 deletions
diff --git a/src/firemon/firemon.c b/src/firemon/firemon.c
index 1ec64bea8..b63e37444 100644
--- a/src/firemon/firemon.c
+++ b/src/firemon/firemon.c
@@ -25,7 +25,6 @@
25#include <grp.h> 25#include <grp.h>
26#include <sys/stat.h> 26#include <sys/stat.h>
27 27
28
29static int arg_route = 0; 28static int arg_route = 0;
30static int arg_arp = 0; 29static int arg_arp = 0;
31static int arg_tree = 0; 30static int arg_tree = 0;
@@ -148,8 +147,13 @@ int main(int argc, char **argv) {
148 arg_seccomp = 1; 147 arg_seccomp = 1;
149 else if (strcmp(argv[i], "--caps") == 0) 148 else if (strcmp(argv[i], "--caps") == 0)
150 arg_caps = 1; 149 arg_caps = 1;
151 else if (strcmp(argv[i], "--interface") == 0) 150 else if (strcmp(argv[i], "--interface") == 0) {
151 if (getuid() != 0) {
152 fprintf(stderr, "Error: you need to be root to run this command\n");
153 exit(1);
154 }
152 arg_interface = 1; 155 arg_interface = 1;
156 }
153 else if (strcmp(argv[i], "--route") == 0) 157 else if (strcmp(argv[i], "--route") == 0)
154 arg_route = 1; 158 arg_route = 1;
155 else if (strcmp(argv[i], "--arp") == 0) 159 else if (strcmp(argv[i], "--arp") == 0)
@@ -196,10 +200,8 @@ int main(int argc, char **argv) {
196 exit(1); 200 exit(1);
197 } 201 }
198 202
199 if (arg_top) 203 if (arg_top) {
200 top(); // never to return 204 top();
201 if (arg_tree) {
202 tree();
203 return 0; 205 return 0;
204 } 206 }
205 if (arg_list) { 207 if (arg_list) {
@@ -212,25 +214,46 @@ int main(int argc, char **argv) {
212 } 214 }
213 215
214 // cumulative options 216 // cumulative options
215 if (arg_interface) 217 int print_procs = 1;
216 interface((pid_t) pid); 218 if (arg_tree) {
217 if (arg_route) 219 tree((pid_t) pid);
218 route((pid_t) pid); 220 print_procs = 0;
219 if (arg_arp) 221 }
220 arp((pid_t) pid); 222 if (arg_cpu) {
221 if (arg_seccomp) 223 cpu((pid_t) pid, print_procs);
222 seccomp((pid_t) pid); 224 print_procs = 0;
223 if (arg_caps) 225 }
224 caps((pid_t) pid); 226 if (arg_seccomp) {
225 if (arg_cpu) 227 seccomp((pid_t) pid, print_procs);
226 cpu((pid_t) pid); 228 print_procs = 0;
227 if (arg_cgroup) 229 }
228 cgroup((pid_t) pid); 230 if (arg_caps) {
229 if (arg_x11) 231 caps((pid_t) pid, print_procs);
230 x11((pid_t) pid); 232 print_procs = 0;
233 }
234 if (arg_cgroup) {
235 cgroup((pid_t) pid, print_procs);
236 print_procs = 0;
237 }
238 if (arg_x11) {
239 x11((pid_t) pid, print_procs);
240 print_procs = 0;
241 }
242 if (arg_interface) {
243 interface((pid_t) pid, print_procs);
244 print_procs = 0;
245 }
246 if (arg_route) {
247 route((pid_t) pid, print_procs);
248 print_procs = 0;
249 }
250 if (arg_arp) {
251 arp((pid_t) pid, print_procs);
252 print_procs = 0;
253 }
231 254
232 if (!arg_interface && !arg_route && !arg_arp && !arg_seccomp && !arg_caps && !arg_cgroup && !arg_x11) 255 if (print_procs)
233 procevent((pid_t) pid); // never to return 256 procevent((pid_t) pid);
234 257
235 return 0; 258 return 0;
236} 259}