firejail/test/fs/private-bin.exp
2026-01-05 12:42:17 -05:00

92 lines
1.6 KiB
Text
Executable file

#!/usr/bin/expect -f
# This file is part of Firejail project
# Copyright (C) 2014-2026 Firejail Authors
# License GPL v2
set timeout 10
spawn $env(SHELL)
match_max 100000
send -- "firejail --private-bin=bash,ls,sh\r"
expect {
timeout {puts "TESTING ERROR 1\n";exit}
-re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
}
sleep 1
send -- "ls /bin\r"
expect {
timeout {puts "TESTING ERROR 2\n";exit}
"bash"
}
expect {
timeout {puts "TESTING ERROR 3\n";exit}
"ls"
}
expect {
timeout {puts "TESTING ERROR 4\n";exit}
"sh"
}
send -- "ls /bin\r"
expect {
timeout {puts "TESTING ERROR 5\n";exit}
"ping" {puts "TESTING ERROR 6\n";exit}
"sh"
}
send -- "exit\r"
sleep 1
send -- "firejail --profile=./private-bin.profile\r"
expect {
timeout {puts "TESTING ERROR 7\n";exit}
-re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
}
sleep 1
send -- "ls /bin\r"
expect {
timeout {puts "TESTING ERROR 8\n";exit}
"bash"
}
expect {
timeout {puts "TESTING ERROR 9\n";exit}
"ls"
}
expect {
timeout {puts "TESTING ERROR 10\n";exit}
"sh"
}
send -- "ls /bin\r"
expect {
timeout {puts "TESTING ERROR 11\n";exit}
"ping" {puts "TESTING ERROR 12\n";exit}
"sh"
}
send -- "exit\r"
after 100
send -- "firejail --private-bin=/etc/shadow\r"
expect {
timeout {puts "TESTING ERROR 13\n";exit}
"Warning: invalid private-bin path /etc/shadow"
}
after 300
send -- "firejail --private-bin=\"bla;bla\"\r"
expect {
timeout {puts "TESTING ERROR 14\n";exit}
"is an invalid filename"
}
after 300
send -- "firejail --private-etc=../bin/ls\r"
expect {
timeout {puts "TESTING ERROR 15\n";exit}
"is an invalid filename"
}
after 300
puts "\nall done\n"