From 63003524cb7c27b50583cc4d90b5d81af5f7a7f6 Mon Sep 17 00:00:00 2001 From: "David R. Hedges" Date: Thu, 18 Feb 2016 21:31:38 -0600 Subject: *.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.) --- src/basic/hostname-util.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/basic/hostname-util.c') diff --git a/src/basic/hostname-util.c b/src/basic/hostname-util.c index 7bb23448ed..4fe6a725aa 100644 --- a/src/basic/hostname-util.c +++ b/src/basic/hostname-util.c @@ -150,16 +150,16 @@ bool is_localhost(const char *hostname) { assert(hostname); /* 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") || strcaseeq(hostname, "localhost.") || - strcaseeq(hostname, "localdomain.") || - strcaseeq(hostname, "localdomain") || + strcaseeq(hostname, "localhost.localdomain") || + strcaseeq(hostname, "localhost.localdomain.") || endswith_no_case(hostname, ".localhost") || endswith_no_case(hostname, ".localhost.") || - endswith_no_case(hostname, ".localdomain") || - endswith_no_case(hostname, ".localdomain."); + endswith_no_case(hostname, ".localhost.localdomain") || + endswith_no_case(hostname, ".localhost.localdomain."); } bool is_gateway_hostname(const char *hostname) { -- cgit v1.2.3-54-g00ecf