mirror of
https://github.com/netblue30/firejail.git
synced 2026-05-15 14:16:14 -06:00
[GH-ISSUE #2758] Firejail does not work with a custom hosts file #1733
Labels
No labels
LTS merge
LTS merge
bug
bug
converted-to-discussion
doc-todo
documentation
duplicate
enhancement
file-transfer
firecfg
firejail-in-firejail
firetools
graphics
help wanted
information_old
installation
invalid
modif
moved
needinfo
networking
notabug
notourbug
old-version
overlayfs
packaging
profile-request
pull-request
question
question_old
removal
runtime-permissions
sandbox-ipc
security
stale
wiki
wiki
wontfix
wordpress
workaround
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/firejail#1733
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @rmrgh on GitHub (Jun 10, 2019).
Original GitHub issue: https://github.com/netblue30/firejail/issues/2758
When running firejail with a custom hosts file:
$ firejail --noprofile --private --hosts-file=hosts firefox -no-remoteit reports the following errors:
My hosts file contains only:
Even with an empty file, it report the same errors.
Firejail Version: 0.9.58
Linux Distribution: NixOS 19.03
@rusty-snake commented on GitHub (Jun 11, 2019):
Can't reproduce with firejail 0.9.61 under Fedora 29.
@chiraag-nataraj commented on GitHub (Jun 11, 2019):
I even just tried
firejail --hosts-file=/dev/nulland it worked.@netblue30 commented on GitHub (Jun 11, 2019):
There could be two reasons it to fail: if the host file is a symbolic link, or if the user doesn't have read access to the file. Also, try to put a full path for the host file, something like "--host-file=/home/username/hostfile". Works fine on 0.9.58, that code didn't change in ages.
@Nudin commented on GitHub (Mar 31, 2020):
I got the same issue on Arch with firejail 0.9.62. The file is no symlink and readable by the user.
@Enteee commented on GitHub (Mar 23, 2021):
Can confirm the same behavior as @rmrgh observed on NixOS (symlinked /etc/hosts). Firejail
0.9.64.4does fail onfirejail --hosts-file=/dev/nullwith:this is the check that fails:
2609e5cf0b/src/firejail/fs_hostname.c (L226-L227)Removing this check seem to be simple enough, but I am not quite sure why this is there in the first place.
For those who use NixOs: I have written an overlay that removes the check by patching firejail. Running the command is working, but the /etc/hosts file is not read. Inside the jail the file /etc/hosts points to is actually changed to whatever you set as
--hosts-filebut it is not actually used by the system resolve. Don't really know why...@deliciouslytyped commented on GitHub (Mar 31, 2021):
@Enteee thanks, I ran into the same issue.
Low key note that copying the script into a config wont work if you use spaces because the source file uses tabs, it causes a small bit of confusion as to why the patch isn't applying.
@dunesong commented on GitHub (Jul 31, 2021):
Had the same issue. In my case, /etc/hosts was not owned by root. Correcting that fixed the issue.
sudo chown root:root /etc/hosts@smitsohu commented on GitHub (Sep 22, 2021):
@onny May I ask where the link points to in NixOS?
EDIT: Reading a bit more about NixOS this is probably a stupid question. It points to
/nix/store/somethingif I understand correctly.@onny commented on GitHub (Sep 24, 2021):
Yep thats right.
@Enteee commented on GitHub (Sep 25, 2021):
@netblue30 : why was this closed. I think the issue is still relevant.
@rusty-snake commented on GitHub (Sep 25, 2021):
Because #4560 was merged and this issue is a linked issues in #4560.
@Enteee do you still get this error?
@Enteee commented on GitHub (Sep 25, 2021):
I have not yet tested it. But I think before merging something that is more or less my suggested patch somebody should have falsified the following:
@earldouglas commented on GitHub (Mar 6, 2025):
I also ran into this on NixOS. In my case, the fix was simply to add a newline to the end of my hosts file.
@gleruzh commented on GitHub (Apr 10, 2025):
Check owner and permissions on your hosts file.
@kmk3 commented on GitHub (Apr 12, 2025):
Note that this issue was closed years ago.
If something does not appear to work as intended, please open a new issue and
follow the bug report template: