Commit graph

698 commits

Author SHA1 Message Date
Kelvin M. Klann
34f12c442e
feature: add ${PUBLICSHARE} and ${TEMPLATES} macros (#7164)
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
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
Kelvin M. Klann
ad89817c08
test/fs: deduplicate xdg dirs in macro tests (#7163)
To make it easier to add new directories.

Relates to #7147.
2026-05-13 14:14:31 +00:00
Kelvin M. Klann
fce18b90f3 test/fs/fs.sh: fix typo of "root"
This amends commit 6b7d77c41 ("testing --tmpfs as root and regular
user", 2026-01-21).
2026-05-11 11:09:00 -03:00
Kelvin M. Klann
98fe3af8ba test/fs/macro-subpath.exp: fix permissions (644 -> 755)
The tests from this file are currently not even being executed in CI[1]:

    TESTING: macro subpaths (test/fs/macro-subpath.exp)
    ./fs.sh: line 130: ./macro-subpath.exp: Permission denied
    TESTING: whitelist empty (test/fs/whitelist-empty.exp)

This amends commit aff7cb630 ("feature: allow subpaths in xdg macros",
2026-04-21) / PR #7151.

Relates to #7147.

[1] https://github.com/netblue30/firejail/actions/runs/25602127293/job/75157737035
2026-05-11 11:08:51 -03:00
Kelvin M. Klann
9426ba79a2 test/fs/macro-subpath.exp: fix ls -> find
The whitelist test is currently broken[1]:

    TESTING: macro subpaths (test/fs/macro-subpath.exp)
    spawn /bin/bash
    firejail --profile=./macro-subpath-whitelist.profile ls  ~/Desktop/_firejail_test_dir [...]
    [...]
    /home/runner/Desktop/_firejail_test_dir:
    a

    [...]
    Parent is shutting down, bye...
    runner@runnervmrc6n4:~/work/firejail/firejail/test/fs$ TESTING ERROR 1.1 Desktop

This amends commit aff7cb630 ("feature: allow subpaths in xdg macros",
2026-04-21) / PR #7151.

Relates to #7147.

[1] https://github.com/netblue30/firejail/actions/runs/25638061680/job/75253423623
2026-05-11 11:08:39 -03:00
Kelvin M. Klann
5abf0577a7
feature: add ${PROJECTS} macro (#7157)
Based on the new ~/Projects directory from version 0.20 of the
xdg-user-dirs specification[1]:

* `XDG_PROJECTS_DIR="$HOME/Projects"`

Relates to #7147 #7151.

[1] https://www.freedesktop.org/wiki/Software/xdg-user-dirs/
2026-05-09 13:19:42 +00:00
Kelvin M. Klann
46a111166e test/fs: simplify error messages in macro tests
Some checks failed
Build / build (push) Has been cancelled
Codespell / codespell (push) Has been cancelled
Test / test-main (push) Has been cancelled
Test / test-fs (push) Has been cancelled
Test / test-environment (push) Has been cancelled
Test / test-utils (push) Has been cancelled
Test / test-network (push) Has been cancelled
To make it easier to add new directories.

This is similar to commit 1511aab5f
("test/fs/disable-devnull-symlink.exp: simplify error messages",
2026-04-27).

Relates to #7147 #7151.
2026-05-05 04:46:59 -03:00
Kelvin M. Klann
6b65860e89 test/fs/fs.sh: use one mkdir per directory
To make the diffs clearer.

This amends commit df3f0b618 ("tests: make sure needed directories
exist", 2018-08-15).

Relates to #7147.
2026-05-05 04:38:11 -03:00
Kelvin M. Klann
aff7cb630c feature: allow subpaths in xdg macros
Currently it is not possible to use XDG-related macros (such as
`${DOCUMENTS}`) with subpaths (such as `${DOCUMENTS}/foo`) and so
profiles just use `${HOME}` with a hardcoded path using the English
directory name and the subpath (such as `${HOME}/Documents/foo`).

Allow using subpaths after XDG macros, so that they automatically use
the auto-detected XDG path, just as when currently using the XDG macros
without subpaths.

Before:

    ${HOME}/Documents/foo

After:

    ${DOCUMENTS}/foo

This is a follow-up to #7147.

Closes #2359.

Relates to #4229.
2026-05-01 07:30:23 -03:00
Kelvin M. Klann
d9739c6d55 test/fs/macro.exp: increase timeout to 3s
The test is failing at multiple parts in CI due to timeouts.

From [1]:

    runner@runnervmrc6n4:~/work/firejail/firejail/test/fs$
    <=./macro-blacklist.profile ls ~/Videos; echo ret $?
    Reading profile ./macro-blacklist.profile
    firejail version 0.9.81

    Parent pid 6385, child pid 6386
    Base filesystem installed in 0.25 ms
    firejail ls /home/runner/Videos
    Child process initialized in 7.58 ms
    ls: cannot open directory '/home/runner/Videos': Permission denied

    Parent is shutting down, bye...
    ret 2
    runner@runnervmrc6n4:~/work/firejail/firejail/test/fs$
    <le touch ~/Desktop/_firejail_test_file; echo ret $?
    Reading profile ./macro-readonly.profile
    firejail version 0.9.81

    Parent pid 6390, child pid 6391
    Base filesystem installed in 3.23 ms
    TESTING ERROR 19

From [2]:

    runner@runnervmrc6n4:~/work/firejail/firejail/test/fs$
    <macro-blacklist.profile ls ~/Documents; echo ret $?
    Reading profile ./macro-blacklist.profile
    firejail version 0.9.81

    Parent pid 6382, child pid 6383
    Base filesystem installed in 0.26 ms
    firejail ls /home/runner/Documents
    Child process initialized in 7.84 ms
    ls: cannot open directory '/home/runner/Documents': Permission denied

    Parent is shutting down, bye...
    ret 2
    runner@runnervmrc6n4:~/work/firejail/firejail/test/fs$
    <macro-blacklist.profile ls ~/Downloads; echo ret $?
    Reading profile ./macro-blacklist.profile
    firejail version 0.9.81

    Parent pid 6387, child pid 6388
    Base filesystem installed in 0.25 ms
    firejail ls /home/runner/Downloads
    TESTING ERROR 11

This amends commit 574885778 ("test/fs/macro.exp: reduce timeout and
sleep", 2026-04-24) / PR #7147.

[1] https://github.com/netblue30/firejail/actions/runs/25076422708/job/73470137137
[2] https://github.com/netblue30/firejail/actions/runs/25076422708/job/73522630528
2026-04-29 02:58:06 -03:00
Kelvin M. Klann
96e66e1020 test/fs/macro.exp: check return value
Fail faster instead of waiting for the timeout.

See also commit a4e6495fd ("modif: do not follow symlinks to /dev/null
on disable (#7129)", 2026-04-17).
2026-04-27 04:47:37 -03:00
Kelvin M. Klann
574885778a test/fs/macro.exp: reduce timeout and sleep
* timeout: 10s -> 1s
* sleep: 1000ms -> 100ms
2026-04-27 04:47:37 -03:00
Kelvin M. Klann
096aa0337f test/fs/macro.exp: use _firejail_test_file
Use `_firejail_test_file` instead of `blablabla`, as the former is a
more common filename in tests and is what is actually removed in
test/fs/fs.sh.

Related commits:

* 2155203b3 ("xdg macro testing", 2018-08-07)
* 188d5f16d ("--profile=FILE rework (#6896)", 2026-01-05)
2026-04-27 04:47:37 -03:00
Kelvin M. Klann
217c96fab4 test/fs/fs.sh: move rm of xdg macro files after macro.exp
They are unrelated to private-whitelist.exp.

This amends commit 2155203b3 ("xdg macro testing", 2018-08-07).
2026-04-27 04:47:37 -03:00
Kelvin M. Klann
af26a06dd9 test/fs/fs.sh: sort rm commands for xdg paths
This amends commit 2155203b3 ("xdg macro testing", 2018-08-07).
2026-04-27 04:47:37 -03:00
Kelvin M. Klann
07fe21516a test/fs/fs.sh: fix typo of _firejail_test_file
This amends commit 2155203b3 ("xdg macro testing", 2018-08-07).
2026-04-27 04:47:37 -03:00
Kelvin M. Klann
0d9a9327d5 test/fs: sort entries in xdg macro profiles
This amends commit 2155203b3 ("xdg macro testing", 2018-08-07).
2026-04-27 04:47:37 -03:00
Kelvin M. Klann
1511aab5fa test/fs/disable-devnull-symlink.exp: simplify error messages
This amends commit a4e6495fd ("modif: do not follow symlinks to
/dev/null on disable (#7129)", 2026-04-17).
2026-04-27 04:43:52 -03:00
Kelvin M. Klann
68427a2333
test: fix unescaped newlines in error messages (#7146)
Commands used to search and replace:

    $ git grep -IElz 'ERROR [0-9]+n"' -- test |
      xargs -0 perl -pi -e 's/(ERROR [0-9]+)n"/$1\\n"/'

Related commits:

* 63e16bfcd ("major cleanup and testing", 2016-11-13)
* 2155203b3 ("xdg macro testing", 2018-08-07)
2026-04-27 07:36:57 +00:00
Kelvin M. Klann
a4e6495fd1
modif: do not follow symlinks to /dev/null on disable (#7129)
When trying to prevent a file or directory in the user home from being
written to, it is not uncommon to replace it with a symlink to
/dev/null.

If this path is also blacklisted (such as by disable-common.inc), the
symlink will be followed, resulting in /dev/null itself being
blacklisted, which can cause issues with (unrelated) programs that have
their output redirected to /dev/null (for example).

To avoid disabling /dev/null, when applying commands from
`disable_file()` (such as `blacklist` and `read-only`), if a file is a
symlink to /dev/null, avoid following the symlink and perform the
operation on the link itself instead.

Using these commands with "/dev/null" directly as the argument (that is,
without going through a symlink) should still work the same way.

It has been confirmed to work on Linux 3.8[1], so it should work on at
least 3.8 and later.

Closes #5803.

[1] https://github.com/netblue30/firejail/pull/7129#issuecomment-4233141574

Reported-by: @fgpietersz
Suggested-by: @Changaco
Tested-by: @Changaco
Tested-by: @Zopolis4
2026-04-17 18:30:28 +00:00
Jonas Jelten
92f7be5192 testing: fix strace color probing in allow-debuggers & seccomp-ptrace
if strace runs in a terminal, it probes the background color to select
its color palette. this probing expects a reply, but due to expect
intercepting the io, the answer isn't sent back to strace, so it never
starts printing the expected output.
2026-03-11 13:43:14 +01:00
Kelvin M. Klann
09329b990f modif: replace --keep-hostname with new --hostname-randomize
Changes:

* Keep hostname by default (same as using `--keep-hostname`)
* Add  `--hostname-randomize` command to randomize the hostname
* Ignore `--keep-hostname` command and print a warning if it is used

Setting a different hostname inside of the sandbox may prevent X11
programs from authenticating to the X server and displaying windows at
all (see #7062).

To avoid breakage, keep the hostname as is by default and only set it to
a random value if a new `hostname-randomize` command is used.

This also avoids potentially surprising behavior, as the user might not
expect the hostname to be changed inside of the sandbox, considering
that usually the protections that are applied firejail involve
restricting access to resources (like file paths), rather than modifying
their values inside of the sandbox.

Fixes #7062

Relates to #7048 #7069.
2026-03-08 02:12:26 -03:00
netblue30
01b741aa80 RELNOTES and some more testing 2026-02-25 15:14:15 -05:00
Kelvin M. Klann
167a0ea74a Fix misc whitespace
Command used to check for whitespace errors:

    $ git diff --check 0.9.78..
2026-02-23 13:20:38 -03:00
netblue30
ca934a2ccd disable by default some of the systemd tools, more cleanup, and more testing 2026-02-04 07:34:07 -05:00
netblue30
6f164f415e --keep-hostname part 2 (#7048) 2026-02-03 13:43:30 -05:00
netblue30
f7c80ab0ee testing; adding pierretom to the commiters list 2026-02-02 08:26:23 -05:00
netblue30
d3f182543d Hide/Mask firejail process (pid 1) inside sandbox #7046 2026-02-02 07:39:36 -05:00
netblue30
2184909cae more make test-apps 2026-01-28 09:09:27 -05:00
netblue30
b2d5c279ff spelling 2026-01-25 11:33:00 -05:00
netblue30
5d78ff54ab Removing time-reading syscalls from @clock group.
It stops several networked programs such as firefox, or any other
program that tries to access the time. For example:
firejail sleep 10
2026-01-25 11:27:50 -05:00
Kelvin M. Klann
f571fb5c70 tests: compile: remove leftover --disable-man test
The `--disable-man` test was added twice on commit 5c7c58f6e and only
one instance was removed on commit a655b7d1b.

Related commits:

* 5c7c58f6e ("rework make test-compile", 2026-01-20)
* a655b7d1b ("removed ./configure --disable-man option", 2026-01-21).
2026-01-25 04:39:34 -03:00
netblue30
6b7d77c41e testing --tmpfs as root and regular user 2026-01-21 15:48:06 -05:00
netblue30
b214d080e0 removed ./configure --disable-usertmpfs option 2026-01-21 15:07:43 -05:00
netblue30
a655b7d1ba removed ./configure --disable-man option 2026-01-21 14:14:40 -05:00
netblue30
5c7c58f6e6 rework make test-compile 2026-01-20 12:09:35 -05:00
netblue30
de15fa0c7c adding make test-filters to ci 2026-01-19 20:34:27 -05:00
netblue30
238fb64ac9 make test-apps 2026-01-18 11:07:44 -05:00
netblue30
9dfbaa9f3b testing 2026-01-17 11:51:42 -05:00
Kelvin M. Klann
f9cc7b24eb build: move cleaning of test files to test/Makefile
Move them from the distclean target in the root Makefile.

Related commits:

* a1ff0c3fd ("testing", 2026-01-16)
* 2f6afc99d ("gcov testing", 2026-01-16)
2026-01-17 02:14:51 -03:00
netblue30
e6b240b3fa remove make test-sysutlis 2026-01-16 13:16:34 -05:00
netblue30
2f6afc99d5 gcov testing 2026-01-16 11:17:29 -05:00
netblue30
b72411292e testing 2026-01-16 09:37:31 -05:00
netblue30
a1ff0c3fd3 testing 2026-01-16 08:54:26 -05:00
netblue30
096c99664f testing 2026-01-16 08:28:49 -05:00
netblue30
4e8cfe1a1c testing 2026-01-15 20:42:02 -05:00
netblue30
6841aef3a7 more nettrace testing 2026-01-15 18:04:20 -05:00
netblue30
7136c6697c make test-fnettrace 2026-01-15 08:03:50 -05:00
netblue30
b8eae09740 make test-utils 2026-01-15 07:37:50 -05:00
netblue30
053e5daf44 jailcheck testing 2026-01-14 12:58:15 -05:00