summaryrefslogtreecommitdiff
path: root/src/nss-myhostname
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-12-18 01:44:34 +0100
committerLennart Poettering <lennart@poettering.net>2014-12-19 02:07:42 +0100
commitb7d131939347fee0f1af7a288052a3dffb5a6763 (patch)
tree55afcf11e48665155eb74cb81877fa07c3214e49 /src/nss-myhostname
parentc853953658865ec3b3487e3f1eb2cc0516320bf3 (diff)
nss-myhostname: introduce is_gateway() similar to the existing is_hostname()
Diffstat (limited to 'src/nss-myhostname')
-rw-r--r--src/nss-myhostname/nss-myhostname.c11
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) {