aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/firejail/fs.c21
-rwxr-xr-xtest/blacklist-link.exp50
-rw-r--r--test/blacklist3.profile1
-rwxr-xr-xtest/test.sh6
4 files changed, 70 insertions, 8 deletions
diff --git a/src/firejail/fs.c b/src/firejail/fs.c
index f4384faf7..1cfdbaea7 100644
--- a/src/firejail/fs.c
+++ b/src/firejail/fs.c
@@ -153,15 +153,20 @@ static void disable_file(OPERATION op, const char *filename, const char *emptydi
153 153
154 // modify the file 154 // modify the file
155 if (op == BLACKLIST_FILE) { 155 if (op == BLACKLIST_FILE) {
156 if (arg_debug) 156 // some distros put all executables under /usr/bin and make /bin a symbolic link
157 printf("Disable %s\n", fname); 157 if (is_link(filename) && S_ISDIR(s.st_mode))
158 if (S_ISDIR(s.st_mode)) { 158 fprintf(stderr, "Warning: %s directory link was not blacklisted\n", filename);
159 if (mount(emptydir, fname, "none", MS_BIND, "mode=400,gid=0") < 0)
160 errExit("disable file");
161 }
162 else { 159 else {
163 if (mount(emptyfile, fname, "none", MS_BIND, "mode=400,gid=0") < 0) 160 if (arg_debug)
164 errExit("disable file"); 161 printf("Disable %s\n", fname);
162 if (S_ISDIR(s.st_mode)) {
163 if (mount(emptydir, fname, "none", MS_BIND, "mode=400,gid=0") < 0)
164 errExit("disable file");
165 }
166 else {
167 if (mount(emptyfile, fname, "none", MS_BIND, "mode=400,gid=0") < 0)
168 errExit("disable file");
169 }
165 } 170 }
166 } 171 }
167 else if (op == MOUNT_READONLY) { 172 else if (op == MOUNT_READONLY) {
diff --git a/test/blacklist-link.exp b/test/blacklist-link.exp
new file mode 100755
index 000000000..da52cae4a
--- /dev/null
+++ b/test/blacklist-link.exp
@@ -0,0 +1,50 @@
1#!/usr/bin/expect -f
2
3set timeout 10
4spawn $env(SHELL)
5match_max 100000
6
7# blacklist a directory symlink
8send -- "firejail --blacklist=auto2\r"
9expect {
10 timeout {puts "TESTING ERROR 1\n";exit}
11 "directory link was not blacklisted"
12}
13expect {
14 timeout {puts "TESTING ERROR 1.1\n";exit}
15 "Child process initialized"
16}
17sleep 1
18
19send -- "file auto2\r"
20expect {
21 timeout {puts "TESTING ERROR 2\n";exit}
22 "symbolic link to"
23}
24send -- "exit\r"
25sleep 1
26
27# blacklist a directory symlink from a profile file
28send -- "firejail --profile=blacklist3.profile\r"
29expect {
30 timeout {puts "TESTING ERROR 3\n";exit}
31 "directory link was not blacklisted"
32}
33expect {
34 timeout {puts "TESTING ERROR 3.1\n";exit}
35 "Child process initialized"
36}
37sleep 1
38
39send -- "file auto2\r"
40expect {
41 timeout {puts "TESTING ERROR 4\n";exit}
42 "symbolic link to"
43}
44send -- "exit\r"
45sleep 1
46
47
48
49puts "all done\n"
50
diff --git a/test/blacklist3.profile b/test/blacklist3.profile
new file mode 100644
index 000000000..08f754f3f
--- /dev/null
+++ b/test/blacklist3.profile
@@ -0,0 +1 @@
blacklist auto2
diff --git a/test/test.sh b/test/test.sh
index 8ddbc476f..8c6be8ddd 100755
--- a/test/test.sh
+++ b/test/test.sh
@@ -15,6 +15,12 @@ echo "TESTING: blacklist"
15./blacklist.exp 15./blacklist.exp
16rm -fr dir\ with\ space 16rm -fr dir\ with\ space
17 17
18ln -s auto auto2
19echo "TESTING: blacklist directory link"
20./blacklist-link.exp
21rm -fr auto2
22
23
18echo "TESTING: version" 24echo "TESTING: version"
19./option_version.exp 25./option_version.exp
20 26