netblue30 / firejail

Linux namespaces and seccomp-bpf sandbox

Home Page:https://firejail.wordpress.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

127.0.0.1 should reference localhost, not the hostname

intereglementet opened this issue · comments

/etc/hosts files typically contain something like this:

127.0.1.1 my-hostname
127.0.0.1 localhost

This makes the following feature typically do away with the localhost entry, and you end up with two hostname entries.

if (strstr(buf, "127.0.0.1") && done == 0) {

This causes problems for applications referencing localhost. The above line should, I think, instead look for 127.0.1.1.

A workaround is to have two localhost entries in the original file, as only one 127.0.0.1 entry is processed.

I did some additional googling. The conclusion is that having 127.0.0.1 alterered and set to anything other than "localhost" is, unfortunately, plain wrong.
The thing with 127.0.1.1 being set to whatever /etc/hostname contains appears to be a de facto standard introduced into debian almost 20 years ago.