aboutsummaryrefslogtreecommitdiffstats
path: root/src/firemon
diff options
context:
space:
mode:
authorLibravatar netblue30 <netblue30@yahoo.com>2018-01-24 08:48:50 -0500
committerLibravatar netblue30 <netblue30@yahoo.com>2018-01-24 08:48:50 -0500
commit5ebebb1211364a4d7164ad30d021adabf5374d32 (patch)
treeadcd26d88b059d25e058e19c56dd496c811e1690 /src/firemon
parentapparmor support for --overlay sandboxes (diff)
downloadfirejail-5ebebb1211364a4d7164ad30d021adabf5374d32.tar.gz
firejail-5ebebb1211364a4d7164ad30d021adabf5374d32.tar.zst
firejail-5ebebb1211364a4d7164ad30d021adabf5374d32.zip
added firejail --apparmor.print and firemon --apparmor
Diffstat (limited to 'src/firemon')
-rw-r--r--src/firemon/Makefile.in3
-rw-r--r--src/firemon/apparmor.c62
-rw-r--r--src/firemon/firemon.c10
-rw-r--r--src/firemon/firemon.h3
-rw-r--r--src/firemon/usage.c1
5 files changed, 77 insertions, 2 deletions
diff --git a/src/firemon/Makefile.in b/src/firemon/Makefile.in
index c24bae9ff..326c305d9 100644
--- a/src/firemon/Makefile.in
+++ b/src/firemon/Makefile.in
@@ -6,13 +6,14 @@ VERSION=@PACKAGE_VERSION@
6NAME=@PACKAGE_NAME@ 6NAME=@PACKAGE_NAME@
7HAVE_FATAL_WARNINGS=@HAVE_FATAL_WARNINGS@ 7HAVE_FATAL_WARNINGS=@HAVE_FATAL_WARNINGS@
8HAVE_GCOV=@HAVE_GCOV@ 8HAVE_GCOV=@HAVE_GCOV@
9HAVE_APPARMOR=@HAVE_APPARMOR@
9EXTRA_LDFLAGS +=@EXTRA_LDFLAGS@ 10EXTRA_LDFLAGS +=@EXTRA_LDFLAGS@
10 11
11H_FILE_LIST = $(sort $(wildcard *.[h])) 12H_FILE_LIST = $(sort $(wildcard *.[h]))
12C_FILE_LIST = $(sort $(wildcard *.c)) 13C_FILE_LIST = $(sort $(wildcard *.c))
13OBJS = $(C_FILE_LIST:.c=.o) 14OBJS = $(C_FILE_LIST:.c=.o)
14BINOBJS = $(foreach file, $(OBJS), $file) 15BINOBJS = $(foreach file, $(OBJS), $file)
15CFLAGS += -ggdb $(HAVE_FATAL_WARNINGS) -O2 -DVERSION='"$(VERSION)"' -DPREFIX='"$(prefix)"' $(HAVE_GCOV) -fstack-protector-all -D_FORTIFY_SOURCE=2 -fPIE -pie -Wformat -Wformat-security 16CFLAGS += -ggdb $(HAVE_FATAL_WARNINGS) -O2 -DVERSION='"$(VERSION)"' -DPREFIX='"$(prefix)"' $(HAVE_APPARMOR) $(HAVE_GCOV) -fstack-protector-all -D_FORTIFY_SOURCE=2 -fPIE -pie -Wformat -Wformat-security
16LDFLAGS += -pie -Wl,-z,relro -Wl,-z,now 17LDFLAGS += -pie -Wl,-z,relro -Wl,-z,now
17HAVE_GCOV=@HAVE_GCOV@ 18HAVE_GCOV=@HAVE_GCOV@
18EXTRA_LDFLAGS +=@EXTRA_LDFLAGS@ 19EXTRA_LDFLAGS +=@EXTRA_LDFLAGS@
diff --git a/src/firemon/apparmor.c b/src/firemon/apparmor.c
new file mode 100644
index 000000000..0fe287e8f
--- /dev/null
+++ b/src/firemon/apparmor.c
@@ -0,0 +1,62 @@
1/*
2 * Copyright (C) 2014-2018 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#include <sys/apparmor.h>
22
23#ifdef HAVE_APPARMOR
24static void print_apparmor(int pid) {
25 char *label = NULL;
26 char *mode = NULL;
27 int rv = aa_gettaskcon(pid, &label, &mode);
28 if (rv != -1) {
29 printf(" AppArmor: ");
30 if (label)
31 printf("%s ", label);
32 if (mode)
33 printf("%s", mode);
34 printf("\n");
35 }
36}
37
38void apparmor(pid_t pid, int print_procs) {
39 pid_read(pid);
40
41 // print processes
42 int i;
43 for (i = 0; i < max_pids; i++) {
44 if (pids[i].level == 1) {
45 if (print_procs || pid == 0)
46 pid_print_list(i, arg_nowrap);
47 int child = find_child(i);
48 if (child != -1)
49 print_apparmor(child);
50 }
51 }
52 printf("\n");
53}
54
55#else
56
57void apparmor(pid_t pid, int print_procs) {
58 (void) pid;
59 (void) print_procs;
60 printf("AppArmor support not available\n");
61}
62#endif
diff --git a/src/firemon/firemon.c b/src/firemon/firemon.c
index 44e2b8687..54f0c5fc9 100644
--- a/src/firemon/firemon.c
+++ b/src/firemon/firemon.c
@@ -37,6 +37,7 @@ static int arg_x11 = 0;
37static int arg_top = 0; 37static int arg_top = 0;
38static int arg_list = 0; 38static int arg_list = 0;
39static int arg_netstats = 0; 39static int arg_netstats = 0;
40static int arg_apparmor = 0;
40int arg_nowrap = 0; 41int arg_nowrap = 0;
41 42
42static struct termios tlocal; // startup terminal setting 43static struct termios tlocal; // startup terminal setting
@@ -178,6 +179,8 @@ int main(int argc, char **argv) {
178 arg_route = 1; 179 arg_route = 1;
179 else if (strcmp(argv[i], "--arp") == 0) 180 else if (strcmp(argv[i], "--arp") == 0)
180 arg_arp = 1; 181 arg_arp = 1;
182 else if (strcmp(argv[i], "--apparmor") == 0)
183 arg_apparmor = 1;
181 184
182 else if (strncmp(argv[i], "--name=", 7) == 0) { 185 else if (strncmp(argv[i], "--name=", 7) == 0) {
183 char *name = argv[i] + 7; 186 char *name = argv[i] + 7;
@@ -238,7 +241,7 @@ int main(int argc, char **argv) {
238 } 241 }
239 242
240 // if --name requested without other options, print all data 243 // if --name requested without other options, print all data
241 if (pid && !arg_cpu && !arg_seccomp && !arg_caps && 244 if (pid && !arg_cpu && !arg_seccomp && !arg_caps && !arg_apparmor &&
242 !arg_cgroup && !arg_x11 && !arg_interface && !arg_route && !arg_arp) { 245 !arg_cgroup && !arg_x11 && !arg_interface && !arg_route && !arg_arp) {
243 arg_tree = 1; 246 arg_tree = 1;
244 arg_cpu = 1; 247 arg_cpu = 1;
@@ -249,6 +252,7 @@ int main(int argc, char **argv) {
249 arg_interface = 1; 252 arg_interface = 1;
250 arg_route = 1; 253 arg_route = 1;
251 arg_arp = 1; 254 arg_arp = 1;
255 arg_apparmor = 1;
252 } 256 }
253 257
254 // cumulative options 258 // cumulative options
@@ -265,6 +269,10 @@ int main(int argc, char **argv) {
265 caps((pid_t) pid, print_procs); 269 caps((pid_t) pid, print_procs);
266 print_procs = 0; 270 print_procs = 0;
267 } 271 }
272 if (arg_apparmor) {
273 apparmor((pid_t) pid, print_procs);
274 print_procs = 0;
275 }
268 if (arg_cgroup) { 276 if (arg_cgroup) {
269 cgroup((pid_t) pid, print_procs); 277 cgroup((pid_t) pid, print_procs);
270 print_procs = 0; 278 print_procs = 0;
diff --git a/src/firemon/firemon.h b/src/firemon/firemon.h
index a03aa85e5..2e0466638 100644
--- a/src/firemon/firemon.h
+++ b/src/firemon/firemon.h
@@ -83,4 +83,7 @@ void netstats(void);
83// x11.c 83// x11.c
84void x11(pid_t pid, int print_procs); 84void x11(pid_t pid, int print_procs);
85 85
86//apparmor.c
87void apparmor(pid_t pid, int print_procs);
88
86#endif 89#endif
diff --git a/src/firemon/usage.c b/src/firemon/usage.c
index 9d3babf55..617f4dacd 100644
--- a/src/firemon/usage.c
+++ b/src/firemon/usage.c
@@ -27,6 +27,7 @@ void usage(void) {
27 printf("are also being monitored. On Grsecurity systems only root user\n"); 27 printf("are also being monitored. On Grsecurity systems only root user\n");
28 printf("can run this program.\n\n"); 28 printf("can run this program.\n\n");
29 printf("Options:\n"); 29 printf("Options:\n");
30 printf("\t--apparmor - print AppArmor confinement status for each sandbox.\n\n");
30 printf("\t--arp - print ARP table for each sandbox.\n\n"); 31 printf("\t--arp - print ARP table for each sandbox.\n\n");
31 printf("\t--caps - print capabilities configuration for each sandbox.\n\n"); 32 printf("\t--caps - print capabilities configuration for each sandbox.\n\n");
32 printf("\t--cgroup - print control group information for each sandbox.\n\n"); 33 printf("\t--cgroup - print control group information for each sandbox.\n\n");