]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
resolved: include Varlink error on inconsistent DNS-SD services in introspection...
authorLennart Poettering <lennart@poettering.net>
Fri, 23 Aug 2024 08:43:40 +0000 (10:43 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 3 Sep 2024 01:42:14 +0000 (10:42 +0900)
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

src/libsystemd/sd-bus/bus-common-errors.c
src/libsystemd/sd-bus/bus-common-errors.h
src/resolve/resolved-bus.c
src/resolve/resolved-varlink.c
src/shared/varlink-io.systemd.Resolve.c

index db1285e7f0fed6671920b423c60daa032cbadb66..f765238ba7b1a4e65c366ecd45bedf8e0f68310b 100644 (file)
@@ -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),
index 622cf4933dbe81c330da8e9232d762dadf653ea4..c460cd54e2642422421db2d833d9195e9f3ec6d7 100644 (file)
@@ -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"
index 847bb6bc6ec43cafe12d8ebb121058ab95d38077..58701bc656f6bf1d2017c0d93df5802263c36cf6 100644 (file)
@@ -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;
         }
 
index fe0482dffb7648ed744094797bbb252a0edac028..6a8e80128c308aa025fe313647b34fd414b29b30 100644 (file)
@@ -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;
         }
 
index 0515b1ae3d947af164701460de4c2e895aa2178d..484a0ccdc732df48885345418a74475b18886846 100644 (file)
@@ -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);