]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/resolve/resolved-bus.c
Merge pull request #15504 from poettering/cmsg-find-pure
[thirdparty/systemd.git] / src / resolve / resolved-bus.c
index ff6acb2eac1fac0b14d54dde7b35f7a8fad07797..a06e9bcf7d26de40ca7d5e817cf42bfc8ee5d6c7 100644 (file)
@@ -2,6 +2,8 @@
 
 #include "alloc-util.h"
 #include "bus-common-errors.h"
+#include "bus-log-control-api.h"
+#include "bus-polkit.h"
 #include "bus-util.h"
 #include "dns-domain.h"
 #include "memory-util.h"
@@ -15,6 +17,7 @@
 #include "socket-netlink.h"
 #include "stdio-util.h"
 #include "strv.h"
+#include "syslog-util.h"
 #include "user-util.h"
 #include "utf8.h"
 
@@ -1113,7 +1116,7 @@ static void bus_method_resolve_service_complete(DnsQuery *q) {
 
         if (has_root_domain && found <= 0) {
                 /* If there's exactly one SRV RR and it uses
-                 * the root domain as host name, then the
+                 * the root domain as hostname, then the
                  * service is explicitly not offered on the
                  * domain. Report this as a recognizable
                  * error. See RFC 2782, Section "Usage
@@ -1852,26 +1855,163 @@ static const sd_bus_vtable resolve_vtable[] = {
         SD_BUS_PROPERTY("DNSSECNegativeTrustAnchors", "as", bus_property_get_ntas, 0, 0),
         SD_BUS_PROPERTY("DNSStubListener", "s", bus_property_get_dns_stub_listener_mode, offsetof(Manager, dns_stub_listener_mode), 0),
 
-        SD_BUS_METHOD("ResolveHostname", "isit", "a(iiay)st", bus_method_resolve_hostname, SD_BUS_VTABLE_UNPRIVILEGED),
-        SD_BUS_METHOD("ResolveAddress", "iiayt", "a(is)t", bus_method_resolve_address, SD_BUS_VTABLE_UNPRIVILEGED),
-        SD_BUS_METHOD("ResolveRecord", "isqqt", "a(iqqay)t", bus_method_resolve_record, SD_BUS_VTABLE_UNPRIVILEGED),
-        SD_BUS_METHOD("ResolveService", "isssit", "a(qqqsa(iiay)s)aayssst", bus_method_resolve_service, SD_BUS_VTABLE_UNPRIVILEGED),
-        SD_BUS_METHOD("ResetStatistics", NULL, NULL, bus_method_reset_statistics, SD_BUS_VTABLE_UNPRIVILEGED),
-        SD_BUS_METHOD("FlushCaches", NULL, NULL, bus_method_flush_caches, SD_BUS_VTABLE_UNPRIVILEGED),
-        SD_BUS_METHOD("ResetServerFeatures", NULL, NULL, bus_method_reset_server_features, SD_BUS_VTABLE_UNPRIVILEGED),
-        SD_BUS_METHOD("GetLink", "i", "o", bus_method_get_link, SD_BUS_VTABLE_UNPRIVILEGED),
-        SD_BUS_METHOD("SetLinkDNS", "ia(iay)", NULL, bus_method_set_link_dns_servers, SD_BUS_VTABLE_UNPRIVILEGED),
-        SD_BUS_METHOD("SetLinkDomains", "ia(sb)", NULL, bus_method_set_link_domains, SD_BUS_VTABLE_UNPRIVILEGED),
-        SD_BUS_METHOD("SetLinkDefaultRoute", "ib", NULL, bus_method_set_link_default_route, SD_BUS_VTABLE_UNPRIVILEGED),
-        SD_BUS_METHOD("SetLinkLLMNR", "is", NULL, bus_method_set_link_llmnr, SD_BUS_VTABLE_UNPRIVILEGED),
-        SD_BUS_METHOD("SetLinkMulticastDNS", "is", NULL, bus_method_set_link_mdns, SD_BUS_VTABLE_UNPRIVILEGED),
-        SD_BUS_METHOD("SetLinkDNSOverTLS", "is", NULL, bus_method_set_link_dns_over_tls, SD_BUS_VTABLE_UNPRIVILEGED),
-        SD_BUS_METHOD("SetLinkDNSSEC", "is", NULL, bus_method_set_link_dnssec, SD_BUS_VTABLE_UNPRIVILEGED),
-        SD_BUS_METHOD("SetLinkDNSSECNegativeTrustAnchors", "ias", NULL, bus_method_set_link_dnssec_negative_trust_anchors, SD_BUS_VTABLE_UNPRIVILEGED),
-        SD_BUS_METHOD("RevertLink", "i", NULL, bus_method_revert_link, SD_BUS_VTABLE_UNPRIVILEGED),
-
-        SD_BUS_METHOD("RegisterService", "sssqqqaa{say}", "o", bus_method_register_service, SD_BUS_VTABLE_UNPRIVILEGED),
-        SD_BUS_METHOD("UnregisterService", "o", NULL, bus_method_unregister_service, SD_BUS_VTABLE_UNPRIVILEGED),
+        SD_BUS_METHOD_WITH_NAMES("ResolveHostname",
+                                 "isit",
+                                 SD_BUS_PARAM(ifindex)
+                                 SD_BUS_PARAM(name)
+                                 SD_BUS_PARAM(family)
+                                 SD_BUS_PARAM(flags),
+                                 "a(iiay)st",
+                                 SD_BUS_PARAM(addresses)
+                                 SD_BUS_PARAM(canonical)
+                                 SD_BUS_PARAM(flags),
+                                 bus_method_resolve_hostname,
+                                 SD_BUS_VTABLE_UNPRIVILEGED),
+        SD_BUS_METHOD_WITH_NAMES("ResolveAddress",
+                                 "iiayt",
+                                 SD_BUS_PARAM(ifindex)
+                                 SD_BUS_PARAM(family)
+                                 SD_BUS_PARAM(address)
+                                 SD_BUS_PARAM(flags),
+                                 "a(is)t",
+                                 SD_BUS_PARAM(names)
+                                 SD_BUS_PARAM(flags),
+                                 bus_method_resolve_address,
+                                 SD_BUS_VTABLE_UNPRIVILEGED),
+        SD_BUS_METHOD_WITH_NAMES("ResolveRecord",
+                                 "isqqt",
+                                 SD_BUS_PARAM(ifindex)
+                                 SD_BUS_PARAM(name)
+                                 SD_BUS_PARAM(class)
+                                 SD_BUS_PARAM(type)
+                                 SD_BUS_PARAM(flags),
+                                 "a(iqqay)t",
+                                 SD_BUS_PARAM(records)
+                                 SD_BUS_PARAM(flags),
+                                 bus_method_resolve_record,
+                                 SD_BUS_VTABLE_UNPRIVILEGED),
+        SD_BUS_METHOD_WITH_NAMES("ResolveService",
+                                 "isssit",
+                                 SD_BUS_PARAM(ifindex)
+                                 SD_BUS_PARAM(name)
+                                 SD_BUS_PARAM(type)
+                                 SD_BUS_PARAM(domain)
+                                 SD_BUS_PARAM(family)
+                                 SD_BUS_PARAM(flags),
+                                 "a(qqqsa(iiay)s)aayssst",
+                                 SD_BUS_PARAM(srv_data)
+                                 SD_BUS_PARAM(txt_data)
+                                 SD_BUS_PARAM(canonical_name)
+                                 SD_BUS_PARAM(canonical_type)
+                                 SD_BUS_PARAM(canonical_domain)
+                                 SD_BUS_PARAM(flags),
+                                 bus_method_resolve_service,
+                                 SD_BUS_VTABLE_UNPRIVILEGED),
+        SD_BUS_METHOD_WITH_NAMES("GetLink",
+                                 "i",
+                                 SD_BUS_PARAM(ifindex),
+                                 "o",
+                                 SD_BUS_PARAM(path),
+                                 bus_method_get_link,
+                                 SD_BUS_VTABLE_UNPRIVILEGED),
+        SD_BUS_METHOD_WITH_NAMES("SetLinkDNS",
+                                 "ia(iay)",
+                                 SD_BUS_PARAM(ifindex)
+                                 SD_BUS_PARAM(addresses),
+                                 NULL,,
+                                 bus_method_set_link_dns_servers,
+                                 SD_BUS_VTABLE_UNPRIVILEGED),
+        SD_BUS_METHOD_WITH_NAMES("SetLinkDomains",
+                                 "ia(sb)",
+                                 SD_BUS_PARAM(ifindex)
+                                 SD_BUS_PARAM(domains),
+                                 NULL,,
+                                 bus_method_set_link_domains,
+                                 SD_BUS_VTABLE_UNPRIVILEGED),
+        SD_BUS_METHOD_WITH_NAMES("SetLinkDefaultRoute",
+                                 "ib",
+                                 SD_BUS_PARAM(ifindex)
+                                 SD_BUS_PARAM(enable),
+                                 NULL,,
+                                 bus_method_set_link_default_route,
+                                 SD_BUS_VTABLE_UNPRIVILEGED),
+        SD_BUS_METHOD_WITH_NAMES("SetLinkLLMNR",
+                                 "is",
+                                 SD_BUS_PARAM(ifindex)
+                                 SD_BUS_PARAM(mode),
+                                 NULL,,
+                                 bus_method_set_link_llmnr,
+                                 SD_BUS_VTABLE_UNPRIVILEGED),
+        SD_BUS_METHOD_WITH_NAMES("SetLinkMulticastDNS",
+                                 "is",
+                                 SD_BUS_PARAM(ifindex)
+                                 SD_BUS_PARAM(mode),
+                                 NULL,,
+                                 bus_method_set_link_mdns,
+                                 SD_BUS_VTABLE_UNPRIVILEGED),
+        SD_BUS_METHOD_WITH_NAMES("SetLinkDNSOverTLS",
+                                 "is",
+                                 SD_BUS_PARAM(ifindex)
+                                 SD_BUS_PARAM(mode),
+                                 NULL,,
+                                 bus_method_set_link_dns_over_tls,
+                                 SD_BUS_VTABLE_UNPRIVILEGED),
+        SD_BUS_METHOD_WITH_NAMES("SetLinkDNSSEC",
+                                 "is",
+                                 SD_BUS_PARAM(ifindex)
+                                 SD_BUS_PARAM(mode),
+                                 NULL,,
+                                 bus_method_set_link_dnssec,
+                                 SD_BUS_VTABLE_UNPRIVILEGED),
+        SD_BUS_METHOD_WITH_NAMES("SetLinkDNSSECNegativeTrustAnchors",
+                                 "ias",
+                                 SD_BUS_PARAM(ifindex)
+                                 SD_BUS_PARAM(names),
+                                 NULL,,
+                                 bus_method_set_link_dnssec_negative_trust_anchors,
+                                 SD_BUS_VTABLE_UNPRIVILEGED),
+        SD_BUS_METHOD_WITH_NAMES("RevertLink",
+                                 "i",
+                                 SD_BUS_PARAM(ifindex),
+                                 NULL,,
+                                 bus_method_revert_link,
+                                 SD_BUS_VTABLE_UNPRIVILEGED),
+        SD_BUS_METHOD_WITH_NAMES("RegisterService",
+                                 "sssqqqaa{say}",
+                                 SD_BUS_PARAM(name)
+                                 SD_BUS_PARAM(name_template)
+                                 SD_BUS_PARAM(type)
+                                 SD_BUS_PARAM(service_port)
+                                 SD_BUS_PARAM(service_priority)
+                                 SD_BUS_PARAM(serwise_weight)
+                                 SD_BUS_PARAM(txt_datas),
+                                 "o",
+                                 SD_BUS_PARAM(service_path),
+                                 bus_method_register_service,
+                                 SD_BUS_VTABLE_UNPRIVILEGED),
+        SD_BUS_METHOD_WITH_NAMES("UnregisterService",
+                                 "o",
+                                 SD_BUS_PARAM(service_path),
+                                 NULL,,
+                                 bus_method_unregister_service,
+                                 SD_BUS_VTABLE_UNPRIVILEGED),
+
+        SD_BUS_METHOD("ResetStatistics",
+                      NULL,
+                      NULL,
+                      bus_method_reset_statistics,
+                      SD_BUS_VTABLE_UNPRIVILEGED),
+        SD_BUS_METHOD("FlushCaches",
+                      NULL,
+                      NULL,
+                      bus_method_flush_caches,
+                      SD_BUS_VTABLE_UNPRIVILEGED),
+        SD_BUS_METHOD("ResetServerFeatures",
+                      NULL,
+                      NULL,
+                      bus_method_reset_server_features,
+                      SD_BUS_VTABLE_UNPRIVILEGED),
+
         SD_BUS_VTABLE_END,
 };
 
@@ -1929,6 +2069,10 @@ int manager_connect_bus(Manager *m) {
         if (r < 0)
                 return log_error_errno(r, "Failed to register dnssd enumerator: %m");
 
+        r = bus_log_control_api_register(m->bus);
+        if (r < 0)
+                return r;
+
         r = sd_bus_request_name_async(m->bus, NULL, "org.freedesktop.resolve1", 0, NULL, NULL);
         if (r < 0)
                 return log_error_errno(r, "Failed to request name: %m");