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

Martin Pitt martin.pitt at ubuntu.com
Mon May 18 02:33:03 PDT 2015

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?
Given that host names are limited to 64 bytes (HOST_NAME_MAX) this
could be written more efficiently.



[1] https://launchpad.net/bugs/1053048
Martin Pitt                        | http://www.piware.de
Ubuntu Developer (www.ubuntu.com)  | Debian Developer  (www.debian.org)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-hostname-Allow-comments-in-etc-hostname.patch
Type: text/x-diff
Size: 3656 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20150518/7e301cf3/attachment.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20150518/7e301cf3/attachment.sig>

More information about the systemd-devel mailing list