From: Lennart Poettering Date: Fri, 23 Aug 2024 08:43:40 +0000 (+0200) Subject: resolved: include Varlink error on inconsistent DNS-SD services in introspection... X-Git-Tag: v257-rc1~572 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7fd18c93d861233fbe512844141e0392526d9a36;p=thirdparty%2Fsystemd.git resolved: include Varlink error on inconsistent DNS-SD services in introspection data Let's also rename the error slightly, since what happens here is that a a valid service RR name is CNAME'd onto an invalid one. That's an inconsistency on the server side, which we really should report as such. Follow-up for: b48ab08732a76b7337628e1e716f11c687000903 --- diff --git a/src/libsystemd/sd-bus/bus-common-errors.c b/src/libsystemd/sd-bus/bus-common-errors.c index db1285e7f0f..f765238ba7b 100644 --- a/src/libsystemd/sd-bus/bus-common-errors.c +++ b/src/libsystemd/sd-bus/bus-common-errors.c @@ -74,6 +74,7 @@ BUS_ERROR_MAP_ELF_REGISTER const sd_bus_error_map bus_common_errors[] = { SD_BUS_ERROR_MAP(BUS_ERROR_CNAME_LOOP, EDEADLK), SD_BUS_ERROR_MAP(BUS_ERROR_ABORTED, ECANCELED), SD_BUS_ERROR_MAP(BUS_ERROR_NO_SUCH_SERVICE, EUNATCH), + SD_BUS_ERROR_MAP(BUS_ERROR_INCONSISTENT_SERVICE_RECORDS, EUNATCH), SD_BUS_ERROR_MAP(BUS_ERROR_DNSSEC_FAILED, EHOSTUNREACH), SD_BUS_ERROR_MAP(BUS_ERROR_NO_TRUST_ANCHOR, EHOSTUNREACH), SD_BUS_ERROR_MAP(BUS_ERROR_RR_TYPE_UNSUPPORTED, EOPNOTSUPP), diff --git a/src/libsystemd/sd-bus/bus-common-errors.h b/src/libsystemd/sd-bus/bus-common-errors.h index 622cf4933db..c460cd54e26 100644 --- a/src/libsystemd/sd-bus/bus-common-errors.h +++ b/src/libsystemd/sd-bus/bus-common-errors.h @@ -74,6 +74,7 @@ #define BUS_ERROR_CNAME_LOOP "org.freedesktop.resolve1.CNameLoop" #define BUS_ERROR_ABORTED "org.freedesktop.resolve1.Aborted" #define BUS_ERROR_NO_SUCH_SERVICE "org.freedesktop.resolve1.NoSuchService" +#define BUS_ERROR_INCONSISTENT_SERVICE_RECORDS "org.freedesktop.resolve1.InconsistentServiceRecords" #define BUS_ERROR_DNSSEC_FAILED "org.freedesktop.resolve1.DnssecFailed" #define BUS_ERROR_NO_TRUST_ANCHOR "org.freedesktop.resolve1.NoTrustAnchor" #define BUS_ERROR_RR_TYPE_UNSUPPORTED "org.freedesktop.resolve1.ResourceRecordTypeUnsupported" diff --git a/src/resolve/resolved-bus.c b/src/resolve/resolved-bus.c index 847bb6bc6ec..58701bc656f 100644 --- a/src/resolve/resolved-bus.c +++ b/src/resolve/resolved-bus.c @@ -1149,7 +1149,7 @@ static void resolve_service_all_complete(DnsQuery *query) { goto finish; if (isempty(type)) { - r = reply_method_errorf(q, BUS_ERROR_NO_SUCH_SERVICE, "'%s' does not provide valid service", dns_query_string(q)); + r = reply_method_errorf(q, BUS_ERROR_INCONSISTENT_SERVICE_RECORDS, "'%s' does not provide a consistent set of service resource records", dns_query_string(q)); goto finish; } diff --git a/src/resolve/resolved-varlink.c b/src/resolve/resolved-varlink.c index fe0482dffb7..6a8e80128c3 100644 --- a/src/resolve/resolved-varlink.c +++ b/src/resolve/resolved-varlink.c @@ -830,7 +830,7 @@ static void resolve_service_all_complete(DnsQuery *query) { goto finish; if (isempty(type)) { - r = sd_varlink_error(q->varlink_request, "io.systemd.Resolve.ServiceNotProvided", NULL); + r = sd_varlink_error(q->varlink_request, "io.systemd.Resolve.InconsistentServiceRecords", NULL); goto finish; } diff --git a/src/shared/varlink-io.systemd.Resolve.c b/src/shared/varlink-io.systemd.Resolve.c index 0515b1ae3d9..484a0ccdc73 100644 --- a/src/shared/varlink-io.systemd.Resolve.c +++ b/src/shared/varlink-io.systemd.Resolve.c @@ -112,6 +112,7 @@ static SD_VARLINK_DEFINE_STRUCT_TYPE( static SD_VARLINK_DEFINE_STRUCT_TYPE( ResolvedCanonical, + SD_VARLINK_FIELD_COMMENT("The DNS-SD name of the service. For simple SRV services this field is absent or null."), SD_VARLINK_DEFINE_FIELD(name, SD_VARLINK_STRING, SD_VARLINK_NULLABLE), SD_VARLINK_DEFINE_FIELD(type, SD_VARLINK_STRING, 0), SD_VARLINK_DEFINE_FIELD(domain, SD_VARLINK_STRING, 0)); @@ -171,17 +172,20 @@ static SD_VARLINK_DEFINE_ERROR(BadAddressSize); static SD_VARLINK_DEFINE_ERROR(ResourceRecordTypeInvalidForQuery); static SD_VARLINK_DEFINE_ERROR(ZoneTransfersNotPermitted); static SD_VARLINK_DEFINE_ERROR(ResourceRecordTypeObsolete); +static SD_VARLINK_DEFINE_ERROR(InconsistentServiceRecords); SD_VARLINK_DEFINE_INTERFACE( io_systemd_Resolve, "io.systemd.Resolve", &vl_method_ResolveHostname, &vl_method_ResolveAddress, + SD_VARLINK_SYMBOL_COMMENT("Resolves a named DNS-SD or unnamed simple SRV service."), &vl_method_ResolveService, &vl_method_ResolveRecord, &vl_type_ResolvedAddress, &vl_type_ResolvedName, &vl_type_ResolvedService, + SD_VARLINK_SYMBOL_COMMENT("Encodes the canonical name, type and domain of a DNS-SD or simple SRV service. Note that due to CNAME redirections and similar, a named DNS-SD service might resolve to a canonical service that is an unnamed simple SRV service. Or in other words: resolving a named service might return an unnamed canonical service."), &vl_type_ResolvedCanonical, &vl_type_ResourceKey, &vl_type_ResourceRecord, @@ -203,4 +207,6 @@ SD_VARLINK_DEFINE_INTERFACE( &vl_error_BadAddressSize, &vl_error_ResourceRecordTypeInvalidForQuery, &vl_error_ZoneTransfersNotPermitted, - &vl_error_ResourceRecordTypeObsolete); + &vl_error_ResourceRecordTypeObsolete, + SD_VARLINK_SYMBOL_COMMENT("The DNS resource records of the specified service are not consistent (e.g. lacks a DNS-SD service type when resolved)."), + &vl_error_InconsistentServiceRecords);