hostname-util: introduce new is_gateway_hostname() call

This moves is_gateway() from nss-myhostname into the basic APIs, and
makes it more like is_localhost(). Also, we rename it to
is_gateway_hostname() to make it more expressive.

Sharing this function in src/basic/ allows us to reuse the function for
routing name requests in resolved (in a later commit).
This commit is contained in:
Lennart Poettering
2015-08-21 12:07:13 +02:00
parent 0d43ffef5a
commit 46a5e0e742
3 changed files with 14 additions and 9 deletions
+11
View File
@@ -151,6 +151,17 @@ bool is_localhost(const char *hostname) {
endswith_no_case(hostname, ".localdomain.");
}
bool is_gateway_hostname(const char *hostname) {
assert(hostname);
/* This tries to identify the valid syntaxes for the our
* synthetic "gateway" host. */
return
strcaseeq(hostname, "gateway") ||
strcaseeq(hostname, "gateway.");
}
int sethostname_idempotent(const char *s) {
char buf[HOST_NAME_MAX + 1] = {};
+1
View File
@@ -33,6 +33,7 @@ bool hostname_is_valid(const char *s, bool relax) _pure_;
char* hostname_cleanup(char *s);
bool is_localhost(const char *hostname);
bool is_gateway_hostname(const char *hostname);
int sethostname_idempotent(const char *s);