Commit graph

32 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
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
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
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
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
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
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
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
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
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
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
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
Kelvin M. Klann
71d7572950 editorconfig: add indentation rules
Commands used to list the file extensions used in the project:

    $ git ls-files | sed -En 's/.*(\.[^.]+)$/\1/p' |
      LC_ALL=C sort | uniq -c

For rules that are more specific to a given directory, put a dedicated
.editorconfig file in it.
2023-02-20 18:07:09 -03:00
Antoine Catton
d0a12f27d6 feature: add 'keep-shell-rc' flag and option
This fixes #1127.

This allow a user to provide their own zshrc/bashrc inside the jail.
This is very useful when using firejail to develop and prevent bad pip
packages to access your system.
2023-02-03 23:11:18 +01:00
Kelvin M. Klann
aad1351ab1 build: auto-generate syntax files
Changes:

* Generate firejail.vim from firejail.vim.in
* Generate firejail-profile.lang from firejail-profile.lang.in
* Update the manual syntax file steps on the new command checklist on
  CONTRIBUTING.md to use `make syntax` instead

Relates to #2679 #5502 #5577 #5612.
2023-01-28 00:05:54 -03:00
Kelvin M. Klann
c7c4f57d13 build: auto-generate syntax lists
Changes:

* Use the commands from contrib/vim/syntax/firejail.vim to create
  makefile targets to generate syntax lists in contrib/syntax/lists
* Add contrib/syntax/files/example.in as an example of how to generate
  syntax files
* Generate and add the syntax lists, to make it easier to spot if they
  are properly updated when a new command is added or if their recipes
  also need changes
* Add "syntax" and "contrib" makefile targets

Note: The generation commands are executed mostly silently to avoid
generating too much noise when also making other targets.

Note2: In some generation commands, a `$$` escape is used to pass `$` to
the shell, to avoid being interpreted by make as the start of a macro.

Note3: `@make_input@` is used in example.in to make it clear that the
file is generated (and that it is generated by make rather than
configure), similarly to how `@configure_input@` is used in configure
input files.  See also apparmor.vim:

    $ head -n 2 /usr/share/vim/vimfiles/syntax/apparmor.vim
    " generated from apparmor.vim.in by create-apparmor.vim.py
    " do not edit this file - edit apparmor.vim.in or create-apparmor.vim.py instead

Environment: apparmor 3.1.2-1 on Artix Linux.

Relates to #2679 #5502 #5577 #5612.
2023-01-27 23:58:30 -03:00
Kelvin M. Klann
88ba851893 build: move syntax files to contrib/syntax/files
Having all of syntax files in the same directory makes it easier to
reference all of them at once on a makefile (such as with
`contrib/syntax/files/*.in`).

Also, this makes the path to the gtksourceview language-spec shorter.
Current path/new path:

* contrib/gtksourceview-5/language-specs/firejail-profile.lang
* contrib/syntax/files/firejail-profile.lang

Currently, adding a rule to the root Makefile to generate the
language-spec in the same directory as an input file would take at least
95 characters (with only a single dependency):

    contrib/gtksourceview-5/language-specs/%.lang: contrib/gtksourceview-5/language-specs/%.lang.in

With this commit, the above shortened to 59 characters:

    contrib/syntax/files/%.lang: contrib/syntax/files/%.lang.in

Which should make it more readable.

Relates to #2679 #5502.
2023-01-27 23:20:40 -03:00