summaryrefslogtreecommitdiff
path: root/src/nss-myhostname
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2019-04-10 21:40:49 +0200
committerLennart Poettering <lennart@poettering.net>2019-04-11 11:13:10 +0200
commite09e7ac3c4107a9bbbcd0e5f1c21825cfcb27b02 (patch)
tree7a56135ea7c1fcc11730f9441e6549ae294c18b0 /src/nss-myhostname
parenta62fc245d01433ed4559db1f6f661a984b2bce03 (diff)
downloadsystemd-e09e7ac3c4107a9bbbcd0e5f1c21825cfcb27b02.tar.gz
nss-myhostname: unify code that handles NOT_FOUND case
Just some minor rework to make this more like nss-resolve.
Diffstat (limited to 'src/nss-myhostname')
-rw-r--r--src/nss-myhostname/nss-myhostname.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/src/nss-myhostname/nss-myhostname.c b/src/nss-myhostname/nss-myhostname.c
index 707caaa321..90de140a9d 100644
--- a/src/nss-myhostname/nss-myhostname.c
+++ b/src/nss-myhostname/nss-myhostname.c
@@ -64,10 +64,8 @@ enum nss_status _nss_myhostname_gethostbyname4_r(
} else if (is_gateway_hostname(name)) {
n_addresses = local_gateways(NULL, 0, AF_UNSPEC, &addresses);
- if (n_addresses <= 0) {
- *h_errnop = HOST_NOT_FOUND;
- return NSS_STATUS_NOTFOUND;
- }
+ if (n_addresses <= 0)
+ goto not_found;
canonical = "_gateway";
@@ -81,10 +79,8 @@ enum nss_status _nss_myhostname_gethostbyname4_r(
}
/* We respond to our local host name, our hostname suffixed with a single dot. */
- if (!streq(name, hn) && !streq_ptr(startswith(name, hn), ".")) {
- *h_errnop = HOST_NOT_FOUND;
- return NSS_STATUS_NOTFOUND;
- }
+ if (!streq(name, hn) && !streq_ptr(startswith(name, hn), "."))
+ goto not_found;
n_addresses = local_addresses(NULL, 0, AF_UNSPEC, &addresses);
if (n_addresses < 0)
@@ -164,6 +160,10 @@ enum nss_status _nss_myhostname_gethostbyname4_r(
h_errno = 0;
return NSS_STATUS_SUCCESS;
+
+not_found:
+ *h_errnop = HOST_NOT_FOUND;
+ return NSS_STATUS_NOTFOUND;
}
static enum nss_status fill_in_hostent(
@@ -339,10 +339,8 @@ enum nss_status _nss_myhostname_gethostbyname3_r(
} else if (is_gateway_hostname(name)) {
n_addresses = local_gateways(NULL, 0, af, &addresses);
- if (n_addresses <= 0) {
- *h_errnop = HOST_NOT_FOUND;
- return NSS_STATUS_NOTFOUND;
- }
+ if (n_addresses <= 0)
+ goto not_found;
canonical = "_gateway";
@@ -355,10 +353,8 @@ enum nss_status _nss_myhostname_gethostbyname3_r(
return NSS_STATUS_TRYAGAIN;
}
- if (!streq(name, hn) && !streq_ptr(startswith(name, hn), ".")) {
- *h_errnop = HOST_NOT_FOUND;
- return NSS_STATUS_NOTFOUND;
- }
+ if (!streq(name, hn) && !streq_ptr(startswith(name, hn), "."))
+ goto not_found;
n_addresses = local_addresses(NULL, 0, af, &addresses);
if (n_addresses < 0)
@@ -381,6 +377,10 @@ enum nss_status _nss_myhostname_gethostbyname3_r(
errnop, h_errnop,
ttlp,
canonp);
+
+not_found:
+ *h_errnop = HOST_NOT_FOUND;
+ return NSS_STATUS_NOTFOUND;
}
enum nss_status _nss_myhostname_gethostbyaddr2_r(