aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/firejail/firejail.h1
-rw-r--r--src/firejail/main.c5
-rw-r--r--src/firejail/preproc.c4
-rw-r--r--src/firejail/profile.c4
-rw-r--r--src/firejail/sandbox.c14
-rw-r--r--src/fnettrace/Makefile3
-rw-r--r--src/include/rundefs.h2
-rw-r--r--src/man/Makefile60
-rw-r--r--src/man/firecfg.1.in (renamed from src/man/firecfg.txt)0
-rw-r--r--src/man/firejail-login.5.in (renamed from src/man/firejail-login.txt)0
-rw-r--r--src/man/firejail-profile.5.in (renamed from src/man/firejail-profile.txt)0
-rw-r--r--src/man/firejail-users.5.in (renamed from src/man/firejail-users.txt)0
-rw-r--r--src/man/firejail.1.in (renamed from src/man/firejail.txt)0
-rw-r--r--src/man/firemon.1.in (renamed from src/man/firemon.txt)0
-rw-r--r--src/man/jailcheck.1.in (renamed from src/man/jailcheck.txt)0
-rwxr-xr-xsrc/man/mkman.sh8
16 files changed, 52 insertions, 49 deletions
diff --git a/src/firejail/firejail.h b/src/firejail/firejail.h
index d85b470e6..c791913ea 100644
--- a/src/firejail/firejail.h
+++ b/src/firejail/firejail.h
@@ -357,6 +357,7 @@ extern int arg_deterministic_exit_code; // always exit with first child's exit s
357extern int arg_deterministic_shutdown; // shut down the sandbox if first child dies 357extern int arg_deterministic_shutdown; // shut down the sandbox if first child dies
358extern int arg_keep_fd_all; // inherit all file descriptors to sandbox 358extern int arg_keep_fd_all; // inherit all file descriptors to sandbox
359extern int arg_netlock; // netlocker 359extern int arg_netlock; // netlocker
360extern int arg_restrict_namespaces;
360 361
361typedef enum { 362typedef enum {
362 DBUS_POLICY_ALLOW, // Allow unrestricted access to the bus 363 DBUS_POLICY_ALLOW, // Allow unrestricted access to the bus
diff --git a/src/firejail/main.c b/src/firejail/main.c
index 732ca93c2..45b199db4 100644
--- a/src/firejail/main.c
+++ b/src/firejail/main.c
@@ -165,6 +165,7 @@ int arg_tab = 0;
165int login_shell = 0; 165int login_shell = 0;
166int just_run_the_shell = 0; 166int just_run_the_shell = 0;
167int arg_netlock = 0; 167int arg_netlock = 0;
168int arg_restrict_namespaces = 0;
168 169
169int parent_to_child_fds[2]; 170int parent_to_child_fds[2];
170int child_to_parent_fds[2]; 171int child_to_parent_fds[2];
@@ -1508,8 +1509,10 @@ int main(int argc, char **argv, char **envp) {
1508 exit_err_feature("seccomp"); 1509 exit_err_feature("seccomp");
1509 } 1510 }
1510 else if (strcmp(argv[i], "--restrict-namespaces") == 0) { 1511 else if (strcmp(argv[i], "--restrict-namespaces") == 0) {
1511 if (checkcfg(CFG_SECCOMP)) 1512 if (checkcfg(CFG_SECCOMP)) {
1513 arg_restrict_namespaces = 1;
1512 profile_list_augment(&cfg.restrict_namespaces, "cgroup,ipc,net,mnt,pid,time,user,uts"); 1514 profile_list_augment(&cfg.restrict_namespaces, "cgroup,ipc,net,mnt,pid,time,user,uts");
1515 }
1513 else 1516 else
1514 exit_err_feature("seccomp"); 1517 exit_err_feature("seccomp");
1515 } 1518 }
diff --git a/src/firejail/preproc.c b/src/firejail/preproc.c
index 6055ec95b..e0c11a005 100644
--- a/src/firejail/preproc.c
+++ b/src/firejail/preproc.c
@@ -96,12 +96,16 @@ void preproc_mount_mnt_dir(void) {
96 if (set_perms(RUN_SECCOMP_PROTOCOL, getuid(), getgid(), 0644)) 96 if (set_perms(RUN_SECCOMP_PROTOCOL, getuid(), getgid(), 0644))
97 errExit("set_perms"); 97 errExit("set_perms");
98 if (cfg.restrict_namespaces) { 98 if (cfg.restrict_namespaces) {
99 copy_file(PATH_SECCOMP_NAMESPACES, RUN_SECCOMP_NS, getuid(), getgid(), 0644); // root needed
100 copy_file(PATH_SECCOMP_NAMESPACES_32, RUN_SECCOMP_NS_32, getuid(), getgid(), 0644); // root needed
101#if 0
99 create_empty_file_as_root(RUN_SECCOMP_NS, 0644); 102 create_empty_file_as_root(RUN_SECCOMP_NS, 0644);
100 if (set_perms(RUN_SECCOMP_NS, getuid(), getgid(), 0644)) 103 if (set_perms(RUN_SECCOMP_NS, getuid(), getgid(), 0644))
101 errExit("set_perms"); 104 errExit("set_perms");
102 create_empty_file_as_root(RUN_SECCOMP_NS_32, 0644); 105 create_empty_file_as_root(RUN_SECCOMP_NS_32, 0644);
103 if (set_perms(RUN_SECCOMP_NS_32, getuid(), getgid(), 0644)) 106 if (set_perms(RUN_SECCOMP_NS_32, getuid(), getgid(), 0644))
104 errExit("set_perms"); 107 errExit("set_perms");
108#endif
105 } 109 }
106 create_empty_file_as_root(RUN_SECCOMP_POSTEXEC, 0644); 110 create_empty_file_as_root(RUN_SECCOMP_POSTEXEC, 0644);
107 if (set_perms(RUN_SECCOMP_POSTEXEC, getuid(), getgid(), 0644)) 111 if (set_perms(RUN_SECCOMP_POSTEXEC, getuid(), getgid(), 0644))
diff --git a/src/firejail/profile.c b/src/firejail/profile.c
index ae881664b..07449f646 100644
--- a/src/firejail/profile.c
+++ b/src/firejail/profile.c
@@ -1088,8 +1088,10 @@ int profile_check_line(char *ptr, int lineno, const char *fname) {
1088 1088
1089 // restrict-namespaces 1089 // restrict-namespaces
1090 if (strcmp(ptr, "restrict-namespaces") == 0) { 1090 if (strcmp(ptr, "restrict-namespaces") == 0) {
1091 if (checkcfg(CFG_SECCOMP)) 1091 if (checkcfg(CFG_SECCOMP)) {
1092 arg_restrict_namespaces = 1;
1092 profile_list_augment(&cfg.restrict_namespaces, "cgroup,ipc,net,mnt,pid,time,user,uts"); 1093 profile_list_augment(&cfg.restrict_namespaces, "cgroup,ipc,net,mnt,pid,time,user,uts");
1094 }
1093 else 1095 else
1094 warning_feature_disabled("seccomp"); 1096 warning_feature_disabled("seccomp");
1095 return 0; 1097 return 0;
diff --git a/src/firejail/sandbox.c b/src/firejail/sandbox.c
index 9eb476f16..538f5be67 100644
--- a/src/firejail/sandbox.c
+++ b/src/firejail/sandbox.c
@@ -1211,7 +1211,19 @@ int sandbox(void* sandbox_arg) {
1211 seccomp_load(RUN_SECCOMP_MDWX_32); 1211 seccomp_load(RUN_SECCOMP_MDWX_32);
1212 } 1212 }
1213 1213
1214 if (cfg.restrict_namespaces) { 1214 if (arg_restrict_namespaces) {
1215 if (arg_seccomp_error_action != EPERM) {
1216 seccomp_filter_namespaces(true, cfg.restrict_namespaces);
1217 seccomp_filter_namespaces(false, cfg.restrict_namespaces);
1218 }
1219
1220 if (arg_debug)
1221 printf("Install namespaces filter\n");
1222 seccomp_load(RUN_SECCOMP_NS); // install filter
1223 seccomp_load(RUN_SECCOMP_NS_32);
1224
1225 }
1226 else if (cfg.restrict_namespaces) {
1215 seccomp_filter_namespaces(true, cfg.restrict_namespaces); 1227 seccomp_filter_namespaces(true, cfg.restrict_namespaces);
1216 seccomp_filter_namespaces(false, cfg.restrict_namespaces); 1228 seccomp_filter_namespaces(false, cfg.restrict_namespaces);
1217 1229
diff --git a/src/fnettrace/Makefile b/src/fnettrace/Makefile
index 9748a3b47..68a4cbdc0 100644
--- a/src/fnettrace/Makefile
+++ b/src/fnettrace/Makefile
@@ -11,6 +11,3 @@ include $(ROOT)/src/prog.mk
11all: $(TARGET) static-ip-map 11all: $(TARGET) static-ip-map
12static-ip-map: static-ip-map.txt fnettrace 12static-ip-map: static-ip-map.txt fnettrace
13 ./fnettrace --squash-map=static-ip-map.txt > static-ip-map 13 ./fnettrace --squash-map=static-ip-map.txt > static-ip-map
14
15
16
diff --git a/src/include/rundefs.h b/src/include/rundefs.h
index 7fc0f21f3..d36851a4e 100644
--- a/src/include/rundefs.h
+++ b/src/include/rundefs.h
@@ -79,6 +79,8 @@
79#define PATH_SECCOMP_DEBUG_32 LIBDIR "/firejail/seccomp.debug32" // 32bit arch debug filter built during make 79#define PATH_SECCOMP_DEBUG_32 LIBDIR "/firejail/seccomp.debug32" // 32bit arch debug filter built during make
80#define PATH_SECCOMP_MDWX LIBDIR "/firejail/seccomp.mdwx" // filter for memory-deny-write-execute built during make 80#define PATH_SECCOMP_MDWX LIBDIR "/firejail/seccomp.mdwx" // filter for memory-deny-write-execute built during make
81#define PATH_SECCOMP_MDWX_32 LIBDIR "/firejail/seccomp.mdwx.32" 81#define PATH_SECCOMP_MDWX_32 LIBDIR "/firejail/seccomp.mdwx.32"
82#define PATH_SECCOMP_NAMESPACES LIBDIR "/firejail/seccomp.namespaces" // filter for restrict-namespaces
83#define PATH_SECCOMP_NAMESPACES_32 LIBDIR "/firejail/seccomp.namespaces.32"
82#define PATH_SECCOMP_BLOCK_SECONDARY LIBDIR "/firejail/seccomp.block_secondary" // secondary arch blocking filter built during make 84#define PATH_SECCOMP_BLOCK_SECONDARY LIBDIR "/firejail/seccomp.block_secondary" // secondary arch blocking filter built during make
83 85
84#define RUN_DEV_DIR RUN_MNT_DIR "/dev" 86#define RUN_DEV_DIR RUN_MNT_DIR "/dev"
diff --git a/src/man/Makefile b/src/man/Makefile
index 17c5cde13..526ed7fcb 100644
--- a/src/man/Makefile
+++ b/src/man/Makefile
@@ -2,45 +2,25 @@
2ROOT = ../.. 2ROOT = ../..
3-include $(ROOT)/config.mk 3-include $(ROOT)/config.mk
4 4
5all: firecfg.1.gz firejail.1.gz firejail-login.5.gz firejail-users.5.gz firejail-profile.5.gz firemon.1.gz jailcheck.1.gz 5MOD_DIR := $(ROOT)/src/man
6 6MANPAGES_IN := $(sort $(wildcard $(MOD_DIR)/*.in))
7#firecfg.1.gz: firecfg.txt 7MANPAGES_GZ := $(MANPAGES_IN:.in=.gz)
8# gawk -f ./preproc.awk -- $(MANFLAGS) < $< > firecfg.1 8TARGET = $(MANPAGES_GZ)
9# ./mkman.sh $(VERSION) firecfg.1 9
10# gzip -n9 firecfg.1 10.PHONY: all
11 11all: $(TARGET)
12# a small function to build a manpage 12
13define build 13# foo.1: foo.1.in
14 gawk -f ./preproc.awk -- $(MANFLAGS) < $1 > $2 14$(MOD_DIR)/%: $(MOD_DIR)/%.in $(ROOT)/config.mk
15 ./mkman.sh $(VERSION) ./$2 15 @printf 'Generating %s from %s\n' $@ $<
16 rm -f $2.gz 16 @gawk -f $(MOD_DIR)/preproc.awk -- $(MANFLAGS) <$< | \
17 gzip -n9 $2 17 $(MOD_DIR)/mkman.sh $(VERSION) >$@
18endef 18
19 19# foo.1.gz: foo.1
20firecfg.1.gz: firecfg.txt 20$(MOD_DIR)/%.gz: $(MOD_DIR)/%
21 $(call build,firecfg.txt,firecfg.1) 21 @printf 'Generating %s from %s\n' $@ $<
22 22 @rm -f $@
23firejail.1.gz: firejail.txt 23 @gzip -n9 $<
24 $(call build,firejail.txt,firejail.1)
25
26firejail-login.5.gz: firejail-login.txt
27 $(call build,firejail-login.txt,firejail-login.5)
28
29firejail-users.5.gz: firejail-users.txt
30 $(call build,firejail-users.txt,firejail-users.5)
31
32firejail-profile.5.gz: firejail-profile.txt
33 $(call build,firejail-profile.txt,firejail-profile.5)
34
35firemon.1.gz: firemon.txt
36 $(call build,firemon.txt,firemon.1)
37
38jailcheck.1.gz: jailcheck.txt
39 $(call build,jailcheck.txt,jailcheck.1)
40
41 24
42.PHONY: clean 25.PHONY: clean
43clean:; rm -fr *.1 *.5 *.gz 26clean:; rm -f *.1 *.5 *.gz
44
45.PHONY: distclean
46distclean: clean
diff --git a/src/man/firecfg.txt b/src/man/firecfg.1.in
index 42add6a41..42add6a41 100644
--- a/src/man/firecfg.txt
+++ b/src/man/firecfg.1.in
diff --git a/src/man/firejail-login.txt b/src/man/firejail-login.5.in
index f03fc3c37..f03fc3c37 100644
--- a/src/man/firejail-login.txt
+++ b/src/man/firejail-login.5.in
diff --git a/src/man/firejail-profile.txt b/src/man/firejail-profile.5.in
index fa294d888..fa294d888 100644
--- a/src/man/firejail-profile.txt
+++ b/src/man/firejail-profile.5.in
diff --git a/src/man/firejail-users.txt b/src/man/firejail-users.5.in
index 7aa151680..7aa151680 100644
--- a/src/man/firejail-users.txt
+++ b/src/man/firejail-users.5.in
diff --git a/src/man/firejail.txt b/src/man/firejail.1.in
index 19fc94ebd..19fc94ebd 100644
--- a/src/man/firejail.txt
+++ b/src/man/firejail.1.in
diff --git a/src/man/firemon.txt b/src/man/firemon.1.in
index fb0cf1175..fb0cf1175 100644
--- a/src/man/firemon.txt
+++ b/src/man/firemon.1.in
diff --git a/src/man/jailcheck.txt b/src/man/jailcheck.1.in
index e889ea91b..e889ea91b 100644
--- a/src/man/jailcheck.txt
+++ b/src/man/jailcheck.1.in
diff --git a/src/man/mkman.sh b/src/man/mkman.sh
index b538b0126..0302e0778 100755
--- a/src/man/mkman.sh
+++ b/src/man/mkman.sh
@@ -5,8 +5,10 @@
5 5
6set -e 6set -e
7 7
8sed -i "s/VERSION/$1/g" "$2"
9MONTH="$(LC_ALL=C date -u --date="@${SOURCE_DATE_EPOCH:-$(date +%s)}" +%b)" 8MONTH="$(LC_ALL=C date -u --date="@${SOURCE_DATE_EPOCH:-$(date +%s)}" +%b)"
10sed -i "s/MONTH/$MONTH/g" "$2"
11YEAR="$(LC_ALL=C date -u --date="@${SOURCE_DATE_EPOCH:-$(date +%s)}" +%Y)" 9YEAR="$(LC_ALL=C date -u --date="@${SOURCE_DATE_EPOCH:-$(date +%s)}" +%Y)"
12sed -i "s/YEAR/$YEAR/g" "$2" 10
11sed \
12 -e "s/VERSION/$1/g" \
13 -e "s/MONTH/$MONTH/g" \
14 -e "s/YEAR/$YEAR/g"