bad /storage/.config/hosts.conf

  • I don't know any side effects of a bad hosts.conf on LibreELEC, but discovered that this configuration file isn't like I would write it.


    Let's see (my box's name is kodi and set by dhcp) on unmodified hosts.conf:


    hostname -s (short) = kodi ok
    hostname -f (fqdn) = localhost nok
    hostname -d (domain) = nok


    Now we add
    127.0.0.1 localhost
    192.168.178.40 kodi kodi.fritz.box
    to /storage/.config/hosts.conf like in the example (IP short fqdn):


    hostname -s (short) = kodi ok
    hostname -f (fqdn) = kodi nok
    hostname -d (domain) = nok


    Now we change it to the correct way with
    127.0.0.1 localhost
    192.168.178.40 kodi.fritz.box kodi
    and get
    hostname -s (short) = kodi ok
    hostname -f (fqdn) = kodi.fritz.box ok
    hostname -d (domain) = fritz.box ok


    Voilà - first comes the IP_address, then the canonical_hostname (FQDN) and optionally aliases...


    So /storage/.config/hosts.conf should be:
    [hr]
    # hosts.conf


    # This configuration file allows you to manually map hostnames to
    # IP addresses


    # Format: IP_address canonical_hostname [aliases...]
    # Example: 192.168.0.3 libreelec.mynetwork libreelec


    # NOTE: do not edit /etc/hosts directly
    # edit /storage/.config/hosts.conf then reboot


    127.0.0.1 localhost
    ::1 localhost
    [hr]
    ajb

  • Dear LE-Team,


    it is many many years ago, that I edited /etc/hosts and was wondering that some code of software ignored it and claimed to know it better. It was SuSe's YAST which drove many admins crazy ... Here it is like a little déjà-vu now:


    Meanwile some months ago, I wrote my very small bug-report and pointed out, that the hosts file created by connman is not quite right and that the example of the given hosts file is not correct. It has nothing changed. And I pointed out that I don't know the side effects of it.


    Today I compiled the LE master from github for my WeTek Play 2 again and without any hosts file I can find:
    [hr]
    wetek:~ # cat /run/connman/hosts
    # hosts.conf


    # This configuration file allows you to manually map hostnames to
    # IP addresses


    # Format: <ipaddress> <hostname1> <hostname2>
    # Example: 192.168.0.3 libreelec libreelec.mynetwork


    # NOTE: do not edit /etc/hosts directly
    # edit /storage/.config/hosts.conf then reboot
    127.0.0.1 localhost wetek
    ::1 localhost ip6-localhost ip6-loopback wetek
    [hr]


    With my own hosts file containing the lines
    127.0.0.1 localhost
    192.168.178.1 fritz.box
    192.168.178.4 syno.fritz.box
    192.168.178.40 wetek.fritz.box


    I get the false /run/connman/hosts again:


    127.0.0.1 localhost
    192.168.178.1 fritz.box
    192.168.178.4 syno.fritz.box
    192.168.178.40 wetek.fritz.box
    127.0.0.1 localhost wetek
    ::1 localhost ip6-localhost ip6-loopback wetek


    Sorry, this is wrong! Ping to your hostname, and you will see it ...


    I wrote I don't know the side effects, but I read here of problems with Samba name resolution etc. Maybe there is a connection.


    BTW, if IPv6 is disabled, why is ::1 added by connman? The IP of my hostname wetek here is not 127.0.0.1, but 192.168.178.40. 127.0.0.1 is the IP of the loopback device. There are many computers around where you can check that and even RFCs.


    So please, correct that. Users writing bug reports and getting ignored, starts to loose fun ...


    Take care
    ajb


  • If you mean yourself, I have to agree.


    This doen't help ... But anyway, I looked where this configuration is made and suggest the following solution:


    1. I see the need of doing some automatic configuration BUT I also see the need of the rule, that no machine should alter any configuration made by an human. Could we agree to that important point?


    2. LibreELEC puts it's host.conf - whatever configuration the devs/deciders might think of are right - to /usr/share/services or whatever place


    3. LE looks whether /storage/.config/hosts.conf exists. If not, LE copies the configuration from place 2 to /run/connman/hosts. If yes, LE copies /storage/.config/hosts.conf to /run/connman/hosts. Python-script system.py in LibreELEC-settings-*/build/service.libreelec.settings/resources/lib/modules can be cleaned up where the "configuration" is made right now:


    hosts.write('127.0.0.1\tlocalhost %s\n' % self.struct['ident']['settings']['hostname']['value'])
    hosts.write('::1\tlocalhost ip6-localhost ip6-loopback %s\n' % self.struct['ident']['settings']['hostname']['value'])


    This would be clean and proper.


    For hosts.conf I suggest the following content:

    Edited once, last by ajb ().