Skip to content

Commit

Permalink
rework make test-fs
Browse files Browse the repository at this point in the history
  • Loading branch information
startx2017 committed Jul 29, 2021
1 parent 982013d commit b4424d9
Show file tree
Hide file tree
Showing 15 changed files with 164 additions and 72 deletions.
51 changes: 36 additions & 15 deletions test/fs/fs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,18 @@ echo "TESTING: mkdir/mkfile (test/fs/mkdir_mkfile.exp)"
./mkdir_mkfile.exp
rm -fr ~/_firejail_test_*

mkdir ~/_firejail_test_dir
touch ~/_firejail_test_dir/a
mkdir ~/_firejail_test_dir/test1
touch ~/_firejail_test_dir/test1/b
echo "TESTING: recursive mkdir (test/fs/mkdir.exp)"
./mkdir.exp
rm -fr ~/_firejail_test_*
rm -fr /tmp/_firejail_test_*

echo "TESTING: read/write (test/fs/read-write.exp)"
./read-write.exp
rm -fr ~/_firejail_test_dir

echo "TESTING: whitelist readonly (test/fs/whitelist-readonly.exp)"
./whitelist-readonly.exp
rm -fr ~/_firejail_test_*
rm -f ~/_firejail_test_dir

echo "TESTING: /sys/fs access (test/fs/sys_fs.exp)"
./sys_fs.exp
Expand All @@ -37,16 +40,19 @@ fi

echo "TESTING: read/write /var/tmp (test/fs/fs_var_tmp.exp)"
./fs_var_tmp.exp
rm -f /var/tmp/_firejail_test_file

echo "TESTING: private-lib (test/fs/private-lib.exp)"
./private-lib.exp

echo "TESTING: read/write /var/lock (test/fs/fs_var_lock.exp)"
./fs_var_lock.exp
rm -f /var/lock/_firejail_test_file

if [ -w /dev/shm ]; then
echo "TESTING: read/write /dev/shm (test/fs/fs_dev_shm.exp)"
./fs_dev_shm.exp
rm -f /dev/shm/_firejail_test_file
else
echo "TESTING SKIP: /dev/shm not writable"
fi
Expand All @@ -56,12 +62,23 @@ echo "TESTING: private (test/fs/private.exp)"

echo "TESTING: private home (test/fs/private-home.exp)"
./private-home.exp
rm -f ~/_firejail_test_file1
rm -f ~/_firejail_test_file2
rm -fr ~/_firejail_test_dir1
rm -f ~/_firejail_test_link1
rm -f ~/_firejail_test_link2

echo "TESTING: private home dir (test/fs/private-home-dir.exp)"
./private-home-dir.exp
rm -fr ~/_firejail_test_dir1

echo "TESTING: private home dir same as user home (test/fs/private-homedir.exp)"
./private-homedir.exp
rm -f ~/_firejail_test_file1
rm -f ~/_firejail_test_file2
rm -fr ~/_firejail_test_dir1
rm -f ~/_firejail_test_link1
rm -f ~/_firejail_test_link2

echo "TESTING: private-etc (test/fs/private-etc.exp)"
./private-etc.exp
Expand All @@ -74,6 +91,7 @@ echo "TESTING: private-bin (test/fs/private-bin.exp)"

echo "TESTING: private-cache (test/fs/private-cache.exp)"
./private-cache.exp
rm -f ~/.cache/abcdefg

echo "TESTING: private-cwd (test/fs/private-cwd.exp)"
./private-cwd.exp
Expand All @@ -83,6 +101,12 @@ echo "TESTING: macros (test/fs/macro.exp)"

echo "TESTING: whitelist empty (test/fs/whitelist-empty.exp)"
./whitelist-empty.exp
rm -f ~/Videos/_firejail_test_fil

This comment has been minimized.

Copy link
@kmk3

kmk3 Aug 3, 2021

Collaborator

@startx2017

rm -f ~/Videos/_firejail_test_fil

Typo?

rm -f ~/Pictures/_firejail_test_file
rm -f ~/Music/_firejail_test_file
rm -f ~/Downloads/_firejail_test_file
rm -f ~/Documents/_firejail_test_file
rm -f ~/Desktop/_firejail_test_file

echo "TESTING: private whitelist (test/fs/private-whitelist.exp)"
./private-whitelist.exp
Expand All @@ -95,9 +119,11 @@ echo "TESTING: blacklist directory (test/fs/option_blacklist.exp)"

echo "TESTING: blacklist file (test/fs/option_blacklist_file.exp)"
./option_blacklist_file.exp
rm -fr ~/_firejail_test_dir

echo "TESTING: blacklist glob (test/fs/option_blacklist_glob.exp)"
./option_blacklist_glob.exp
rm -fr ~/_firejail_test_dir

echo "TESTING: noblacklist blacklist noexec (test/fs/noblacklist-blacklist-noexec.exp)"
./noblacklist-blacklist-noexec.exp
Expand All @@ -108,14 +134,13 @@ echo "TESTING: noblacklist blacklist readonly (test/fs/noblacklist-blacklist-rea
echo "TESTING: bind as user (test/fs/option_bind_user.exp)"
./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
rm -f /tmp/_firejail_test_file

