diff options
author | Lennart Poettering <lennart@poettering.net> | 2014-07-02 13:41:31 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2014-07-02 13:41:31 +0200 |
commit | fecc80c1ba2eed9dadb9a10c15508c356bcc5fc1 (patch) | |
tree | 8db82ae690416827c910683432c9746f365acf2e /src/shared/util.c | |
parent | 9a00f57a5ba7ed431e6bac8d8b36518708503b4e (diff) |
util: generalize is_localhost() and use it everywhere where applicable
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."); +} |