summaryrefslogtreecommitdiff
path: root/src/basic/hostname-util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/basic/hostname-util.c')
-rw-r--r--src/basic/hostname-util.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/basic/hostname-util.c b/src/basic/hostname-util.c
index 8932c552c8..5a2d60f21d 100644
--- a/src/basic/hostname-util.c
+++ b/src/basic/hostname-util.c
@@ -12,6 +12,7 @@
#include "hostname-util.h"
#include "macro.h"
#include "string-util.h"
+#include "strv.h"
bool hostname_is_set(void) {
struct utsname u;
@@ -180,14 +181,16 @@ bool is_localhost(const char *hostname) {
/* This tries to identify local host and domain names
* described in RFC6761 plus the redhatism of localdomain */
- return strcaseeq(hostname, "localhost") ||
- strcaseeq(hostname, "localhost.") ||
- strcaseeq(hostname, "localhost.localdomain") ||
- strcaseeq(hostname, "localhost.localdomain.") ||
- endswith_no_case(hostname, ".localhost") ||
- endswith_no_case(hostname, ".localhost.") ||
- endswith_no_case(hostname, ".localhost.localdomain") ||
- endswith_no_case(hostname, ".localhost.localdomain.");
+ return STRCASE_IN_SET(
+ hostname,
+ "localhost",
+ "localhost.",
+ "localhost.localdomain",
+ "localhost.localdomain.") ||
+ endswith_no_case(hostname, ".localhost") ||
+ endswith_no_case(hostname, ".localhost.") ||
+ endswith_no_case(hostname, ".localhost.localdomain") ||
+ endswith_no_case(hostname, ".localhost.localdomain.");
}
bool is_gateway_hostname(const char *hostname) {