diff options
Diffstat (limited to 'src/shared/util.c')
-rw-r--r-- | src/shared/util.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/shared/util.c b/src/shared/util.c index a1c8baf237..ceafa019a8 100644 --- a/src/shared/util.c +++ b/src/shared/util.c @@ -6732,3 +6732,18 @@ char *tempfn_random(const char *p) { return t; } + +/* make sure the hostname is not "localhost" */ +bool is_localhost(const char *hostname) { + assert(hostname); + + /* This tries to identify local hostnames described in RFC6761 + * plus the redhatism of .localdomain */ + + return streq(hostname, "localhost") || + streq(hostname, "localhost.") || + endswith(hostname, ".localhost") || + endswith(hostname, ".localhost.") || + endswith(hostname, ".localdomain") || + endswith(hostname, ".localdomain."); +} |