firejail/test/filters/protocol.exp
2018-01-15 09:46:44 -05:00

185 lines
3.7 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
send -- "firejail --noprofile --protocol=unix ./syscall_test socket\r"
expect {
timeout {puts "TESTING ERROR 1\n";exit}
"Permission denied" {puts "TESTING SKIP: permission denied\n"; exit}
"Child process initialized"
}
expect {
timeout {puts "TESTING ERROR 1.1\n";exit}
"Permission denied" {puts "TESTING SKIP: permission denied\n"; exit}
"socket AF_INET"
}
expect {
timeout {puts "TESTING ERROR 1.2\n";exit}
"Operation not supported"
}
expect {
timeout {puts "TESTING ERROR 1.3\n";exit}
"socket AF_INET6"
}
expect {
timeout {puts "TESTING ERROR 1.4\n";exit}
"Operation not supported"
}
expect {
timeout {puts "TESTING ERROR 1.5\n";exit}
"socket AF_NETLINK"
}
expect {
timeout {puts "TESTING ERROR 1.6\n";exit}
"Operation not supported"
}
expect {
timeout {puts "TESTING ERROR 1.7\n";exit}
"socket AF_UNIX"
}
expect {
timeout {puts "TESTING ERROR 1.8\n";exit}
"socket AF_PACKETX"
}
expect {
timeout {puts "TESTING ERROR 1.9\n";exit}
"Operation not supported"
}
sleep 1
send -- "firejail --noprofile --protocol=inet6,packet ./syscall_test socket\r"
expect {
timeout {puts "TESTING ERROR 2\n";exit}
"Child process initialized"
}
expect {
timeout {puts "TESTING ERROR 2.1\n";exit}
"socket AF_INET"
}
expect {
timeout {puts "TESTING ERROR 2.2\n";exit}
"Operation not supported"
}
expect {
timeout {puts "TESTING ERROR 2.3\n";exit}
"socket AF_INET6"
}
expect {
timeout {puts "TESTING ERROR 2.4\n";exit}
"socket AF_NETLINK"
}
expect {
timeout {puts "TESTING ERROR 2.5\n";exit}
"Operation not supported"
}
expect {
timeout {puts "TESTING ERROR 2.6\n";exit}
"socket AF_UNIX"
}
expect {
timeout {puts "TESTING ERROR 2.7\n";exit}
"Operation not supported"
}
expect {
timeout {puts "TESTING ERROR 2.8\n";exit}
"socket AF_PACKETX"
}
expect {
timeout {puts "TESTING ERROR 2.9\n";exit}
"after socket"
}
sleep 1
# profile testing
send -- "firejail --profile=protocol1.profile ./syscall_test socket\r"
expect {
timeout {puts "TESTING ERROR 3\n";exit}
"Child process initialized"
}
expect {
timeout {puts "TESTING ERROR 3.1\n";exit}
"socket AF_INET"
}
expect {
timeout {puts "TESTING ERROR 3.2\n";exit}
"Operation not supported"
}
expect {
timeout {puts "TESTING ERROR 3.3\n";exit}
"socket AF_INET6"
}
expect {
timeout {puts "TESTING ERROR 3.4\n";exit}
"Operation not supported"
}
expect {
timeout {puts "TESTING ERROR 3.5\n";exit}
"socket AF_NETLINK"
}
expect {
timeout {puts "TESTING ERROR 3.6\n";exit}
"Operation not supported"
}
expect {
timeout {puts "TESTING ERROR 3.7\n";exit}
"socket AF_UNIX"
}
expect {
timeout {puts "TESTING ERROR 3.8\n";exit}
"socket AF_PACKETX"
}
expect {
timeout {puts "TESTING ERROR 3.9\n";exit}
"Operation not supported"
}
sleep 1
send -- "firejail --profile=protocol2.profile ./syscall_test socket\r"
expect {
timeout {puts "TESTING ERROR 4\n";exit}
"Child process initialized"
}
expect {
timeout {puts "TESTING ERROR 4.1\n";exit}
"socket AF_INET"
}
expect {
timeout {puts "TESTING ERROR 4.2\n";exit}
"Operation not supported"
}
expect {
timeout {puts "TESTING ERROR 4.3\n";exit}
"socket AF_INET6"
}
expect {
timeout {puts "TESTING ERROR 4.4\n";exit}
"socket AF_NETLINK"
}
expect {
timeout {puts "TESTING ERROR 4.5\n";exit}
"Operation not supported"
}
expect {
timeout {puts "TESTING ERROR 4.6\n";exit}
"socket AF_UNIX"
}
expect {
timeout {puts "TESTING ERROR 4.7\n";exit}
"Operation not supported"
}
expect {
timeout {puts "TESTING ERROR 4.8\n";exit}
"socket AF_PACKETX"
}
expect {
timeout {puts "TESTING ERROR 4.9\n";exit}
"after socket"
}
after 100
puts "\nall done\n"