firejail/test/fs/macro.exp
Kelvin M. Klann 34f12c442e
Some checks are pending
Build-extra / build-gcc (push) Waiting to run
Build-extra / build-clang (push) Waiting to run
Build / build (push) Waiting to run
Check-C / scan-build (push) Waiting to run
Check-C / cppcheck (push) Waiting to run
Check-C / codeql-cpp (push) Waiting to run
Check-Profiles / profile-checks (push) Waiting to run
Codespell / codespell (push) Waiting to run
Test / test-main (push) Waiting to run
Test / test-fs (push) Waiting to run
Test / test-environment (push) Waiting to run
Test / test-utils (push) Waiting to run
Test / test-network (push) Waiting to run
feature: add ${PUBLICSHARE} and ${TEMPLATES} macros (#7164)
Add the following directories from the xdg-user-dirs specification[1]:

* `XDG_PUBLICSHARE_DIR="$HOME/Public"`
* `XDG_TEMPLATES_DIR="$HOME/Templates"`

With this, all directories from the specification are supported as
macros.

See also /etc/xdg/user-dirs.defaults.

Relates to #7157 #7163.

[1] https://www.freedesktop.org/wiki/Software/xdg-user-dirs/
2026-05-15 13:11:54 +00:00

64 lines
1.7 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 3
spawn $env(SHELL)
match_max 100000
set macros [ dict create \
"DESKTOP" "$::env(HOME)/Desktop" \
"DOCUMENTS" "$::env(HOME)/Documents" \
"DOWNLOADS" "$::env(HOME)/Downloads" \
"MUSIC" "$::env(HOME)/Music" \
"PICTURES" "$::env(HOME)/Pictures" \
"PROJECTS" "$::env(HOME)/Projects" \
"PUBLICSHARE" "$::env(HOME)/Public" \
"TEMPLATES" "$::env(HOME)/Templates" \
"VIDEOS" "$::env(HOME)/Videos" \
]
# Test that macros work.
dict for {name path} $macros {
send -- "firejail --profile=./macro-whitelist.profile find $path -maxdepth 1 | LC_ALL=C sort\r"
expect {
timeout {puts "TESTING ERROR 1\n";exit}
-re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
}
expect {
timeout {puts "TESTING ERROR 1.1 $name\n";exit}
"$path"
}
after 100
}
dict for {name path} $macros {
send -- "firejail --profile=./macro-blacklist.profile ls $path; echo ret \$?\r"
expect {
timeout {puts "TESTING ERROR 2 $name\n";exit}
-re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
}
expect {
timeout {puts "TESTING ERROR 2.1 $name\n";exit}
"Permission denied" {}
-re {ret 0} {puts "TESTING ERROR 2.2 $name\n";exit}
}
after 100
}
dict for {name path} $macros {
send -- "firejail --profile=./macro-readonly.profile touch $path/_firejail_test_file; echo ret \$?\r"
expect {
timeout {puts "TESTING ERROR 3 $name\n";exit}
-re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
}
expect {
timeout {puts "TESTING ERROR 3.1 $name\n";exit}
"Read-only file system" {}
-re {ret 0} {puts "TESTING ERROR 3.2 $name\n";exit}
}
after 100
}
puts "\nall done\n"