diff options
-rw-r--r-- | src/libsystemd/sd-bus/bus-control.c | 6 | ||||
-rw-r--r-- | src/libsystemd/sd-bus/bus-control.h | 7 | ||||
-rw-r--r-- | src/libsystemd/sd-bus/bus-internal.h | 6 | ||||
-rw-r--r-- | src/libsystemd/sd-bus/bus-slot.c | 2 | ||||
-rw-r--r-- | src/libsystemd/sd-bus/sd-bus.c | 9 | ||||
-rw-r--r-- | src/resolve/resolved-dns-query.c | 11 | ||||
-rw-r--r-- | src/resolve/resolved-dns-synthesize.c | 84 |
7 files changed, 82 insertions, 43 deletions
diff --git a/src/libsystemd/sd-bus/bus-control.c b/src/libsystemd/sd-bus/bus-control.c index 1a87d3a0ee..3c770a6e2e 100644 --- a/src/libsystemd/sd-bus/bus-control.c +++ b/src/libsystemd/sd-bus/bus-control.c @@ -650,8 +650,7 @@ int bus_add_match_internal( sd_bus *bus, const char *match, struct bus_match_component *components, - unsigned n_components, - uint64_t cookie) { + unsigned n_components) { assert(bus); @@ -686,8 +685,7 @@ static int bus_remove_match_internal_dbus1( int bus_remove_match_internal( sd_bus *bus, - const char *match, - uint64_t cookie) { + const char *match) { assert(bus); diff --git a/src/libsystemd/sd-bus/bus-control.h b/src/libsystemd/sd-bus/bus-control.h index 91efc68d57..01c71874db 100644 --- a/src/libsystemd/sd-bus/bus-control.h +++ b/src/libsystemd/sd-bus/bus-control.h @@ -23,8 +23,5 @@ #include "bus-match.h" -int bus_add_match_internal(sd_bus *bus, const char *match, struct bus_match_component *components, unsigned n_components, uint64_t cookie); -int bus_remove_match_internal(sd_bus *bus, const char *match, uint64_t cookie); - -int bus_add_match_internal_kernel(sd_bus *bus, struct bus_match_component *components, unsigned n_components, uint64_t cookie); -int bus_remove_match_internal_kernel(sd_bus *bus, uint64_t cookie); +int bus_add_match_internal(sd_bus *bus, const char *match, struct bus_match_component *components, unsigned n_components); +int bus_remove_match_internal(sd_bus *bus, const char *match); diff --git a/src/libsystemd/sd-bus/bus-internal.h b/src/libsystemd/sd-bus/bus-internal.h index 9a3bc9dd98..3af383e18b 100644 --- a/src/libsystemd/sd-bus/bus-internal.h +++ b/src/libsystemd/sd-bus/bus-internal.h @@ -53,7 +53,6 @@ struct filter_callback { struct match_callback { sd_bus_message_handler_t callback; - uint64_t cookie; unsigned last_iteration; char *match_string; @@ -287,8 +286,6 @@ struct sd_bus { uint64_t hello_flags; uint64_t attach_flags; - uint64_t match_cookie; - sd_event_source *input_io_event_source; sd_event_source *output_io_event_source; sd_event_source *time_event_source; @@ -308,9 +305,6 @@ struct sd_bus { char *description; - size_t bloom_size; - unsigned bloom_n_hash; - sd_bus_track *track_queue; LIST_HEAD(sd_bus_slot, slots); diff --git a/src/libsystemd/sd-bus/bus-slot.c b/src/libsystemd/sd-bus/bus-slot.c index 33590c31ac..725265b331 100644 --- a/src/libsystemd/sd-bus/bus-slot.c +++ b/src/libsystemd/sd-bus/bus-slot.c @@ -93,7 +93,7 @@ void bus_slot_disconnect(sd_bus_slot *slot) { case BUS_MATCH_CALLBACK: if (slot->match_added) - bus_remove_match_internal(slot->bus, slot->match_callback.match_string, slot->match_callback.cookie); + bus_remove_match_internal(slot->bus, slot->match_callback.match_string); slot->bus->match_callbacks_modified = true; bus_match_remove(&slot->bus->match_callbacks, &slot->match_callback); diff --git a/src/libsystemd/sd-bus/sd-bus.c b/src/libsystemd/sd-bus/sd-bus.c index 16d997c85e..621fabb015 100644 --- a/src/libsystemd/sd-bus/sd-bus.c +++ b/src/libsystemd/sd-bus/sd-bus.c @@ -56,7 +56,7 @@ #define log_debug_bus_message(m) \ do { \ sd_bus_message *_mm = (m); \ - log_debug("Got message type=%s sender=%s destination=%s object=%s interface=%s member=%s cookie=%" PRIu64 " reply_cookie=%" PRIu64 " error=%s", \ + log_debug("Got message type=%s sender=%s destination=%s object=%s interface=%s member=%s cookie=%" PRIu64 " reply_cookie=%" PRIu64 " error-name=%s error-message=%s", \ bus_message_type_to_string(_mm->header->type), \ strna(sd_bus_message_get_sender(_mm)), \ strna(sd_bus_message_get_destination(_mm)), \ @@ -65,6 +65,7 @@ strna(sd_bus_message_get_member(_mm)), \ BUS_MESSAGE_COOKIE(_mm), \ _mm->reply_cookie, \ + strna(_mm->error.name), \ strna(_mm->error.message)); \ } while (false) @@ -1465,7 +1466,7 @@ static int bus_write_message(sd_bus *bus, sd_bus_message *m, bool hint_sync_call return r; if (*idx >= BUS_MESSAGE_SIZE(m)) - log_debug("Sent message type=%s sender=%s destination=%s object=%s interface=%s member=%s cookie=%" PRIu64 " reply_cookie=%" PRIu64 " error=%s", + log_debug("Sent message type=%s sender=%s destination=%s object=%s interface=%s member=%s cookie=%" PRIu64 " reply_cookie=%" PRIu64 " error-name=%s error-message=%s", bus_message_type_to_string(m->header->type), strna(sd_bus_message_get_sender(m)), strna(sd_bus_message_get_destination(m)), @@ -1474,6 +1475,7 @@ static int bus_write_message(sd_bus *bus, sd_bus_message *m, bool hint_sync_call strna(sd_bus_message_get_member(m)), BUS_MESSAGE_COOKIE(m), m->reply_cookie, + strna(m->error.name), strna(m->error.message)); return r; @@ -2856,7 +2858,6 @@ _public_ int sd_bus_add_match( } s->match_callback.callback = callback; - s->match_callback.cookie = ++bus->match_cookie; if (bus->bus_client) { enum bus_match_scope scope; @@ -2876,7 +2877,7 @@ _public_ int sd_bus_add_match( goto finish; } - r = bus_add_match_internal(bus, s->match_callback.match_string, components, n_components, s->match_callback.cookie); + r = bus_add_match_internal(bus, s->match_callback.match_string, components, n_components); if (r < 0) goto finish; diff --git a/src/resolve/resolved-dns-query.c b/src/resolve/resolved-dns-query.c index 2b091e6c45..c2b29bc452 100644 --- a/src/resolve/resolved-dns-query.c +++ b/src/resolve/resolved-dns-query.c @@ -623,7 +623,18 @@ static int dns_query_synthesize_reply(DnsQuery *q, DnsTransactionState *state) { q->question_utf8, q->ifindex, &answer); + if (r == -ENXIO) { + /* If we get ENXIO this tells us to generate NXDOMAIN unconditionally. */ + dns_query_reset_answer(q); + q->answer_rcode = DNS_RCODE_NXDOMAIN; + q->answer_protocol = dns_synthesize_protocol(q->flags); + q->answer_family = dns_synthesize_family(q->flags); + q->answer_authenticated = true; + *state = DNS_TRANSACTION_RCODE_FAILURE; + + return 0; + } if (r <= 0) return r; diff --git a/src/resolve/resolved-dns-synthesize.c b/src/resolve/resolved-dns-synthesize.c index 25d2322453..ad38c6a561 100644 --- a/src/resolve/resolved-dns-synthesize.c +++ b/src/resolve/resolved-dns-synthesize.c @@ -186,6 +186,7 @@ static int answer_add_addresses_ptr( unsigned n_addresses, int af, const union in_addr_union *match) { + bool added = false; unsigned j; int r; @@ -215,9 +216,11 @@ static int answer_add_addresses_ptr( r = dns_answer_add(*answer, rr, addresses[j].ifindex, DNS_ANSWER_AUTHENTICATED); if (r < 0) return r; + + added = true; } - return 0; + return added; } static int synthesize_system_hostname_rr(Manager *m, const DnsResourceKey *key, int ifindex, DnsAnswer **answer) { @@ -265,6 +268,7 @@ static int synthesize_system_hostname_rr(Manager *m, const DnsResourceKey *key, static int synthesize_system_hostname_ptr(Manager *m, int af, const union in_addr_union *address, int ifindex, DnsAnswer **answer) { _cleanup_free_ struct local_address *addresses = NULL; + bool added = false; int n, r; assert(m); @@ -273,10 +277,13 @@ static int synthesize_system_hostname_ptr(Manager *m, int af, const union in_add if (af == AF_INET && address->in.s_addr == htobe32(0x7F000002)) { - /* Always map the IPv4 address 127.0.0.2 to the local - * hostname, in addition to "localhost": */ + /* Always map the IPv4 address 127.0.0.2 to the local hostname, in addition to "localhost": */ - r = dns_answer_reserve(answer, 3); + r = dns_answer_reserve(answer, 4); + if (r < 0) + return r; + + r = answer_add_ptr(answer, "2.0.0.127.in-addr.arpa", m->full_hostname, dns_synthesize_ifindex(ifindex), DNS_ANSWER_AUTHENTICATED); if (r < 0) return r; @@ -292,23 +299,37 @@ static int synthesize_system_hostname_ptr(Manager *m, int af, const union in_add if (r < 0) return r; - return 0; + return 1; } n = local_addresses(m->rtnl, ifindex, af, &addresses); - if (n < 0) + if (n <= 0) return n; + r = answer_add_addresses_ptr(answer, m->full_hostname, addresses, n, af, address); + if (r < 0) + return r; + if (r > 0) + added = true; + r = answer_add_addresses_ptr(answer, m->llmnr_hostname, addresses, n, af, address); if (r < 0) return r; + if (r > 0) + added = true; + + r = answer_add_addresses_ptr(answer, m->mdns_hostname, addresses, n, af, address); + if (r < 0) + return r; + if (r > 0) + added = true; - return answer_add_addresses_ptr(answer, m->mdns_hostname, addresses, n, af, address); + return added; } static int synthesize_gateway_rr(Manager *m, const DnsResourceKey *key, int ifindex, DnsAnswer **answer) { _cleanup_free_ struct local_address *addresses = NULL; - int n = 0, af; + int n = 0, af, r; assert(m); assert(key); @@ -317,11 +338,15 @@ static int synthesize_gateway_rr(Manager *m, const DnsResourceKey *key, int ifin af = dns_type_to_af(key->type); if (af >= 0) { n = local_gateways(m->rtnl, ifindex, af, &addresses); - if (n < 0) - return n; + if (n <= 0) + return n; /* < 0 means: error; == 0 means we have no gateway */ } - return answer_add_addresses_rr(answer, dns_resource_key_name(key), addresses, n); + r = answer_add_addresses_rr(answer, dns_resource_key_name(key), addresses, n); + if (r < 0) + return r; + + return 1; /* > 0 means: we have some gateway */ } static int synthesize_gateway_ptr(Manager *m, int af, const union in_addr_union *address, int ifindex, DnsAnswer **answer) { @@ -333,7 +358,7 @@ static int synthesize_gateway_ptr(Manager *m, int af, const union in_addr_union assert(answer); n = local_gateways(m->rtnl, ifindex, af, &addresses); - if (n < 0) + if (n <= 0) return n; return answer_add_addresses_ptr(answer, "_gateway", addresses, n, af, address); @@ -347,7 +372,7 @@ int dns_synthesize_answer( _cleanup_(dns_answer_unrefp) DnsAnswer *answer = NULL; DnsResourceKey *key; - bool found = false; + bool found = false, nxdomain = false; int r; assert(m); @@ -381,6 +406,10 @@ int dns_synthesize_answer( r = synthesize_gateway_rr(m, key, ifindex, &answer); if (r < 0) return log_error_errno(r, "Failed to synthesize gateway RRs: %m"); + if (r == 0) { /* if we have no gateway return NXDOMAIN */ + nxdomain = true; + continue; + } } else if ((dns_name_endswith(name, "127.in-addr.arpa") > 0 && dns_name_equal(name, "2.0.0.127.in-addr.arpa") == 0) || dns_name_equal(name, "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa") > 0) { @@ -390,26 +419,35 @@ int dns_synthesize_answer( return log_error_errno(r, "Failed to synthesize localhost PTR RRs: %m"); } else if (dns_name_address(name, &af, &address) > 0) { + int v, w; - r = synthesize_system_hostname_ptr(m, af, &address, ifindex, &answer); - if (r < 0) + v = synthesize_system_hostname_ptr(m, af, &address, ifindex, &answer); + if (v < 0) return log_error_errno(r, "Failed to synthesize system hostname PTR RR: %m"); - r = synthesize_gateway_ptr(m, af, &address, ifindex, &answer); - if (r < 0) + w = synthesize_gateway_ptr(m, af, &address, ifindex, &answer); + if (w < 0) return log_error_errno(r, "Failed to synthesize gateway hostname PTR RR: %m"); + + if (v == 0 && w == 0) /* This IP address is neither a local one nor a gateway */ + continue; + } else continue; found = true; } - r = found; + if (found) { - if (ret) { - *ret = answer; - answer = NULL; - } + if (ret) { + *ret = answer; + answer = NULL; + } + + return 1; + } else if (nxdomain) + return -ENXIO; - return r; + return 0; } |