-
Notifications
You must be signed in to change notification settings - Fork 567
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Firejail does not work with a custom hosts file #2758
Comments
Can't reproduce with firejail 0.9.61 under Fedora 29.
|
I even just tried |
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. |
I got the same issue on Arch with firejail 0.9.62. The file is no symlink and readable by the user.
|
Can confirm the same behavior as @rmrgh observed on NixOS (symlinked /etc/hosts). Firejail
this is the check that fails: firejail/src/firejail/fs_hostname.c Lines 226 to 227 in 2609e5c
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 self: super: {
firejail = (super.firejail.overrideAttrs (oldAttrs: {
patches = [
(
# Fix for https://github.com/netblue30/firejail/issues/2758
super.writeText "fix-2758" ''
diff --git a/src/firejail/fs_hostname.c b/src/firejail/fs_hostname.c
index 8a3bb71e..0d318744 100644
--- a/src/firejail/fs_hostname.c
+++ b/src/firejail/fs_hostname.c
@@ -222,9 +218,6 @@ void fs_mount_hosts_file(void) {
struct stat s;
if (stat("/etc/hosts", &s) == -1)
goto errexit;
- // not a link
- if (is_link("/etc/hosts"))
- goto errexit;
// owned by root
if (s.st_uid != 0)
goto errexit;
''
)
];
}));
} |
@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. |
Had the same issue. In my case, /etc/hosts was not owned by root. Correcting that fixed the issue.
|
@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 |
Yep thats right.
|
@netblue30 : why was this closed. I think the issue is still relevant. |
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:
|
Note: They are added in the order that the issues were fixed/closed. Note2: The issues were found through the following url: https://github.com/netblue30/firejail/issues?q=is%3Aclosed+label%3Abug+-label%3Asecurity+closed%3A%3E2021-06-29+ The date used is the release date of 0.9.66, so in theory the query should return every bug closed after that. Security-related issues are excluded because they will be added separately. Note3: All issues other than netblue30#4328 were fixed before 0.9.68rc1. Relates to netblue30#2758 netblue30#4235 netblue30#4328 netblue30#4387 netblue30#4395 netblue30#4460 netblue30#4467 netblue30#4558 netblue30#4560 netblue30#4586.
When running firejail with a custom hosts file:
$ firejail --noprofile --private --hosts-file=hosts firefox -no-remote
it 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
The text was updated successfully, but these errors were encountered: