1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-02-22 17:57:49 +03:00

*.localdomain != localhost

".localdomain" is not a reserved suffix (or prefix). I'm not aware of any
product expecting *.localdomain to resolve to localhost, however I am aware of
at least one product that defaults to ".localdomain" as its DNS suffix provided
via DHCP (pfSense). This leads to unexpected results when attempting to access
a host that's offline (or a host that's online, when nsswitch.conf is
[mis-]configured to have myhostname ahead of DNS).

Operate on:
localhost (and localhost.)
*.localhost (and *.localhost.)
localhost.localdomain (and localhost.localdomain.)
*.localhost.localdomain (and *.localhost.localdomain.)

We should not cover:
*.localdomain (nor *.localdomain.)
localdomain (nor localdomain.)
This commit is contained in:
David R. Hedges 2016-02-18 21:31:38 -06:00 committed by Zbigniew Jędrzejewski-Szmek
parent 48ddca5f35
commit 63003524cb
3 changed files with 13 additions and 11 deletions

View File

@ -71,9 +71,10 @@
is on the local loopback) and the IPv6 address ::1 (which is the is on the local loopback) and the IPv6 address ::1 (which is the
local host).</para></listitem> local host).</para></listitem>
<listitem><para>The hostname <literal>localhost</literal> (as well as any hostname ending in <listitem><para>The hostnames <literal>localhost</literal> and
<literal>.localhost</literal>, <literal>.localdomain</literal> or equal to <literal>localdomain</literal>) is <literal>localhost.localdomain</literal> (as well as any hostname
resolved to the IP addresses 127.0.0.1 and ::1.</para></listitem> ending in <literal>.localhost</literal> or <literal>.localhost.localdomain</literal>)
are resolved to the IP addresses 127.0.0.1 and ::1.</para></listitem>
<listitem><para>The hostname <literal>gateway</literal> is <listitem><para>The hostname <literal>gateway</literal> is
resolved to all current default routing gateway addresses, resolved to all current default routing gateway addresses,

View File

@ -87,9 +87,10 @@
is on the local loopback) and the IPv6 address ::1 (which is the is on the local loopback) and the IPv6 address ::1 (which is the
local host).</para></listitem> local host).</para></listitem>
<listitem><para>The hostname <literal>localhost</literal> (as well as any hostname ending in <listitem><para>The hostnames <literal>localhost</literal> and
<literal>.localhost</literal>, <literal>.localdomain</literal> or equal to <literal>localdomain</literal>) is <literal>localhost.localdomain</literal> (as well as any hostname
resolved to the IP addresses 127.0.0.1 and ::1.</para></listitem> ending in <literal>.localhost</literal> or <literal>.localhost.localdomain</literal>)
are resolved to the IP addresses 127.0.0.1 and ::1.</para></listitem>
<listitem><para>The hostname <literal>gateway</literal> is <listitem><para>The hostname <literal>gateway</literal> is
resolved to all current default routing gateway addresses, resolved to all current default routing gateway addresses,

View File

@ -150,16 +150,16 @@ bool is_localhost(const char *hostname) {
assert(hostname); assert(hostname);
/* This tries to identify local host and domain names /* This tries to identify local host and domain names
* described in RFC6761 plus the redhatism of .localdomain */ * described in RFC6761 plus the redhatism of localdomain */
return strcaseeq(hostname, "localhost") || return strcaseeq(hostname, "localhost") ||
strcaseeq(hostname, "localhost.") || strcaseeq(hostname, "localhost.") ||
strcaseeq(hostname, "localdomain.") || strcaseeq(hostname, "localhost.localdomain") ||
strcaseeq(hostname, "localdomain") || strcaseeq(hostname, "localhost.localdomain.") ||
endswith_no_case(hostname, ".localhost") || endswith_no_case(hostname, ".localhost") ||
endswith_no_case(hostname, ".localhost.") || endswith_no_case(hostname, ".localhost.") ||
endswith_no_case(hostname, ".localdomain") || endswith_no_case(hostname, ".localhost.localdomain") ||
endswith_no_case(hostname, ".localdomain."); endswith_no_case(hostname, ".localhost.localdomain.");
} }
bool is_gateway_hostname(const char *hostname) { bool is_gateway_hostname(const char *hostname) {