fix whitelist ~/deletme problem

This commit is contained in:
netblue30 2016-08-05 08:39:56 -04:00
parent 323c26b4ad
commit 265cd772fc
3 changed files with 54 additions and 6 deletions

View file

@ -268,6 +268,7 @@ static void whitelist_path(ProfileEntry *entry) {
// process regular file
else {
if (access(path, R_OK)) {
// create an empty file
FILE *fp = fopen(path, "w");
if (!fp) {
@ -276,6 +277,9 @@ static void whitelist_path(ProfileEntry *entry) {
}
fclose(fp);
}
else
return; // the file is already present
}
// set file properties
if (chown(path, s.st_uid, s.st_gid) < 0)

View file

@ -54,3 +54,5 @@ echo "TESTING: bind as user (test/fs/option_bind_user.exp)"
echo "TESTING: recursive mkdir (test/fs/mkdir.exp)"
./mkdir.exp
echo "TESTING: double whitelist (test/fs/whitelist-double.exp)"
./whitelist-double.exp

42
test/fs/whitelist-double.exp Executable file
View file

@ -0,0 +1,42 @@
#!/usr/bin/expect -f
# This file is part of Firejail project
# Copyright (C) 2014-2016 Firejail Authors
# License GPL v2
set timeout 30
spawn $env(SHELL)
match_max 100000
send -- "echo 123 > /tmp/firejal-deleteme\r"
sleep 1
send -- "firejail --whitelist=/tmp/firejal-deleteme --whitelist=/tmp/firejal-deleteme\r"
expect {
timeout {puts "TESTING ERROR 0\n";exit}
"Child process initialized"
}
sleep 1
send -- "cat /tmp/firejal-deleteme\r"
expect {
timeout {puts "TESTING ERROR 1\n";exit}
"123"
}
send -- "exit\r"
sleep 1
send -- "cat /tmp/firejal-deleteme\r"
expect {
timeout {puts "TESTING ERROR 1\n";exit}
"123"
}
send -- "rm/tmp/firejal-deleteme \r"
expect {
timeout {puts "TESTING ERROR 3\n";exit}
"0"
}
sleep 1
puts "\nall done\n"