[GH-ISSUE #1063] bindmount for /etc/hosts without root #722

Closed
opened 2026-05-05 06:31:27 -06:00 by gitea-mirror · 4 comments
Owner

Originally created by @ibukanov on GitHub (Jan 21, 2017).
Original GitHub issue: https://github.com/netblue30/firejail/issues/1063

To override an IP address for a host in a jail I use the --bind option to point /etc/hosts to a file with the desired IP mapping. However, it requires that I run firejail as root. It would be nice to have an option to provide a custom context for /etc/hosts without requiring root. This could be similar to --dns that provides a custom /etc/resolve.conf.

Originally created by @ibukanov on GitHub (Jan 21, 2017). Original GitHub issue: https://github.com/netblue30/firejail/issues/1063 To override an IP address for a host in a jail I use the --bind option to point /etc/hosts to a file with the desired IP mapping. However, it requires that I run firejail as root. It would be nice to have an option to provide a custom context for /etc/hosts without requiring root. This could be similar to --dns that provides a custom /etc/resolve.conf.
gitea-mirror 2026-05-05 06:31:27 -06:00
Author
Owner

@netblue30 commented on GitHub (Jan 22, 2017):

You are all set:

       --hosts-file=file
              Use file as /etc/hosts.

              Example:
              $ firejail --hosts-file=~/myhosts firefox

In a profile file use "hosts-file filename".

<!-- gh-comment-id:274337435 --> @netblue30 commented on GitHub (Jan 22, 2017): You are all set: ````` --hosts-file=file Use file as /etc/hosts. Example: $ firejail --hosts-file=~/myhosts firefox ````` In a profile file use "hosts-file filename".
Author
Owner

@ibukanov commented on GitHub (Jan 22, 2017):

This is brilliant :)

I am curious why the code insists that the file should be owned by the user? I.e. what is problematic with mounting a file that is owned by root and world readable?

<!-- gh-comment-id:274340490 --> @ibukanov commented on GitHub (Jan 22, 2017): This is brilliant :) I am curious why the code insists that the file should be owned by the user? I.e. what is problematic with mounting a file that is owned by root and world readable?
Author
Owner

@ibukanov commented on GitHub (Jan 22, 2017):

Is that restriction that the file must be owned by the user to prevent an accidental exposure of root-owned files that are world-readable but not accessible to the user due to no executable permissions on a file path?

<!-- gh-comment-id:274341308 --> @ibukanov commented on GitHub (Jan 22, 2017): Is that restriction that the file must be owned by the user to prevent an accidental exposure of root-owned files that are world-readable but not accessible to the user due to no executable permissions on a file path?
Author
Owner

@netblue30 commented on GitHub (Jan 23, 2017):

You are right, in this case a simple read access check is enough. All fixed in git.

<!-- gh-comment-id:274506843 --> @netblue30 commented on GitHub (Jan 23, 2017): You are right, in this case a simple read access check is enough. All fixed in git.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/firejail#722
No description provided.