chiark / gitweb /
resolve: add distinct bus error code for hosts that exist but lack A or AAAA records
authorLennart Poettering <lennart@poettering.net>
Wed, 16 Jul 2014 01:28:18 +0000 (03:28 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 16 Jul 2014 01:28:18 +0000 (03:28 +0200)
src/resolve/resolved-bus.c
src/resolve/resolved-dns-query.c
src/shared/bus-errors.h

index 4a011ef..50eb012 100644 (file)
@@ -138,8 +138,10 @@ static void bus_method_resolve_hostname_complete(DnsQuery *q) {
                         added ++;
                 }
 
-                if (added <= 0)
-                        goto parse_fail;
+                if (added <= 0) {
+                        r = sd_bus_reply_method_errorf(q->request, BUS_ERROR_NO_SUCH_RR, "Hostname %s does not have RR of this type", q->request_hostname);
+                        break;
+                }
 
                 r = sd_bus_message_close_container(reply);
                 if (r < 0)
@@ -315,8 +317,10 @@ static void bus_method_resolve_address_complete(DnsQuery *q) {
                         added ++;
                 }
 
-                if (added <= 0)
-                        goto parse_fail;
+                if (added <= 0) {
+                        r = sd_bus_reply_method_errorf(q->request, BUS_ERROR_NO_SUCH_RR, "Address %s does not have RR of this type", ip);
+                        break;
+                }
 
                 r = sd_bus_message_close_container(reply);
                 if (r < 0)
index a988052..dd81215 100644 (file)
@@ -107,12 +107,9 @@ int dns_query_transaction_reply(DnsQueryTransaction *t, DnsPacket *p) {
 
         t->packet = dns_packet_ref(p);
 
-        if (DNS_PACKET_RCODE(p) == DNS_RCODE_SUCCESS) {
-                if( be16toh(DNS_PACKET_HEADER(p)->ancount) > 0)
-                        dns_query_transaction_set_state(t, DNS_QUERY_SUCCESS);
-                else
-                        dns_query_transaction_set_state(t, DNS_QUERY_INVALID_REPLY);
-        } else
+        if (DNS_PACKET_RCODE(p) == DNS_RCODE_SUCCESS)
+                dns_query_transaction_set_state(t, DNS_QUERY_SUCCESS);
+        else
                 dns_query_transaction_set_state(t, DNS_QUERY_FAILURE);
 
         return 0;
index 388b42b..08a7acc 100644 (file)
@@ -62,4 +62,5 @@
 
 #define BUS_ERROR_NO_NAME_SERVERS "org.freedesktop.resolve1.NoNameServers"
 #define BUS_ERROR_INVALID_REPLY "org.freedesktop.resolve1.InvalidReply"
+#define BUS_ERROR_NO_SUCH_RR "org.freedesktop.resolve1.NoSuchRR"
 #define _BUS_ERROR_DNS "org.freedesktop.resolve1.DnsError."