[systemd-devel] [PATCH] hostname: Allow comments in /etc/hostname

Thomas H.P. Andersen phomes at gmail.com
Mon May 18 02:49:26 PDT 2015

On Mon, May 18, 2015 at 11:33 AM, Martin Pitt <martin.pitt at ubuntu.com> wrote:
> Hello all,
> We got a report [1] that systemd doesn't allow comments in
> /etc/hostname. If there is a comment, your host name ends up being
> "# comment". But the original hostname(1) tool documents that comments
> are allowed, thus in the sysvinit/upstart world these worked fine.
> Earlier versions of cloud-init also produced a comment there.
> This currently uses read_full_file() and strv_split_newlines() which
> is relatively expensive (although, in most cases there will only be
> one line). In cases like these should we rather use an fgets() loop?

I think FOREACH_LINE would make this more readable.

> Given that host names are limited to 64 bytes (HOST_NAME_MAX) this
> could be written more efficiently.

More information about the systemd-devel mailing list