summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuca Boccassi <bluca@debian.org>2023-02-07 20:33:07 +0100
committerGitHub <noreply@github.com>2023-02-07 20:33:07 +0100
commit2a0e9089cc34379582b4d2a7cd48297dcec9a028 (patch)
tree146b9c5cc010c06fd918e24380d40e7965e5bda7
parentFix Positivo-vaio VJPW12F11X key toggle touchpad (diff)
parentresolve: adjust message for NXDOMAIN lookup result (diff)
downloadsystemd-2a0e9089cc34379582b4d2a7cd48297dcec9a028.tar.xz
systemd-2a0e9089cc34379582b4d2a7cd48297dcec9a028.zip
Merge pull request #26335 from keszybz/dns-not-found
resolve: adjust message for NXDOMAIN lookup result
-rw-r--r--src/libsystemd/sd-bus/bus-common-errors.c36
-rw-r--r--src/libsystemd/sd-bus/bus-common-errors.h19
-rw-r--r--src/resolve/resolvectl.c9
-rw-r--r--src/resolve/resolved-bus.c4
-rw-r--r--src/resolve/test-dnssec-complex.c32
5 files changed, 63 insertions, 37 deletions
diff --git a/src/libsystemd/sd-bus/bus-common-errors.c b/src/libsystemd/sd-bus/bus-common-errors.c
index cb22d62d2c..0eaedec87c 100644
--- a/src/libsystemd/sd-bus/bus-common-errors.c
+++ b/src/libsystemd/sd-bus/bus-common-errors.c
@@ -80,24 +80,24 @@ BUS_ERROR_MAP_ELF_REGISTER const sd_bus_error_map bus_common_errors[] = {
SD_BUS_ERROR_MAP(BUS_ERROR_NO_SUCH_DNSSD_SERVICE, ENOENT),
SD_BUS_ERROR_MAP(BUS_ERROR_DNSSD_SERVICE_EXISTS, EEXIST),
- SD_BUS_ERROR_MAP(_BUS_ERROR_DNS "FORMERR", EBADMSG),
- SD_BUS_ERROR_MAP(_BUS_ERROR_DNS "SERVFAIL", EHOSTDOWN),
- SD_BUS_ERROR_MAP(_BUS_ERROR_DNS "NXDOMAIN", ENXIO),
- SD_BUS_ERROR_MAP(_BUS_ERROR_DNS "NOTIMP", ENOSYS),
- SD_BUS_ERROR_MAP(_BUS_ERROR_DNS "REFUSED", EACCES),
- SD_BUS_ERROR_MAP(_BUS_ERROR_DNS "YXDOMAIN", EEXIST),
- SD_BUS_ERROR_MAP(_BUS_ERROR_DNS "YRRSET", EEXIST),
- SD_BUS_ERROR_MAP(_BUS_ERROR_DNS "NXRRSET", ENOENT),
- SD_BUS_ERROR_MAP(_BUS_ERROR_DNS "NOTAUTH", EACCES),
- SD_BUS_ERROR_MAP(_BUS_ERROR_DNS "NOTZONE", EREMOTE),
- SD_BUS_ERROR_MAP(_BUS_ERROR_DNS "BADVERS", EBADMSG),
- SD_BUS_ERROR_MAP(_BUS_ERROR_DNS "BADKEY", EKEYREJECTED),
- SD_BUS_ERROR_MAP(_BUS_ERROR_DNS "BADTIME", EBADMSG),
- SD_BUS_ERROR_MAP(_BUS_ERROR_DNS "BADMODE", EBADMSG),
- SD_BUS_ERROR_MAP(_BUS_ERROR_DNS "BADNAME", EBADMSG),
- SD_BUS_ERROR_MAP(_BUS_ERROR_DNS "BADALG", EBADMSG),
- SD_BUS_ERROR_MAP(_BUS_ERROR_DNS "BADTRUNC", EBADMSG),
- SD_BUS_ERROR_MAP(_BUS_ERROR_DNS "BADCOOKIE", EBADR),
+ SD_BUS_ERROR_MAP(BUS_ERROR_DNS_FORMERR, EBADMSG),
+ SD_BUS_ERROR_MAP(BUS_ERROR_DNS_SERVFAIL, EHOSTDOWN),
+ SD_BUS_ERROR_MAP(BUS_ERROR_DNS_NXDOMAIN, ENXIO),
+ SD_BUS_ERROR_MAP(BUS_ERROR_DNS_NOTIMP, ENOSYS),
+ SD_BUS_ERROR_MAP(BUS_ERROR_DNS_REFUSED, EACCES),
+ SD_BUS_ERROR_MAP(BUS_ERROR_DNS_YXDOMAIN, EEXIST),
+ SD_BUS_ERROR_MAP(BUS_ERROR_DNS_YRRSET, EEXIST),
+ SD_BUS_ERROR_MAP(BUS_ERROR_DNS_NXRRSET, ENOENT),
+ SD_BUS_ERROR_MAP(BUS_ERROR_DNS_NOTAUTH, EACCES),
+ SD_BUS_ERROR_MAP(BUS_ERROR_DNS_NOTZONE, EREMOTE),
+ SD_BUS_ERROR_MAP(BUS_ERROR_DNS_BADVERS, EBADMSG),
+ SD_BUS_ERROR_MAP(BUS_ERROR_DNS_BADKEY, EKEYREJECTED),
+ SD_BUS_ERROR_MAP(BUS_ERROR_DNS_BADTIME, EBADMSG),
+ SD_BUS_ERROR_MAP(BUS_ERROR_DNS_BADMODE, EBADMSG),
+ SD_BUS_ERROR_MAP(BUS_ERROR_DNS_BADNAME, EBADMSG),
+ SD_BUS_ERROR_MAP(BUS_ERROR_DNS_BADALG, EBADMSG),
+ SD_BUS_ERROR_MAP(BUS_ERROR_DNS_BADTRUNC, EBADMSG),
+ SD_BUS_ERROR_MAP(BUS_ERROR_DNS_BADCOOKIE, EBADR),
SD_BUS_ERROR_MAP(BUS_ERROR_NO_SUCH_TRANSFER, ENXIO),
SD_BUS_ERROR_MAP(BUS_ERROR_TRANSFER_IN_PROGRESS, EBUSY),
diff --git a/src/libsystemd/sd-bus/bus-common-errors.h b/src/libsystemd/sd-bus/bus-common-errors.h
index 40d6abc413..b6c2e93ea5 100644
--- a/src/libsystemd/sd-bus/bus-common-errors.h
+++ b/src/libsystemd/sd-bus/bus-common-errors.h
@@ -79,7 +79,26 @@
#define BUS_ERROR_STUB_LOOP "org.freedesktop.resolve1.StubLoop"
#define BUS_ERROR_NO_SUCH_DNSSD_SERVICE "org.freedesktop.resolve1.NoSuchDnssdService"
#define BUS_ERROR_DNSSD_SERVICE_EXISTS "org.freedesktop.resolve1.DnssdServiceExists"
+
#define _BUS_ERROR_DNS "org.freedesktop.resolve1.DnsError."
+#define BUS_ERROR_DNS_FORMERR _BUS_ERROR_DNS "FORMERR"
+#define BUS_ERROR_DNS_SERVFAIL _BUS_ERROR_DNS "SERVFAIL"
+#define BUS_ERROR_DNS_NXDOMAIN _BUS_ERROR_DNS "NXDOMAIN"
+#define BUS_ERROR_DNS_NOTIMP _BUS_ERROR_DNS "NOTIMP"
+#define BUS_ERROR_DNS_REFUSED _BUS_ERROR_DNS "REFUSED"
+#define BUS_ERROR_DNS_YXDOMAIN _BUS_ERROR_DNS "YXDOMAIN"
+#define BUS_ERROR_DNS_YRRSET _BUS_ERROR_DNS "YRRSET"
+#define BUS_ERROR_DNS_NXRRSET _BUS_ERROR_DNS "NXRRSET"
+#define BUS_ERROR_DNS_NOTAUTH _BUS_ERROR_DNS "NOTAUTH"
+#define BUS_ERROR_DNS_NOTZONE _BUS_ERROR_DNS "NOTZONE"
+#define BUS_ERROR_DNS_BADVERS _BUS_ERROR_DNS "BADVERS"
+#define BUS_ERROR_DNS_BADKEY _BUS_ERROR_DNS "BADKEY"
+#define BUS_ERROR_DNS_BADTIME _BUS_ERROR_DNS "BADTIME"
+#define BUS_ERROR_DNS_BADMODE _BUS_ERROR_DNS "BADMODE"
+#define BUS_ERROR_DNS_BADNAME _BUS_ERROR_DNS "BADNAME"
+#define BUS_ERROR_DNS_BADALG _BUS_ERROR_DNS "BADALG"
+#define BUS_ERROR_DNS_BADTRUNC _BUS_ERROR_DNS "BADTRUNC"
+#define BUS_ERROR_DNS_BADCOOKIE _BUS_ERROR_DNS "BADCOOKIE"
#define BUS_ERROR_NO_SUCH_TRANSFER "org.freedesktop.import1.NoSuchTransfer"
#define BUS_ERROR_TRANSFER_IN_PROGRESS "org.freedesktop.import1.TransferInProgress"
diff --git a/src/resolve/resolvectl.c b/src/resolve/resolvectl.c
index 505be23051..2638e985fb 100644
--- a/src/resolve/resolvectl.c
+++ b/src/resolve/resolvectl.c
@@ -232,6 +232,13 @@ static void print_ifindex_comment(int printed_so_far, int ifindex) {
ansi_grey(), ifname, ansi_normal());
}
+static int resolve_host_error(const char *name, int r, const sd_bus_error *error) {
+ if (sd_bus_error_has_name(error, BUS_ERROR_DNS_NXDOMAIN))
+ return log_error_errno(r, "%s: %s", name, bus_error_message(error, r));
+
+ return log_error_errno(r, "%s: resolve call failed: %s", name, bus_error_message(error, r));
+}
+
static int resolve_host(sd_bus *bus, const char *name) {
_cleanup_(sd_bus_message_unrefp) sd_bus_message *req = NULL, *reply = NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
@@ -257,7 +264,7 @@ static int resolve_host(sd_bus *bus, const char *name) {
r = sd_bus_call(bus, req, SD_RESOLVED_QUERY_TIMEOUT_USEC, &error, &reply);
if (r < 0)
- return log_error_errno(r, "%s: resolve call failed: %s", name, bus_error_message(&error, r));
+ return resolve_host_error(name, r, &error);
ts = now(CLOCK_MONOTONIC) - ts;
diff --git a/src/resolve/resolved-bus.c b/src/resolve/resolved-bus.c
index c818e1d52f..1c1e5bc3aa 100644
--- a/src/resolve/resolved-bus.c
+++ b/src/resolve/resolved-bus.c
@@ -159,7 +159,7 @@ static int reply_query_state(DnsQuery *q) {
case DNS_TRANSACTION_NOT_FOUND:
/* We return this as NXDOMAIN. This is only generated when a host doesn't implement LLMNR/TCP, and we
* thus quickly know that we cannot resolve an in-addr.arpa or ip6.arpa address. */
- return reply_method_errorf(q, _BUS_ERROR_DNS "NXDOMAIN", "'%s' not found", dns_query_string(q));
+ return reply_method_errorf(q, BUS_ERROR_DNS_NXDOMAIN, "'%s' not found", dns_query_string(q));
case DNS_TRANSACTION_NO_SOURCE:
return reply_method_errorf(q, BUS_ERROR_NO_SOURCE, "All suitable resolution sources turned off");
@@ -176,7 +176,7 @@ static int reply_query_state(DnsQuery *q) {
return 0;
if (q->answer_rcode == DNS_RCODE_NXDOMAIN)
- sd_bus_error_setf(&error, _BUS_ERROR_DNS "NXDOMAIN", "'%s' not found", dns_query_string(q));
+ sd_bus_error_setf(&error, BUS_ERROR_DNS_NXDOMAIN, "Name '%s' not found", dns_query_string(q));
else {
const char *rc, *n;
diff --git a/src/resolve/test-dnssec-complex.c b/src/resolve/test-dnssec-complex.c
index e21eb86756..d8aeb7061f 100644
--- a/src/resolve/test-dnssec-complex.c
+++ b/src/resolve/test-dnssec-complex.c
@@ -146,9 +146,9 @@ int main(int argc, char* argv[]) {
test_hostname_lookup(bus, "www.dnssec-bogus.sg", AF_INET, BUS_ERROR_DNSSEC_FAILED);
/* NXDOMAIN in NSEC domain */
- test_rr_lookup(bus, "hhh.nasa.gov", DNS_TYPE_A, _BUS_ERROR_DNS "NXDOMAIN");
- test_hostname_lookup(bus, "hhh.nasa.gov", AF_UNSPEC, _BUS_ERROR_DNS "NXDOMAIN");
- test_rr_lookup(bus, "_pgpkey-https._tcp.hkps.pool.sks-keyservers.net", DNS_TYPE_SRV, _BUS_ERROR_DNS "NXDOMAIN");
+ test_rr_lookup(bus, "hhh.nasa.gov", DNS_TYPE_A, BUS_ERROR_DNS_NXDOMAIN);
+ test_hostname_lookup(bus, "hhh.nasa.gov", AF_UNSPEC, BUS_ERROR_DNS_NXDOMAIN);
+ test_rr_lookup(bus, "_pgpkey-https._tcp.hkps.pool.sks-keyservers.net", DNS_TYPE_SRV, BUS_ERROR_DNS_NXDOMAIN);
/* wildcard, NSEC zone */
test_rr_lookup(bus, ".wilda.nsec.0skar.cz", DNS_TYPE_A, NULL);
@@ -187,16 +187,16 @@ int main(int argc, char* argv[]) {
test_hostname_lookup(bus, "herndon.nasa.gov", AF_INET6, BUS_ERROR_NO_SUCH_RR);
/* NXDOMAIN in NSEC root zone: */
- test_rr_lookup(bus, "jasdhjas.kjkfgjhfjg", DNS_TYPE_A, _BUS_ERROR_DNS "NXDOMAIN");
- test_hostname_lookup(bus, "jasdhjas.kjkfgjhfjg", AF_UNSPEC, _BUS_ERROR_DNS "NXDOMAIN");
- test_hostname_lookup(bus, "jasdhjas.kjkfgjhfjg", AF_INET, _BUS_ERROR_DNS "NXDOMAIN");
- test_hostname_lookup(bus, "jasdhjas.kjkfgjhfjg", AF_INET6, _BUS_ERROR_DNS "NXDOMAIN");
+ test_rr_lookup(bus, "jasdhjas.kjkfgjhfjg", DNS_TYPE_A, BUS_ERROR_DNS_NXDOMAIN);
+ test_hostname_lookup(bus, "jasdhjas.kjkfgjhfjg", AF_UNSPEC, BUS_ERROR_DNS_NXDOMAIN);
+ test_hostname_lookup(bus, "jasdhjas.kjkfgjhfjg", AF_INET, BUS_ERROR_DNS_NXDOMAIN);
+ test_hostname_lookup(bus, "jasdhjas.kjkfgjhfjg", AF_INET6, BUS_ERROR_DNS_NXDOMAIN);
/* NXDOMAIN in NSEC3 .com zone: */
- test_rr_lookup(bus, "kjkfgjhfjgsdfdsfd.com", DNS_TYPE_A, _BUS_ERROR_DNS "NXDOMAIN");
- test_hostname_lookup(bus, "kjkfgjhfjgsdfdsfd.com", AF_INET, _BUS_ERROR_DNS "NXDOMAIN");
- test_hostname_lookup(bus, "kjkfgjhfjgsdfdsfd.com", AF_INET6, _BUS_ERROR_DNS "NXDOMAIN");
- test_hostname_lookup(bus, "kjkfgjhfjgsdfdsfd.com", AF_UNSPEC, _BUS_ERROR_DNS "NXDOMAIN");
+ test_rr_lookup(bus, "kjkfgjhfjgsdfdsfd.com", DNS_TYPE_A, BUS_ERROR_DNS_NXDOMAIN);
+ test_hostname_lookup(bus, "kjkfgjhfjgsdfdsfd.com", AF_INET, BUS_ERROR_DNS_NXDOMAIN);
+ test_hostname_lookup(bus, "kjkfgjhfjgsdfdsfd.com", AF_INET6, BUS_ERROR_DNS_NXDOMAIN);
+ test_hostname_lookup(bus, "kjkfgjhfjgsdfdsfd.com", AF_UNSPEC, BUS_ERROR_DNS_NXDOMAIN);
/* Unsigned A */
test_rr_lookup(bus, "poettering.de", DNS_TYPE_A, NULL);
@@ -213,11 +213,11 @@ int main(int argc, char* argv[]) {
#endif
/* DNAME, pointing to NXDOMAIN */
- test_rr_lookup(bus, ".ireallyhpoethisdoesnexist.xn--kprw13d.", DNS_TYPE_A, _BUS_ERROR_DNS "NXDOMAIN");
- test_rr_lookup(bus, ".ireallyhpoethisdoesnexist.xn--kprw13d.", DNS_TYPE_RP, _BUS_ERROR_DNS "NXDOMAIN");
- test_hostname_lookup(bus, ".ireallyhpoethisdoesntexist.xn--kprw13d.", AF_UNSPEC, _BUS_ERROR_DNS "NXDOMAIN");
- test_hostname_lookup(bus, ".ireallyhpoethisdoesntexist.xn--kprw13d.", AF_INET, _BUS_ERROR_DNS "NXDOMAIN");
- test_hostname_lookup(bus, ".ireallyhpoethisdoesntexist.xn--kprw13d.", AF_INET6, _BUS_ERROR_DNS "NXDOMAIN");
+ test_rr_lookup(bus, ".ireallyhpoethisdoesnexist.xn--kprw13d.", DNS_TYPE_A, BUS_ERROR_DNS_NXDOMAIN);
+ test_rr_lookup(bus, ".ireallyhpoethisdoesnexist.xn--kprw13d.", DNS_TYPE_RP, BUS_ERROR_DNS_NXDOMAIN);
+ test_hostname_lookup(bus, ".ireallyhpoethisdoesntexist.xn--kprw13d.", AF_UNSPEC, BUS_ERROR_DNS_NXDOMAIN);
+ test_hostname_lookup(bus, ".ireallyhpoethisdoesntexist.xn--kprw13d.", AF_INET, BUS_ERROR_DNS_NXDOMAIN);
+ test_hostname_lookup(bus, ".ireallyhpoethisdoesntexist.xn--kprw13d.", AF_INET6, BUS_ERROR_DNS_NXDOMAIN);
return 0;
}