firejail/test/fs/private-home.exp
2018-01-15 09:46:44 -05:00

102 lines
2.1 KiB
Text
Executable file

#!/usr/bin/expect -f
# This file is part of Firejail project
# Copyright (C) 2014-2018 Firejail Authors
# License GPL v2
set timeout 10
spawn $env(SHELL)
match_max 100000
# create some test files in user home directory
send -- "touch ~/_firejail_test_file1\r"
after 100
send -- "touch ~/_firejail_test_file2\r"
after 100
send -- "mkdir ~/_firejail_test_dir1\r"
after 100
send -- "mkdir ~/_firejail_test_dir1/_firejail_test_dir2\r"
after 100
send -- "touch ~/_firejail_test_dir1/_firejail_test_dir2/_firejail_test_file3\r"
after 100
send -- "ln -s /etc ~/_firejail_test_link1\r"
after 100
send -- "ln -s ~/_firejail_test_dir1 ~/_firejail_test_link2\r"
after 100
send -- "firejail --private-home=_firejail_test_file1,_firejail_test_file2,_firejail_test_dir1\r"
expect {
timeout {puts "TESTING ERROR 1\n";exit}
"Child process initialized"
}
after 100
send -- "find ~\r"
expect {
timeout {puts "TESTING ERROR 2\n";exit}
"_firejail_test_file3"
}
expect {
timeout {puts "TESTING ERROR 3\n";exit}
"_firejail_test_file2"
}
expect {
timeout {puts "TESTING ERROR 4\n";exit}
"_firejail_test_file1"
}
after 100
send -- "exit\r"
sleep 1
send -- "firejail --private-home=\"bla;bla\"\r"
expect {
timeout {puts "TESTING ERROR 5\n";exit}
"is an invalid filename"
}
after 100
send -- "firejail --private-home=/etc/shadow\r"
expect {
timeout {puts "TESTING ERROR 6\n";exit}
"invalid file"
}
after 100
send -- "firejail --private-home=/etc/passwd\r"
expect {
timeout {puts "TESTING ERROR 7\n";exit}
"invalid file"
}
after 100
send -- "firejail --private-home=../../etc/passwd\r"
expect {
timeout {puts "TESTING ERROR 8\n";exit}
"invalid file"
}
after 100
send -- "firejail --private-home=_firejail_test_link1\r"
expect {
timeout {puts "TESTING ERROR 9\n";exit}
"to file or directory not owned by the user"
}
after 100
send -- "firejail --private-home=_firejail_test_link2\r"
expect {
timeout {puts "TESTING ERROR 10\n";exit}
"Child process initialized"
}
after 100
send -- "file ~/_firejail_test_link2\r"
expect {
timeout {puts "TESTING ERROR 11\n";exit}
"broken symbolic link"
}
send -- "exit\r"
send -- "rm -f ~/_firejail_test*\r"
after 100
puts "\nall done\n"