aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile.in4
-rw-r--r--etc/firefox.profile1
-rw-r--r--src/firejail/firejail.h4
-rw-r--r--src/firejail/fs.c10
-rw-r--r--src/firejail/fs_bin.c5
-rw-r--r--src/firejail/fs_var.c2
-rw-r--r--src/firejail/profile.c8
-rwxr-xr-xtest/chromium.exp10
-rwxr-xr-xtest/fscheck-shell.exp14
-rwxr-xr-xtest/private-bin.exp71
-rw-r--r--test/private-bin.profile1
-rwxr-xr-xtest/test.sh12
12 files changed, 116 insertions, 26 deletions
diff --git a/Makefile.in b/Makefile.in
index 4d00e3aef..14fbaa0bf 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -8,7 +8,9 @@ bindir=@bindir@
8libdir=@libdir@ 8libdir=@libdir@
9datarootdir=@datarootdir@ 9datarootdir=@datarootdir@
10mandir=@mandir@ 10mandir=@mandir@
11sysconfdir=@sysconfdir@ 11# todo: fix sysconfdir
12# sysconfdir=@sysconfdir@
13sysconfdir=/etc
12 14
13VERSION=@PACKAGE_VERSION@ 15VERSION=@PACKAGE_VERSION@
14NAME=@PACKAGE_NAME@ 16NAME=@PACKAGE_NAME@
diff --git a/etc/firefox.profile b/etc/firefox.profile
index b31f25fc6..fae7d7ad4 100644
--- a/etc/firefox.profile
+++ b/etc/firefox.profile
@@ -8,6 +8,5 @@ caps.drop all
8seccomp 8seccomp
9netfilter 9netfilter
10noroot 10noroot
11shell none
12 11
13 12
diff --git a/src/firejail/firejail.h b/src/firejail/firejail.h
index 64cf3ccef..cbc4086fb 100644
--- a/src/firejail/firejail.h
+++ b/src/firejail/firejail.h
@@ -407,5 +407,9 @@ void errno_print(void);
407// pulseaudio.c 407// pulseaudio.c
408void pulseaudio_init(void); 408void pulseaudio_init(void);
409 409
410// fs_bin.c
411void fs_check_bin_list(void);
412void fs_private_bin_list(void);
413
410#endif 414#endif
411 415
diff --git a/src/firejail/fs.c b/src/firejail/fs.c
index 54086e0bb..b3748de51 100644
--- a/src/firejail/fs.c
+++ b/src/firejail/fs.c
@@ -435,23 +435,23 @@ void fs_proc_sys_dev_boot(void) {
435 if (arg_debug) 435 if (arg_debug)
436 printf("Disable /sys/firmware directory\n"); 436 printf("Disable /sys/firmware directory\n");
437 if (mount("tmpfs", "/sys/firmware", "tmpfs", MS_NOSUID | MS_NODEV | MS_STRICTATIME | MS_REC, "mode=755,gid=0") < 0) 437 if (mount("tmpfs", "/sys/firmware", "tmpfs", MS_NOSUID | MS_NODEV | MS_STRICTATIME | MS_REC, "mode=755,gid=0") < 0)
438 errExit("disable /sys/firmware directory"); 438 fprintf(stderr, "Warning: cannot disable /sys/firmware directory\n");
439 if (arg_debug) 439 if (arg_debug)
440 printf("Disable /sys/hypervisor directory\n"); 440 printf("Disable /sys/hypervisor directory\n");
441 if (mount("tmpfs", "/sys/hypervisor", "tmpfs", MS_NOSUID | MS_NODEV | MS_STRICTATIME | MS_REC, "mode=755,gid=0") < 0) 441 if (mount("tmpfs", "/sys/hypervisor", "tmpfs", MS_NOSUID | MS_NODEV | MS_STRICTATIME | MS_REC, "mode=755,gid=0") < 0)
442 errExit("disable /sys/hypervisor directory"); 442 fprintf(stderr, "Warning: cannot disable /sys/hypervisor directory\n");
443 if (arg_debug) 443 if (arg_debug)
444 printf("Disable /sys/fs directory\n"); 444 printf("Disable /sys/fs directory\n");
445 if (mount("tmpfs", "/sys/fs", "tmpfs", MS_NOSUID | MS_NODEV | MS_STRICTATIME | MS_REC, "mode=755,gid=0") < 0) 445 if (mount("tmpfs", "/sys/fs", "tmpfs", MS_NOSUID | MS_NODEV | MS_STRICTATIME | MS_REC, "mode=755,gid=0") < 0)
446 errExit("disable /sys/fs directory"); 446 fprintf(stderr, "Warning: cannot disable /sys/fs directory\n");
447 if (arg_debug) 447 if (arg_debug)
448 printf("Disable /sys/module directory\n"); 448 printf("Disable /sys/module directory\n");
449 if (mount("tmpfs", "/sys/module", "tmpfs", MS_NOSUID | MS_NODEV | MS_STRICTATIME | MS_REC, "mode=755,gid=0") < 0) 449 if (mount("tmpfs", "/sys/module", "tmpfs", MS_NOSUID | MS_NODEV | MS_STRICTATIME | MS_REC, "mode=755,gid=0") < 0)
450 errExit("disable /sys/module directory"); 450 fprintf(stderr, "Warning: cannot disable /sys/module directory\n");
451 if (arg_debug) 451 if (arg_debug)
452 printf("Disable /sys/power directory\n"); 452 printf("Disable /sys/power directory\n");
453 if (mount("tmpfs", "/sys/power", "tmpfs", MS_NOSUID | MS_NODEV | MS_STRICTATIME | MS_REC, "mode=755,gid=0") < 0) 453 if (mount("tmpfs", "/sys/power", "tmpfs", MS_NOSUID | MS_NODEV | MS_STRICTATIME | MS_REC, "mode=755,gid=0") < 0)
454 errExit("disable /sys/power directory"); 454 fprintf(stderr, "Warning: cannot disable /sys/power directory\n");
455 455
456 456
457 457
diff --git a/src/firejail/fs_bin.c b/src/firejail/fs_bin.c
index 4b3292b6c..dcfdadb6b 100644
--- a/src/firejail/fs_bin.c
+++ b/src/firejail/fs_bin.c
@@ -44,9 +44,9 @@ static char *check_dir_or_file(const char *name) {
44 errExit("asprintf"); 44 errExit("asprintf");
45 if (arg_debug) 45 if (arg_debug)
46 printf("Checking %s/%s\n", paths[i], name); 46 printf("Checking %s/%s\n", paths[i], name);
47 if (stat(fname, &s) == 0) 47 if (stat(fname, &s) == 0 && !S_ISDIR(s.st_mode)) // do not allow directories
48 break; // file found 48 break; // file found
49 49
50 free(fname); 50 free(fname);
51 fname = NULL; 51 fname = NULL;
52 i++; 52 i++;
@@ -99,7 +99,6 @@ void fs_check_bin_list(void) {
99 else 99 else
100 notfound = 1; 100 notfound = 1;
101 } 101 }
102printf("here %d: newlist #%s#\n", __LINE__, newlist);
103 102
104 if (*newlist == '\0') { 103 if (*newlist == '\0') {
105 fprintf(stderr, "Warning: no --private-bin list executable found, option disabled\n"); 104 fprintf(stderr, "Warning: no --private-bin list executable found, option disabled\n");
diff --git a/src/firejail/fs_var.c b/src/firejail/fs_var.c
index 3200c5282..93625633a 100644
--- a/src/firejail/fs_var.c
+++ b/src/firejail/fs_var.c
@@ -146,7 +146,7 @@ void fs_var_log(void) {
146 errExit("chmod"); 146 errExit("chmod");
147 } 147 }
148 else 148 else
149 fprintf(stderr, "Warning: cannot mount tmpfs in top of /var/log\n"); 149 fprintf(stderr, "Warning: cannot mount tmpfs on top of /var/log\n");
150} 150}
151 151
152void fs_var_lib(void) { 152void fs_var_lib(void) {
diff --git a/src/firejail/profile.c b/src/firejail/profile.c
index 2863b454e..5b18cc179 100644
--- a/src/firejail/profile.c
+++ b/src/firejail/profile.c
@@ -257,6 +257,14 @@ int profile_check_line(char *ptr, int lineno) {
257 return 0; 257 return 0;
258 } 258 }
259 259
260 // private /bin list of files
261 if (strncmp(ptr, "private-bin ", 12) == 0) {
262 cfg.bin_private_keep = ptr + 12;
263 fs_check_bin_list();
264 arg_private_bin = 1;
265 return 0;
266 }
267
260 // filesystem bind 268 // filesystem bind
261 if (strncmp(ptr, "bind ", 5) == 0) { 269 if (strncmp(ptr, "bind ", 5) == 0) {
262 if (getuid() != 0) { 270 if (getuid() != 0) {
diff --git a/test/chromium.exp b/test/chromium.exp
index 020826f3d..77325d070 100755
--- a/test/chromium.exp
+++ b/test/chromium.exp
@@ -4,10 +4,10 @@ set timeout 10
4spawn $env(SHELL) 4spawn $env(SHELL)
5match_max 100000 5match_max 100000
6 6
7send -- "firejail chromium-browser www.gentoo.org\r" 7send -- "firejail chromium www.gentoo.org\r"
8expect { 8expect {
9 timeout {puts "TESTING ERROR 0\n";exit} 9 timeout {puts "TESTING ERROR 0\n";exit}
10 "Reading profile /etc/firejail/chromium-browser.profile" 10 "Reading profile /etc/firejail/chromium.profile"
11} 11}
12expect { 12expect {
13 timeout {puts "TESTING ERROR 1\n";exit} 13 timeout {puts "TESTING ERROR 1\n";exit}
@@ -23,7 +23,7 @@ expect {
23} 23}
24expect { 24expect {
25 timeout {puts "TESTING ERROR 3.1\n";exit} 25 timeout {puts "TESTING ERROR 3.1\n";exit}
26 "chromium-browser" 26 "chromium"
27} 27}
28sleep 1 28sleep 1
29 29
@@ -38,7 +38,7 @@ spawn $env(SHELL)
38send -- "firemon --seccomp\r" 38send -- "firemon --seccomp\r"
39expect { 39expect {
40 timeout {puts "TESTING ERROR 5\n";exit} 40 timeout {puts "TESTING ERROR 5\n";exit}
41 ":firejail chromium-browser" 41 ":firejail chromium"
42} 42}
43expect { 43expect {
44 timeout {puts "TESTING ERROR 5.1\n";exit} 44 timeout {puts "TESTING ERROR 5.1\n";exit}
@@ -52,7 +52,7 @@ sleep 1
52send -- "firemon --caps\r" 52send -- "firemon --caps\r"
53expect { 53expect {
54 timeout {puts "TESTING ERROR 6\n";exit} 54 timeout {puts "TESTING ERROR 6\n";exit}
55 ":firejail chromium-browser" 55 ":firejail chromium"
56} 56}
57expect { 57expect {
58 timeout {puts "TESTING ERROR 6.1\n";exit} 58 timeout {puts "TESTING ERROR 6.1\n";exit}
diff --git a/test/fscheck-shell.exp b/test/fscheck-shell.exp
index d2320a4c3..548955e60 100755
--- a/test/fscheck-shell.exp
+++ b/test/fscheck-shell.exp
@@ -15,7 +15,7 @@ after 100
15# .. 15# ..
16send -- "firejail --net=br0 --shell=../test/fscheck-dir\r" 16send -- "firejail --net=br0 --shell=../test/fscheck-dir\r"
17expect { 17expect {
18 timeout {puts "TESTING ERROR 0.1\n";exit} 18 timeout {puts "TESTING ERROR 1\n";exit}
19 "Error" 19 "Error"
20} 20}
21after 100 21after 100
@@ -23,7 +23,7 @@ after 100
23# dir link 23# dir link
24send -- "firejail --net=br0 --shell=fscheck-dir-link\r" 24send -- "firejail --net=br0 --shell=fscheck-dir-link\r"
25expect { 25expect {
26 timeout {puts "TESTING ERROR 1\n";exit} 26 timeout {puts "TESTING ERROR 2\n";exit}
27 "Error" 27 "Error"
28} 28}
29after 100 29after 100
@@ -31,7 +31,7 @@ after 100
31# .. 31# ..
32send -- "firejail --net=br0 --shell=../test/fscheck-dir-link\r" 32send -- "firejail --net=br0 --shell=../test/fscheck-dir-link\r"
33expect { 33expect {
34 timeout {puts "TESTING ERROR 1.1\n";exit} 34 timeout {puts "TESTING ERROR 3\n";exit}
35 "Error" 35 "Error"
36} 36}
37after 100 37after 100
@@ -39,7 +39,7 @@ after 100
39# file link 39# file link
40send -- "firejail --net=br0 --shell=fscheck-file-link\r" 40send -- "firejail --net=br0 --shell=fscheck-file-link\r"
41expect { 41expect {
42 timeout {puts "TESTING ERROR 2\n";exit} 42 timeout {puts "TESTING ERROR 4\n";exit}
43 "Error" 43 "Error"
44} 44}
45after 100 45after 100
@@ -47,7 +47,7 @@ after 100
47# .. 47# ..
48send -- "firejail --net=br0 --shell=../test/fscheck-file-link\r" 48send -- "firejail --net=br0 --shell=../test/fscheck-file-link\r"
49expect { 49expect {
50 timeout {puts "TESTING ERROR 2\n";exit} 50 timeout {puts "TESTING ERROR 5\n";exit}
51 "Error" 51 "Error"
52} 52}
53after 100 53after 100
@@ -55,7 +55,7 @@ after 100
55# no file 55# no file
56send -- "firejail --net=br0 --shell=../test/nofile\r" 56send -- "firejail --net=br0 --shell=../test/nofile\r"
57expect { 57expect {
58 timeout {puts "TESTING ERROR 3\n";exit} 58 timeout {puts "TESTING ERROR 6\n";exit}
59 "Error" 59 "Error"
60} 60}
61after 100 61after 100
@@ -63,7 +63,7 @@ after 100
63# real GID/UID 63# real GID/UID
64send -- "firejail --net=br0 --shell=/etc/shadow\r" 64send -- "firejail --net=br0 --shell=/etc/shadow\r"
65expect { 65expect {
66 timeout {puts "TESTING ERROR 4\n";exit} 66 timeout {puts "TESTING ERROR 7\n";exit}
67 "Error" 67 "Error"
68} 68}
69after 100 69after 100
diff --git a/test/private-bin.exp b/test/private-bin.exp
new file mode 100755
index 000000000..cc5ea99c7
--- /dev/null
+++ b/test/private-bin.exp
@@ -0,0 +1,71 @@
1#!/usr/bin/expect -f
2
3set timeout 10
4spawn $env(SHELL)
5match_max 100000
6
7send -- "firejail --private-bin=bash,ls,sh\r"
8expect {
9 timeout {puts "TESTING ERROR 1\n";exit}
10 "Child process initialized"
11}
12sleep 1
13
14send -- "ls -al /bin\r"
15expect {
16 timeout {puts "TESTING ERROR 2\n";exit}
17 "bash"
18}
19expect {
20 timeout {puts "TESTING ERROR 3\n";exit}
21 "ls"
22}
23expect {
24 timeout {puts "TESTING ERROR 4\n";exit}
25 "sh"
26}
27
28send -- "ls -al /bin\r"
29expect {
30 timeout {puts "TESTING ERROR 5\n";exit}
31 "ping" {puts "TESTING ERROR 6\n";exit}
32 "sh"
33}
34send -- "exit\r"
35sleep 1
36
37send -- "firejail --profile=private-bin.profile\r"
38expect {
39 timeout {puts "TESTING ERROR 7\n";exit}
40 "Child process initialized"
41}
42sleep 1
43
44send -- "ls -al /bin\r"
45expect {
46 timeout {puts "TESTING ERROR 8\n";exit}
47 "bash"
48}
49expect {
50 timeout {puts "TESTING ERROR 9\n";exit}
51 "ls"
52}
53expect {
54 timeout {puts "TESTING ERROR 10\n";exit}
55 "sh"
56}
57
58send -- "ls -al /bin\r"
59expect {
60 timeout {puts "TESTING ERROR 5\n";exit}
61 "ping" {puts "TESTING ERROR 6\n";exit}
62 "sh"
63}
64send -- "exit\r"
65
66
67
68
69sleep 1
70puts "\nall done\n"
71
diff --git a/test/private-bin.profile b/test/private-bin.profile
new file mode 100644
index 000000000..24cf5929a
--- /dev/null
+++ b/test/private-bin.profile
@@ -0,0 +1 @@
private-bin bash,ls,sh
diff --git a/test/test.sh b/test/test.sh
index 6f198cd52..2e7b1e2bc 100755
--- a/test/test.sh
+++ b/test/test.sh
@@ -18,9 +18,15 @@ echo "TESTING: environment variables"
18echo "TESTING: private-etc" 18echo "TESTING: private-etc"
19./private-etc.exp 19./private-etc.exp
20 20
21echo "TESTING: private-bin"
22./private-bin.exp
23
24sleep 1
25rm -fr dir\ with\ space
21mkdir dir\ with\ space 26mkdir dir\ with\ space
22echo "TESTING: blacklist" 27echo "TESTING: blacklist"
23./blacklist.exp 28./blacklist.exp
29sleep 1
24rm -fr dir\ with\ space 30rm -fr dir\ with\ space
25 31
26ln -s auto auto2 32ln -s auto auto2
@@ -155,7 +161,7 @@ else
155 echo "TESTING: midori not found" 161 echo "TESTING: midori not found"
156fi 162fi
157 163
158which chromium-browser 164which chromium
159if [ "$?" -eq 0 ]; 165if [ "$?" -eq 0 ];
160then 166then
161 echo "TESTING: chromium" 167 echo "TESTING: chromium"
@@ -278,10 +284,10 @@ echo "TESTING: seccomp su"
278echo "TESTING: seccomp ptrace" 284echo "TESTING: seccomp ptrace"
279./seccomp-ptrace.exp 285./seccomp-ptrace.exp
280 286
281echo "TESTING: seccomp chmod (seccomp lists)" 287echo "TESTING: seccomp chmod - seccomp lists"
282./seccomp-chmod.exp 288./seccomp-chmod.exp
283 289
284echo "TESTING: seccomp chmod profile (seccomp lists)" 290echo "TESTING: seccomp chmod profile - seccomp lists"
285./seccomp-chmod-profile.exp 291./seccomp-chmod-profile.exp
286 292
287echo "TESTING: seccomp empty" 293echo "TESTING: seccomp empty"