diff options
Diffstat (limited to 'src/nss-myhostname')
-rw-r--r-- | src/nss-myhostname/nss-myhostname.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/nss-myhostname/nss-myhostname.c b/src/nss-myhostname/nss-myhostname.c index 2f768603b0..dcf7c1f5de 100644 --- a/src/nss-myhostname/nss-myhostname.c +++ b/src/nss-myhostname/nss-myhostname.c @@ -47,6 +47,13 @@ NSS_GETHOSTBYNAME_PROTOTYPES(myhostname); NSS_GETHOSTBYADDR_PROTOTYPES(myhostname); +static bool is_gateway(const char *hostname) { + assert(hostname); + + return streq(hostname, "gateway") || + streq(hostname, "gateway."); +} + enum nss_status _nss_myhostname_gethostbyname4_r( const char *name, struct gaih_addrtuple **pat, @@ -78,7 +85,7 @@ enum nss_status _nss_myhostname_gethostbyname4_r( canonical = "localhost"; local_address_ipv4 = htonl(INADDR_LOOPBACK); - } else if (streq(name, "gateway") || streq(name, "gateway.")) { + } else if (is_gateway(name)) { n_addresses = local_gateways(NULL, 0, AF_UNSPEC, &addresses); if (n_addresses <= 0) { @@ -348,7 +355,7 @@ enum nss_status _nss_myhostname_gethostbyname3_r( canonical = "localhost"; local_address_ipv4 = htonl(INADDR_LOOPBACK); - } else if (streq(name, "gateway") || streq(name, "gateway.")) { + } else if (is_gateway(name)) { n_addresses = local_gateways(NULL, 0, af, &addresses); if (n_addresses <= 0) { |