testing --tmpfs as root and regular user

This commit is contained in:
netblue30 2026-01-21 15:48:06 -05:00
parent b214d080e0
commit 6b7d77c41e
4 changed files with 89 additions and 0 deletions

View file

@ -10,6 +10,12 @@ export LC_ALL=C
# These directories are required by some tests:
mkdir -p ~/Desktop ~/Documents ~/Downloads ~/Music ~/Pictures ~/Videos
echo "TESTING: tmpfs as regular user (test/fs/tmpfs.exp)"
./tmpfs.exp
echo "TESTING: tmpfs as rooot (test/fs/tmpfs-root.exp)"
sudo ./tmpfs-root.exp
echo "TESTING: tab completion (test/fs/tab.exp)"
./tab.exp

46
test/fs/tmpfs-root.exp Executable file
View file

@ -0,0 +1,46 @@
#!/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 --tmpfs=/var\r"
expect {
timeout {puts "TESTING ERROR 1\n";exit}
-re "you are not allowed to mount a tmpfs" {puts "TESTING ERROR 2\n";exit}
-re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
}
after 500
send -- "ls /var/tmp\r"
expect {
timeout {puts "TESTING ERROR 3\n";exit}
-re "cannot access"
}
after 100
send -- "exit\r"
after 500
send -- "firejail --profile=./tmpfs.profile\r"
expect {
timeout {puts "TESTING ERROR 4\n";exit}
-re "you are not allowed to mount a tmpfs" {puts "TESTING ERROR 5\n";exit}
-re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
}
after 500
send -- "ls /var/tmp\r"
expect {
timeout {puts "TESTING ERROR 3\n";exit}
-re "cannot access"
}
after 100
send -- "exit\r"
after 100
puts "\nall done\n"

36
test/fs/tmpfs.exp Executable file
View file

@ -0,0 +1,36 @@
#!/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 --tmpfs=/var\r"
expect {
timeout {puts "TESTING ERROR 1\n";exit}
-re "you are not allowed to mount a tmpfs"
}
expect {
timeout {puts "TESTING ERROR 2\n";exit}
-re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
}
after 500
send -- "exit\r"
after 500
send -- "firejail --profile=./tmpfs.profile\r"
expect {
timeout {puts "TESTING ERROR 3\n";exit}
-re "you are not allowed to mount a tmpfs"
}
expect {
timeout {puts "TESTING ERROR 4\n";exit}
-re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
}
after 500
send -- "exit\r"
after 100
puts "\nall done\n"

1
test/fs/tmpfs.profile Normal file
View file

@ -0,0 +1 @@
tmpfs /var