Commit graph

162 commits

Author SHA1 Message Date
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
pierretom
9d90daff22 create a new syscall group: @program-keep
`@default-keep` should be used for syscalls used by Firejail itself only.
We are moving some syscalls from `@default-keep` that do not meet this condition into the new group `@program-keep`.
Syscalls in `@program-keep` are not forced to whitelist (we let users decide), but should never be present in `@default` and its sub-groups.

Also move `execv` into `@obsolete` (sparc only, replaced by `execve`).
2026-04-01 14:26:38 +02: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
pierretom
e9cccefe1d update all system call headers 2026-03-05 14:49:33 +01:00
netblue30
6f8cc61d00 merges 2026-02-06 20:39:24 -05:00
netblue30
cc8b019b5d --keep-hostname part 1 (#7048) 2026-02-03 11:41:34 -05:00
netblue30
5dc63f1a08 RELNOTES update 2026-01-22 09:01:27 -05:00
netblue30
2a5062c800 copyright 2014-2026 all over the place 2025-12-30 08:20:44 -05:00
netblue30
27c5724d33 bwrap replacement - part 9 - allow-bwrap profile command 2025-12-29 13:56:35 -05:00
netblue30
489cc25c2f cleaned up old overlayfs code; the feature was disabled by default in 2021 because of security problems 2025-12-16 20:28:28 -05:00
netblue30
af57dec211
Merge pull request #6961 from pierretom/patch4
update and add system calls for several architectures
2025-12-04 07:44:43 -05:00
netblue30
bd94e87eb7 sorting xephyr-extra-params 2025-11-27 09:57:57 -05:00
pierretom
380e90169e update and add system calls for several architectures
Closes #6956.
2025-11-10 08:35:20 +01:00
Yurei TZK
15b0e07617
feature: xephyr-extra-params option 2025-10-30 15:55:58 +03:00
Kelvin M. Klann
dd3ef2a1d0
feature: add warn command (#6710)
And use it in etc/inc/disable-X11.inc.

This allows printing a warning message from inside a profile.

Everything after the command is printed in a warning message as is (that
is, without macro expansion).

Example:

    $ firejail --noprofile --include=/etc/firejail/disable-X11.inc true
    Reading profile /etc/firejail/disable-X11.inc
    Warning: /etc/firejail/disable-X11.inc:5: This file is deprecated; use disable-x11.inc (lowercase) instead.
    Reading profile /etc/firejail/disable-x11.inc
    [...]

Relates to #6294.

This is a follow-up to #6709.
2025-04-21 10:49:27 +00:00
Kelvin M. Klann
4d34d4c336 modif: block TPM devices & turn notpm command into keep-dev-tpm
Instead of having a `notpm` command and potentially adding it to almost
all profiles (as few programs should need direct access to TPM devices),
add a `keep-dev-tpm` command and use it only in profiles that need
access to TPM devices.

Changes:

* Turn `notpm` command into `keep-dev-tpm` command
* Warn and ignore if `notpm` is used
* Block `/dev/tpm*` devices by default
* Allow `/dev/tpm*` devices with `keep-dev-tpm` (even if `private-dev`
  is used)

Added on commit 001320226 ("feature: add notpm command & keep tpm
devices in private-dev (#6390)", 2024-07-09).

See also commit ee1c264c5 ("feature: block /dev/ntsync & add
keep-dev-ntsync command (#6660)", 2025-03-06) and the discussion at
PR #6660.

This is a follow-up to #6687.
2025-04-05 15:52:30 -03:00
沈澄心
36de842b77
contrib/vim: add ftplugin file (based on cfg.vim) (#6680)
Add a simple vim filetype plugin.
2025-03-10 02:57:57 +00:00
weebnix
ee1c264c5f
feature: block /dev/ntsync & add keep-dev-ntsync command (#6660)
Changes:

* Block access to /dev/ntsync by default
* Add the `keep-dev-ntsync` command to allow access to /dev/ntsync (even
  if `private-dev` is used)
* Add `keep-dev-ntsync` to wine.profile and similar profiles

Closes #6655.
2025-03-06 06:36:00 +00:00
netblue30
212ac3cb19 update copyright 2025-01-12 19:26:24 -05:00
Kelvin M. Klann
7b47c82d6b build: sort.py: ignore empty files
Currently it adds a newline to empty files.

Before:

    $ : >foo.profile
    $ contrib/sort.py foo.profile
    sort.py: checking 1 profile(s)...
    foo.profile:(fixed whitespace)
    [ Fixed ] foo.profile
    $ od -A n -t x1 foo.profile
     0a

After:

    $ : >foo.profile
    $ contrib/sort.py foo.profile
    sort.py: checking 1 profile(s)...
    $

This amends commit c222b7f69 ("build: sort.py: fix whitespace in entire
profile (#6593)", 2024-12-28).
2025-01-04 11:33:12 -03:00
Kelvin M. Klann
8c28f0e386 bugfix: update syscalls.list
Commands used to update it:

    touch src/include/syscall_aarch64.h # potentially needed
    make syntax

This amends commit 508cd6a6c ("feature: add aarch64 syscalls (#6574)",
2024-12-21).
2025-01-04 01:03:12 -03:00
Kelvin M. Klann
df6620c11c
build: sort.py: quote diff lines (#6594)
To make it clearer when only whitespace was fixed on a given line.

Before:

    $ printf 'private-bin a,b \n' >foo.profile
    $ ./contrib/sort.py -n foo.profile
    sort.py: checking 1 profile(s)...
    foo.profile:1:-private-bin a,b
    foo.profile:1:+private-bin a,b

After:

    $ printf 'private-bin a,b \n' >foo.profile
    $ ./contrib/sort.py -n foo.profile
    sort.py: checking 1 profile(s)...
    foo.profile:1:-'private-bin a,b '
    foo.profile:1:+'private-bin a,b'

See commit 53ff8e0ad ("build: sort.py: strip trailing whitespace in all
lines", 2024-11-26) / PR #6556.
2024-12-29 12:06:14 +00:00
Kelvin M. Klann
c222b7f692
build: sort.py: fix whitespace in entire profile (#6593)
Changes:

* Strip whitespace at the beginning
* Strip whitespace at the end
* Ensure exactly one newline at the end
* Strip extraneous newlines

Also, for clarity print the git diff in the sort.py ci job, since the
specific lines changed are not printed by the sort.py script in this
case (as whitespace is fixed in the entire profile at once).

Command used to search and replace:

    ./contrib/sort.py etc/inc/*.inc etc/profile*/*.profile

This is a follow-up to #6556.

Update contrib/sort.py
2024-12-28 16:00:14 +00:00
Kelvin M. Klann
08e5f8161c build: sort.py: strip whitespace in commands
Currently whitespace is left as is within an entry.

In a `protocol` entry, if there is whitespace between the command and
its argument or around an item, the item in question is dropped from the
output.

Changes:

* `protocol`: Strip all whitespace in the argument
* Other commands: Strip leading/trailing whitespace around each item,
  including any extra whitespace between a command and its argument

Note: Whitespace characters inside paths are left as is, as some paths
(such as `Foo Bar` may contain spaces.

Before:

    $ printf 'private-bin a,b\nprivate-bin  a,b\nprivate-bin  b,a\nprivate-bin  C,A  B\nprotocol  unix,net\nprotocol  inet,unix\n' \
      >foo.profile
    $ ./contrib/sort.py -n foo.profile
    sort.py: checking 1 profile(s)...
    foo.profile:5:-protocol  unix,net
    foo.profile:5:+protocol
    foo.profile:6:-protocol  inet,unix
    foo.profile:6:+protocol unix

After:

    $ printf 'private-bin a,b\nprivate-bin  a,b\nprivate-bin  b,a\nprivate-bin  C,A  B\nprotocol  unix,net\nprotocol  inet,unix\n' \
      >foo.profile
    $ ./contrib/sort.py -n foo.profile
    sort.py: checking 1 profile(s)...
    foo.profile:2:-private-bin  a,b
    foo.profile:2:+private-bin a,b
    foo.profile:3:-private-bin  b,a
    foo.profile:3:+private-bin a,b
    foo.profile:4:-private-bin  C,A  B
    foo.profile:4:+private-bin A  B,C
    foo.profile:5:-protocol  unix,net
    foo.profile:5:+protocol unix
    foo.profile:6:-protocol  inet,unix
    foo.profile:6:+protocol unix,inet
2024-12-05 04:53:41 -03:00
Kelvin M. Klann
53ff8e0ad9 build: sort.py: strip trailing whitespace in all lines
Currently the output is mangled if the last item on the line contains
trailing whitespace and is moved when sorting.

So remove trailing whitespace in all lines (that is, not just in lines
containing supported commands).

Leave leading whitespace as is for now since it could potentially be
used for indentation.

Before:

    $ printf '# hello world  \nprivate-bin a,b  \nprivate-bin b,a  \nprivate-bin  a,b\n' \
      >foo.profile
    $ ./contrib/sort.py -n foo.profile | tr ' ' .
    sort.py:.checking.1.profile(s)...
    foo.profile:3:-private-bin.b,a..
    foo.profile:3:+private-bin.a..,b

After:

    $ printf '# hello world  \nprivate-bin a,b  \nprivate-bin b,a  \n' \
      >foo.profile
    $ ./contrib/sort.py -n foo.profile | tr ' ' .
    sort.py:.checking.1.profile(s)...
    foo.profile:1:-#.hello.world..
    foo.profile:1:+#.hello.world
    foo.profile:2:-private-bin.a,b..
    foo.profile:2:+private-bin.a,b
    foo.profile:3:-private-bin.b,a..
    foo.profile:3:+private-bin.a,b
2024-12-05 04:53:35 -03:00
Kelvin M. Klann
406b1cb18e build: sort.py: rename line variables
Rename `line` to `original_line` to make it less likely to accidentally
read from/write to it instead of the fixed line.

Rename `fixed_line` to `line` to make the code shorter since it is now
referenced much more often (up to 3 times in the same line of code) than
the original line.

See also commit aa17ca5fc ("sort.py: rename protocols to
original_protocols", 2022-10-17) / PR #5429.
2024-12-05 04:43:00 -03:00
Kelvin M. Klann
ced8b19dbe build: sort.py: operate mostly on fixed_line
Set `fixed_line` to `line` and only use the latter when needed.

This makes it easier to modify `fixed_line` multiple times.
2024-12-05 04:43:00 -03:00
Kelvin M. Klann
4e8253a695
build: sort.py: add -h option for help (#6562)
Print the usage if `-h` is given.

Kind of relates to #6290.
2024-12-02 10:26:21 +00:00
Kelvin M. Klann
245a0aba89 build: sort.py: format/clarify misc options usage
This amends commit a6d2119ee ("build: sort.py: support "--" and fail on
unknown option", 2024-05-13) / PR #6339.
2024-12-01 11:45:32 -03:00
qdii
001320226c
feature: add notpm command & keep tpm devices in private-dev (#6390)
An ssh private key may be stored in a Trusted Platform Module (TPM)
device and `private-dev` in ssh.profile currently breaks this use-case,
as it does not keep tpm devices (see #6379).

So add a new `notpm` command and keep tpm devices in /dev by default
with `private-dev` unless `notpm` is used.
2024-07-09 01:43:55 +00:00
Kelvin M. Klann
a6d2119ee6 build: sort.py: support "--" and fail on unknown option
Support "--" to end options and fail if an unknown option is given.
2024-05-13 20:22:30 -03:00
Kelvin M. Klann
b177ec0552 build: sort.py: use -i by default and add -n
Overwrite in-place by default (`-i`) and add `-n` to override it.

This restores the previous default behavior (from 0.9.72), for the sake
of being consistent with all previous versions and because it's more
likely to be the desired behavior in most cases.

This amends commit aa08aa132 ("build: sort.py: add and require -i to
edit in-place (#6290)", 2024-03-25).
2024-05-13 20:15:45 -03:00
Kelvin M. Klann
aa08aa132b
build: sort.py: add and require -i to edit in-place (#6290)
Similarly to `sed -i` and `perl -i`.

This allows checking if sort.py correctly sorts the relevant lines in a
profile without having to overwrite it, which makes debugging and
testing easier (for example, in #6261).

Note: If it finds items that are not sorted, it still sorts them, prints
the diff and returns an error.
2024-03-25 08:51:59 +00:00
Kelvin M. Klann
908e5a1a43 build: sort.py: filter empty and duplicate items
Note: This seems to already be done for `protocol` lines.

Before:

    $ ./contrib/sort.py test.profile
    sort.py: checking 1 profile(s)...
    test.profile:1:-private-etc ,,bar,,foo,,bar,,,
    test.profile:1:+private-etc ,,,,,,,bar,bar,foo
    test.profile:2:-protocol ,,unix,,bluetooth,,unix,,inet,,,
    test.profile:2:+protocol unix,inet,bluetooth
    [ Fixed ] test.profile

After:

    $ ./contrib/sort.py test.profile
    sort.py: checking 1 profile(s)...
    test.profile:1:-private-etc ,,bar,,foo,,bar,,,
    test.profile:1:+private-etc bar,foo
    test.profile:2:-protocol ,,unix,,bluetooth,,unix,,inet,,,
    test.profile:2:+protocol unix,inet,bluetooth
    [ Fixed ] test.profile
2024-03-03 10:10:39 -03:00
netblue30
8c4cc9a839
Merge pull request #6230 from kmk3/build-reduce-inconsistencies
build: reduce hardcoding and inconsistencies
2024-02-29 10:12:08 -05:00
Kelvin M. Klann
48db047cdb build: use generic wildcard on package install
To reduce TARNAME hardcoding.
2024-02-29 07:52:33 -03:00
Kelvin M. Klann
9cfeb485eb landlock: use "landlock.fs." prefix in filesystem commands
Since Landlock ABI v4 it is possible to restrict actions related to the
network and potentially more areas will be added in the future.

So use `landlock.fs.` as the prefix in the current filesystem-related
commands (and later `landlock.net.` for the network-related commands) to
keep them organized and to match what is used in the kernel.

Examples of filesystem and network access flags:

* `LANDLOCK_ACCESS_FS_EXECUTE`: Execute a file.
* `LANDLOCK_ACCESS_FS_READ_DIR`: Open a directory or list its content.
* `LANDLOCK_ACCESS_NET_BIND_TCP`: Bind a TCP socket to a local port.
* `LANDLOCK_ACCESS_NET_CONNECT_TCP`: Connect an active TCP socket to a
  remote port.

Relates to #6078.
2024-02-27 22:27:46 -03:00
Kelvin M. Klann
f70ffbe76c landlock: split .special into .makeipc and .makedev
As discussed with @topimiettinen[1], it is unlikely that an unprivileged
process would need to directly create block or character devices.  Also,
`landlock.special` is not very descriptive of what it allows.

So split `landlock.special` into:

* `landlock.makeipc`: allow creating named pipes and sockets (which are
  usually used for inter-process communication)
* `landlock.makedev`: allow creating block and character devices

Misc: The `makedev` name is based on `nodev` from mount(8), which makes
mount not interpret block and character devices.  `ipc` was suggested by
@rusty-snake[2].

Relates to #6078.

[1] https://github.com/netblue30/firejail/pull/6078#pullrequestreview-1740569786
[2] https://github.com/netblue30/firejail/pull/6187#issuecomment-1924107294
2024-02-02 19:37:06 -03:00
netblue30
ae8f62dba0 update copyright 2024 2024-01-12 11:23:22 -05:00
Kelvin M. Klann
760f50f78a landlock: move commands into profile and add landlock.enforce
Changes:

* Move commands from --landlock and --landlock.proc= into
  etc/inc/landlock-common.inc
* Remove --landlock and --landlock.proc=
* Add --landlock.enforce

Instead of hard-coding the default commands (and having a separate
command just for /proc), move them into a dedicated profile to make it
easier for users to interact with the entries (view, copy, add ignore
entries, etc).

Only enforce the Landlock commands if --landlock.enforce is supplied.
This allows safely adding Landlock commands to (upstream) profiles while
keeping their enforcement opt-in.  It also makes it simpler to
effectively disable all Landlock commands, by using
`--ignore=landlock.enforce`.

Relates to #6078.
2023-12-11 22:47:11 -03:00
netblue30
9ba5c8d50b
Merge pull request #6078 from kmk3/landlock_v3
feature: add Landlock support
2023-12-04 09:18:05 -05:00
netblue30
13b2c566df feature: add Landlock support
Based on 5315 by ChrysoliteAzalea.

It is based on the same underlying structure, but with a lot of
refactoring/simplification and with bugfixes and improvements.

Co-authored-by: Kelvin M. Klann <kmk3.code@protonmail.com>
Co-authored-by: Азалия Смарагдова <charming.flurry@yandex.ru>
2023-11-07 17:55:13 -03:00
Kelvin M. Klann
98e34c444b build: sort.py: use case-sensitive sorting
To match how things are sorted elsewhere, such as with `noblacklist` /
`whitelist` lines (vertically) in profiles and in
ci/check/profiles/sort-disable-programs.sh and src/etc-cleanup/main.c.

This makes the order in `private-etc` always be groups (`@group`), then
uppercase paths, then lowercase paths.  Example from
etc/profile-m-z/softmaker-common.profile:

    private-etc @tls-ca,SoftMaker,fstab

Note that this does not affect a significant amount of profiles; most
changes are in `private-bin` / `private-lib` lines and in `private-etc`
lines for newer profiles that do not use groups.  This is partly due to
commit 5d0822c52 ("private-etc: big profile changes", 2023-02-05)
replacing `X11` with `@x11` in `private-etc` lines and then commit
0f996ea4d ("private-etc: groups modified", 2023-02-05) removing
`Trolltech.conf` from `private-etc` lines and using case-sensitive
sorting in them.

Relates to #5610.
2023-10-27 16:40:39 -03:00
Kelvin M. Klann
ee27c8e15c sort.py: fix missing/duplicated commands in usage 2023-10-25 14:19:43 -03:00
mammo0
ac63d80630
contrib/syntax: remove 'text/plain' from firejail-profile.lang.in (#6059)
The `mimetypes` property contains the section `text/plain`. This causes
for example the Gnome Editor to recognize every simple text file as a
firejail profile file. See this issue:
https://gitlab.gnome.org/GNOME/gnome-text-editor/-/issues/612

Fixes #6057.
2023-10-22 23:50:42 +00:00
Kelvin M. Klann
ce6fb3a8dd build: add missing dbus/x11 commands to arg1 list
Fix the list generation and run `make syntax`.

Relates to #5627.
2023-09-06 03:19:32 -03:00
Kelvin M. Klann
bfcf8bc31a
Merge pull request #5956 from kmk3/build-fix-dep-syntax
build: add missing makefile dep & syntax improvements
2023-08-14 21:37:50 +00:00
Kelvin M. Klann
204c45adee build: improve char escaping of syntax lists
Escape `.` only when generating the syntax files rather than directly in
the syntax lists, so that the latter contain the command names as is.

This also makes the escaping apply to the arg1 syntax list as well.

Note: Double escaping (`\\\\.`) is used in `regex_fromlf` because its
output is used in another sed replacement (where it needs to be `\\.`).

Relates to #5627.
2023-08-14 18:16:10 -03:00
Kelvin M. Klann
9490fc1e71 build: fix codespell errors in more files
Found by simply running `codespell .`.

Environment: codespell 2.2.5-2 on Artix Linux.
2023-08-13 23:23:27 -03:00
Kelvin M. Klann
61897ea50e contrib/syntax: run make syntax
This adds the `shell` command.  Note that it's still being parsed in
profile.c, even if it's just to return an error.

Commands used to remake them:

    rm contrib/syntax/lists/*
    make syntax

Relates to #5627 #5894.
2023-07-23 05:27:20 -03:00