guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Contents of /etc/hosts


From: John Darrington
Subject: Contents of /etc/hosts
Date: Wed, 5 Oct 2016 20:31:47 +0200
User-agent: Mutt/1.5.23 (2014-03-12)

Further to discussions on #guix earlier this week ...

Some of us are concerned about what we currently have in /etc/hosts viz:

127.0.0.1 localhost gambrinus
::1       localhost gambrinus

(my machine is called "gambrinus")


This is a problem becuase it means that "hostname -f" returns the wrong thing.

Further, the man page for hostname (from the net-tools package) says:

   The  recommended  method  of  setting  the  FQDN  is  to make the hostname be
   an alias for the fully qualified name using /etc/hosts, DNS, or NIS.  For
   example, if the hostname was "ursula", one might have a line in /etc/hosts
   which reads:

   127.0.1.1    ursula.example.com ursula

However I would recommend 127.0.0.2 instead of 127.0.1.1 because RFC 3330
mentions that 127.0.0.0/8 is reserved for loopback, but the rest of
127.0.0.0/16 subject to allocation.


Many systems also have a file called /etc/hostname and  according to the 
hostname man page:

     /etc/hostname  Historically this file was supposed to only contain the
     hostname and not the full canonical FQDN.  Nowadays  most software is able
     to cope with a full FQDN here. This file is read at boot time by the system
     initialization  scripts to set the hostname.


Guix of course uses /etc/config.scm so we don't need /etc/hostname but there
might be some rougue programs which rely on it so perhaps we should have one.


When setting the name via the net-utils "hostname" utility,
HOST_NAME_MAX is the maximum length which can be passed to sethostname.
On Linux, this limit is 64


So security conscious programs (notably kerberos) will refuse to operate if
the forward and reverse DNS do not agree.


Some DHCP servers are configured to return the domain name which they
expect the host to use.

RFC 1034 \union 1123
stipulates that, labels may contain the characters [a-zA-Z0-9-] and \
may not start with - 

In services/base.scm we have:

(define host-name-service-type
  (shepherd-service-type
   'host-name
   (lambda (name)
     (shepherd-service
      (documentation "Initialize the machine's host name.")
      (provision '(host-name))
      (start #~(lambda _
                 (sethostname #$name)))
      (respawn? #f)))))

This will fail if /etc/config.scm has is too long, or has invalid characters.
So we should check it in system reconfigure.


So ... my recommendations:

1. We change /etc/hosts to read


 127.0.0.1 localhost.localdomain localhost 
 ::1       localhost.localdomain localhost

 127.0.0.2 gambrinus


2. We put some checks in guix system to ensure that the host-name field does not
 exceed 63 bytes (not characters) and that it conforms to the format of RFC1034


Any objections if I commit a patch to gnu/system.scm ??

J'

-- 
Avoid eavesdropping.  Send strong encrypted email.
PGP Public key ID: 1024D/2DE827B3 
fingerprint = 8797 A26D 0854 2EAB 0285  A290 8A67 719C 2DE8 27B3
See http://sks-keyservers.net or any PGP keyserver for public key.

Attachment: signature.asc
Description: Digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]