[systemd-devel] [PATCH] networkd: send hostname to dhcp server
Lennart Poettering
lennart at poettering.net
Tue Jul 1 11:02:08 PDT 2014
On Tue, 01.07.14 10:37, Eugene Yakubovich (eugene.yakubovich at coreos.com) wrote:
> >
> > > +/* make sure the hostname is not "localhost" */
> > > +static bool is_localhost(const char *hostname) {
> > > + char *hostend;
> > > +
> > > + assert(hostname);
> > > +
> > > + hostend = strchr(hostname, '.');
> > > + if (hostend)
> > > + return strneq(hostname, "localhost", (hostend -
> > hostname));
> > > + else
> > > + return streq(hostname, "localhost");
> > > +}
> >
> > We have a similar check in pam_systemd, and in hostnamed. I'd prefer if
> > we could unify that and stick it in src/shared/util.[ch]. I am not
> > convinced though that check for all names with the "localhost."
> > prefix. That appears too broad to me. I'd really just check for
> > "localhost" and "localhost.localdomain", where the former is what
> > everybody uses, and the latter a redhatism...
> >
> >
> I think in practice localhost and localhost.localdomain should cover it but
> there is a
> recent RFC 6761 that says this (sec 6.3):
>
> The domain "localhost." and any names falling within ".localhost."
> are special in the following ways:
>
>
> ... all ways in which localhost is special follows ...
>
> Not sure how much weight this RFC carries and this patch does not follow it
> exactly as it should also be checking for somehost.localhost.abc.com
>
> It seemed to me that localhost.mydomain.com should really refer to your
> localhost so
> that is why I put the check in for that (and also to not special case
> localdomain).
I think this is a misunderstanding. The RFCs use the trailing dot to
indicate that the name shall not be subject to search domains, i.e. that
nothing should be appended to it. Hence "names falling within
.localhost." shall mean "*.localhost", not "*.localhost.*" if you follow
what I mean.
Taking this into account we should probably check for:
streq(n, "localhost") ||
streq(n, "localhost.") ||
endswith(n, ".localhost") ||
endswith(n, ".localhost.") ||
endswith(n, ".localdomain") ||
endswith(n, ".localdomain.")
This should then be in-line with the RFC, and also cover that
localdomain redhatism.
Lennart
--
Lennart Poettering, Red Hat
More information about the systemd-devel
mailing list