1
0
mirror of https://github.com/systemd/systemd.git synced 2025-03-08 08:58:27 +03:00

nss-myhostname: introduce is_gateway() similar to the existing is_hostname()

This commit is contained in:
Lennart Poettering 2014-12-18 01:44:34 +01:00
parent c853953658
commit b7d1319393

View File

@ -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) {