summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2023-02-07 14:38:28 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2023-02-07 14:49:58 +0100
commit03e80572a71c65833ccca7b9ef06c5d86322e2ed (patch)
tree4fe51ac01789790e8a9cbefa968d3cfb21d922c8
parentMerge pull request #26324 from yuwata/argv-util-update-short-name (diff)
downloadsystemd-03e80572a71c65833ccca7b9ef06c5d86322e2ed.tar.xz
systemd-03e80572a71c65833ccca7b9ef06c5d86322e2ed.zip
resolve: define normal macros for BUS_ERROR_DNS error codes
This result is identical after cpp is done, so we don't save anything by not having the usual macros. And with the usual macros it's easier to grep and code-crossreferencing works better.
Diffstat (limited to '')
-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/resolved-bus.c4
-rw-r--r--src/resolve/test-dnssec-complex.c32
4 files changed, 55 insertions, 36 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/resolved-bus.c b/src/resolve/resolved-bus.c
index c818e1d52f..3bbf612078 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, "'%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;
}