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.
This commit is contained in:
Kelvin M. Klann 2026-03-07 10:02:52 -03:00
parent 2e9a96bbdb
commit 09329b990f
15 changed files with 87 additions and 53 deletions

View file

@ -443,15 +443,21 @@ full path or a relative path for the filename.
Parent is shutting down, bye…
```
### --keep-hostname
### --hostname-randomize
```text
--keep-hostname
By default, the hostname is replaced by a random name generated
by firejail at startup. Use this option to disable this feature.
--hostname-randomize
Set sandbox hostname to a random value generated by firejail.
This is incompatible with --hostname.
Example:
$ firejail --keep-hostname
$ firejail --hostname-randomize /usr/bin/firefox
Note: Changing the hostname may cause breakage related to
networking (see #7048
<https://github.com/netblue30/firejail/issues/7048>) and may
cause X11 programs to crash on startup due to not being able to
authenticate to the X server (see #7062
<https://github.com/netblue30/firejail/issues/7062>).
```
### Landlock support - ongoing/experimental