echo "TESTING: whitelist (test/fs/whitelist.exp)"
./whitelist.exp
rm -fr ~/_firejail_test_*

echo "TESTING: whitelist dev, var(test/fs/whitelist-dev.exp)"
./whitelist-dev.exp
Expand All @@ -131,6 +156,8 @@ echo "TESTING: fscheck --bind non root (test/fs/fscheck-bindnoroot.exp)"

echo "TESTING: fscheck --tmpfs non root (test/fs/fscheck-tmpfs.exp)"
./fscheck-tmpfs.exp
rm -fr ~/_firejail_test_dir
rm -fr /tmp/_firejail_test_dir

echo "TESTING: fscheck --private= (test/fs/fscheck-private.exp)"
./fscheck-private.exp
Expand All @@ -139,10 +166,4 @@ echo "TESTING: fscheck --read-only= (test/fs/fscheck-readonly.exp)"
./fscheck-readonly.exp

#cleanup
rm -fr ~/fjtest-dir
rm -fr ~/fjtest-dir-lnk
rm -f ~/fjtest-file
rm -f ~/fjtest-file-lnk
rm -f /tmp/fjtest-file
rm -fr /tmp/fjtest-dir
rm -fr ~/_firejail_test_*
rm -fr ~/_firejail_test*
16 changes: 8 additions & 8 deletions test/fs/fs_dev_shm.exp
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ expect {
after 100
send -- "stty -echo\r"

send -- "echo mytest > /dev/shm/ttt;echo done\r"
send -- "echo mytest > /dev/shm/_firejail_test_file;echo done\r"
expect {
timeout {puts "TESTING ERROR 1\n";exit}
"done"
}

send -- "cat /dev/shm/ttt;echo done\r"
send -- "cat /dev/shm/_firejail_test_file;echo done\r"
expect {
timeout {puts "TESTING ERROR 2\n";exit}
"mytest"
Expand All @@ -32,13 +32,13 @@ expect {
"done"
}

send -- "rm /dev/shm/ttt;echo done\r"
send -- "rm /dev/shm/_firejail_test_file;echo done\r"
expect {
timeout {puts "TESTING ERROR 4\n";exit}
"done"
}

send -- "cat /dev/shm/ttt;echo done\r"
send -- "cat /dev/shm/_firejail_test_file;echo done\r"
expect {
timeout {puts "TESTING ERROR 5\n";exit}
"mytest" {puts "TESTING ERROR 6\n";exit}
Expand All @@ -57,13 +57,13 @@ expect {
after 100
send -- "stty -echo\r"

send -- "echo mytest > /dev/shm/ttt;echo done\r"
send -- "echo mytest > /dev/shm/_firejail_test_file;echo done\r"
expect {
timeout {puts "TESTING ERROR 8\n";exit}
"done"
}

send -- "cat /dev/shm/ttt;echo done\r"
send -- "cat /dev/shm/_firejail_test_file;echo done\r"
expect {
timeout {puts "TESTING ERROR 9\n";exit}
"mytest"
Expand All @@ -73,13 +73,13 @@ expect {
"done"
}

send -- "rm /dev/shm/ttt;echo done\r"
send -- "rm /dev/shm/_firejail_test_file;echo done\r"
expect {
timeout {puts "TESTING ERROR 11\n";exit}
"done"
}

send -- "cat /dev/shm/ttt;echo done\r"
send -- "cat /dev/shm/_firejail_test_file;echo done\r"
expect {
timeout {puts "TESTING ERROR 12\n";exit}
"mytest" {puts "TESTING ERROR 13\n";exit}
Expand Down
16 changes: 8 additions & 8 deletions test/fs/fs_var_tmp.exp
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ expect {
after 100
send -- "stty -echo\r"

send -- "echo mytest > /var/tmp/ttt;echo done\r"
send -- "echo mytest > /var/tmp/_firejail_test_file;echo done\r"
expect {
timeout {puts "TESTING ERROR 1\n";exit}
"done"
}

send -- "cat /var/tmp/ttt;echo done\r"
send -- "cat /var/tmp/_firejail_test_file;echo done\r"
expect {
timeout {puts "TESTING ERROR 2\n";exit}
"mytest"
Expand All @@ -32,13 +32,13 @@ expect {
"done"
}

send -- "rm /var/tmp/ttt;echo done\r"
send -- "rm /var/tmp/_firejail_test_file;echo done\r"
expect {
timeout {puts "TESTING ERROR 4\n";exit}
"done"
}

send -- "cat /var/tmp/ttt;echo done\r"
send -- "cat /var/tmp/_firejail_test_file;echo done\r"
expect {
timeout {puts "TESTING ERROR 5\n";exit}
"mytest" {puts "TESTING ERROR 6\n";exit}
Expand All @@ -58,13 +58,13 @@ expect {
after 100
send -- "stty -echo\r"

send -- "echo mytest > /var/tmp/ttt;echo done\r"
send -- "echo mytest > /var/tmp/_firejail_test_file;echo done\r"
expect {
timeout {puts "TESTING ERROR 8\n";exit}
"done"
}

send -- "cat /var/tmp/ttt;echo done\r"
send -- "cat /var/tmp/_firejail_test_file;echo done\r"
expect {
timeout {puts "TESTING ERROR 9\n";exit}
"mytest"
Expand All @@ -74,13 +74,13 @@ expect {
"done"
}

send -- "rm /var/tmp/ttt;echo done\r"
send -- "rm /var/tmp/_firejail_test_file;echo done\r"
expect {
timeout {puts "TESTING ERROR 11\n";exit}
"done"
}

send -- "cat /var/tmp/ttt;echo done\r"
send -- "cat /var/tmp/_firejail_test_file;echo done\r"
expect {
timeout {puts "TESTING ERROR 12\n";exit}
"mytest" {puts "TESTING ERROR 13\n";exit}
Expand Down
20 changes: 10 additions & 10 deletions test/fs/mkdir.exp
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,34 @@ set timeout 3
spawn $env(SHELL)
match_max 100000

send -- "rm -fr ~/.firejail_test\r"
send -- "rm -fr ~/_firejail_test_dir\r"
after 100

send -- "firejail --profile=mkdir.profile find ~/.firejail_test\r"
send -- "firejail --profile=mkdir.profile find ~/_firejail_test_dir\r"
expect {
timeout {puts "TESTING ERROR 1.1\n";exit}
".firejail_test/a/b/c/d.txt"
"_firejail_test_dir/_firejail_test_file"
}
send -- "rm -rf ~/.firejail_test\r"
send -- "rm -rf ~/_firejail_test_dir\r"
after 100

send -- "firejail --profile=mkdir.profile find /tmp/.firejail_test\r"
send -- "firejail --profile=mkdir.profile find /tmp/_firejail_test_dir\r"
expect {
timeout {puts "TESTING ERROR 2.1\n";exit}
"/tmp/.firejail_test/a/b/c/d.txt"
"_firejail_test_dir/_firejail_test_file"
}
send -- "rm -rf /tmp/.firejail_test\r"
send -- "rm -rf /tmp/_firejail_test_dir\r"
after 100

set UID [exec id -u]
set fexist [file exist /run/user/$UID]
if { $fexist } {
send -- "firejail --profile=mkdir.profile find /run/user/$UID/.firejail_test\r"
send -- "firejail --profile=mkdir.profile find /run/user/$UID/_firejail_test_dir\r"
expect {
timeout {puts "TESTING ERROR 3.1\n";exit}
"/run/user/$UID/.firejail_test/a/b/c/d.txt"
"_firejail_test_dir/_firejail_test_file"
}
send -- "rm -rf /run/user/$UID/.firejail_test\r"
send -- "rm -rf /run/user/$UID/_firejail_test_dir\r"
after 100


Expand Down
12 changes: 6 additions & 6 deletions test/fs/mkdir.profile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
mkdir ~/.firejail_test/a/b/c
mkfile ~/.firejail_test/a/b/c/d.txt
mkdir /tmp/.firejail_test/a/b/c
mkfile /tmp/.firejail_test/a/b/c/d.txt
mkdir ${RUNUSER}/.firejail_test/a/b/c
mkfile ${RUNUSER}/.firejail_test/a/b/c/d.txt
mkdir ~/_firejail_test_dir
mkfile ~/_firejail_test_dir/_firejail_test_file
mkdir /tmp/_firejail_test_dir
mkfile /tmp/_firejail_test_dir/_firejail_test_file
mkdir ${RUNUSER}/_firejail_test_dir
mkfile ${RUNUSER}/_firejail_test_dir/_firejail_test_file
2 changes: 1 addition & 1 deletion test/fs/option_blacklist.exp
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ expect {
}
after 100

puts "\n"
puts "\nall done\n"
25 changes: 23 additions & 2 deletions test/fs/option_blacklist_file.exp
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,29 @@ set timeout 10
spawn $env(SHELL)
match_max 100000

send -- "firejail --blacklist=/etc/passwd\r"
send -- "mkdir ~/_firejail_test_dir\r"
after 100
send -- "touch ~/_firejail_test_dir/a\r"
after 100

send -- "firejail --blacklist=/etc/passwd --blacklist=~/_firejail_test_dir\r"
expect {
timeout {puts "TESTING ERROR 0\n";exit}
"Child process initialized"
}
sleep 1

send -- "cat /etc/passwd;echo done\r"
expect {
timeout {puts "TESTING ERROR 1\n";exit}
"No such file or directory"
}
expect {
timeout {puts "TESTING ERROR 2\n";exit}
"done"
}
after 100
send -- "cat ~/_firejail_test_dir/a;echo done\r"
expect {
timeout {puts "TESTING ERROR 1\n";exit}
"Permission denied"
Expand All @@ -25,4 +40,10 @@ expect {
}
after 100

puts "\n"
send -- "exit\r"
sleep 1

send -- "rm -fr ~/_firejail_test_dir\r"
after 100

puts "\nall done\n"
Loading

0 comments on commit b4424d9

Please sign in to comment.