[elbe-devel] [PATCH] fix /etc/hosts generation

Torben Hohn torben.hohn at linutronix.de
Tue Dec 4 17:09:10 CET 2018


On Fri, Nov 30, 2018 at 10:13:18AM +0100, Manuel Traut wrote:
> fix github issue #185:
> 
> --8<--
> The format of the /etc/hosts file for Debian Stretch is described here:
> https://manpages.debian.org/stretch/manpages/hosts.5.en.html. According to this
> document, the hostname
> should be specified using 127.0.1.1 and not 127.0.01. There should be a tab
> instead of a space between
> 127.0.1.1 and the hostname.
> 
> When giving an empty **<domain></domain>** section, the **/etc/hosts** file will
> contain test.None. In
> most cases we don't need/want a domain entry. There seems to be no way to tell
> Elbe to skip generating a
> domain entry.
> --8<--
> 
> The statement about tabs as delimiters is wrong:
> "Fields  of  the  entry are separated by any number of blanks and/or tab characters."
> 
> Signed-off-by: Manuel Traut <manut at linutronix.de>

Reviewed-by: Torben Hohn <torben.hohn at linutronix.de>

> ---
>  elbepack/rfs.py   | 12 +++++++-----
>  schema/dbsfed.xsd |  2 +-
>  2 files changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/elbepack/rfs.py b/elbepack/rfs.py
> index 4009f61b..eec4e6a0 100644
> --- a/elbepack/rfs.py
> +++ b/elbepack/rfs.py
> @@ -283,12 +283,14 @@ class BuildEnv (object):
>              (passwd, passwd))
>  
>          hostname = self.xml.text("target/hostname")
> -        domain = self.xml.text("target/domain")
> +        fqdn = hostname
> +        if self.xml.has("target/domain"):
> +            fqdn = ("%s.%s" % (hostname, self.xml.text("target/domain")))
>  
>          self.log.chroot(
>              self.rfs.path,
> -            """/bin/sh -c 'echo "127.0.0.1 %s.%s %s elbe-daemon" >> """
> -            """/etc/hosts'""" % (hostname, domain, hostname))
> +            """/bin/sh -c 'echo "127.0.1.1 %s %s elbe-daemon" >> """
> +            """/etc/hosts'""" % (fqdn,hostname))
>  
>          self.log.chroot(
>              self.rfs.path,
> @@ -296,8 +298,8 @@ class BuildEnv (object):
>  
>          self.log.chroot(
>              self.rfs.path,
> -            """/bin/sh -c 'echo "%s.%s" > """
> -            """/etc/mailname'""" % (hostname, domain))
> +            """/bin/sh -c 'echo "%s" > """
> +            """/etc/mailname'""" % (fqdn))
>  
>          if self.xml.has("target/console"):
>              serial_con, serial_baud = self.xml.text(
> diff --git a/schema/dbsfed.xsd b/schema/dbsfed.xsd
> index d52b80f6..76674c62 100644
> --- a/schema/dbsfed.xsd
> +++ b/schema/dbsfed.xsd
> @@ -744,7 +744,7 @@
>            </documentation>
>          </annotation>
>        </element>
> -      <element name="domain" type="rfs:string" minOccurs="1" maxOccurs="1">
> +      <element name="domain" type="rfs:string" minOccurs="0" maxOccurs="1">
>          <annotation>
>            <documentation>
>              domainname of the network the target system is part of
> -- 
> 2.19.1
> 

-- 
Torben Hohn
Linutronix GmbH | Bahnhofstrasse 3 | D-88690 Uhldingen-Mühlhofen
Phone: +49 7556 25 999 18; Fax.: +49 7556 25 999 99

Hinweise zum Datenschutz finden Sie hier (Informations on data privacy 
can be found here): https://linutronix.de/kontakt/Datenschutz.php

Linutronix GmbH | Firmensitz (Registered Office): Uhldingen-Mühlhofen | 
Registergericht (Registration Court): Amtsgericht Freiburg i.Br., HRB700 
806 | Geschäftsführer (Managing Directors): Heinz Egger, Thomas Gleixner
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.linutronix.de/pipermail/elbe-devel/attachments/20181204/c0ecfe20/attachment.sig>


More information about the elbe-devel mailing list