resolved-bus.c revision 3abaabdab73bd0f3e4f68284dc3cb00902b8e1c6
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2014 Lennart Poettering
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include "alloc-util.h"
#include "bus-common-errors.h"
#include "bus-util.h"
#include "dns-domain.h"
#include "resolved-bus.h"
#include "resolved-def.h"
#include "resolved-link-bus.h"
static int reply_query_state(DnsQuery *q) {
switch (q->state) {
return sd_bus_reply_method_errorf(q->request, BUS_ERROR_NO_NAME_SERVERS, "No appropriate name servers or networks for name found");
case DNS_TRANSACTION_TIMEOUT:
return sd_bus_reply_method_errorf(q->request, SD_BUS_ERROR_TIMEOUT, "All attempts to contact name servers or networks failed");
case DNS_TRANSACTION_ABORTED:
return sd_bus_reply_method_errorf(q->request, BUS_ERROR_DNSSEC_FAILED, "DNSSEC validation failed: %s",
return sd_bus_reply_method_errorf(q->request, BUS_ERROR_NO_TRUST_ANCHOR, "No suitable trust anchor known");
return sd_bus_reply_method_errorf(q->request, BUS_ERROR_RR_TYPE_UNSUPPORTED, "Server does not support requested resource record type");
case DNS_TRANSACTION_RCODE_FAILURE: {
if (q->answer_rcode == DNS_RCODE_NXDOMAIN)
else {
const char *rc, *n;
char p[3]; /* the rcode is 4 bits long */
if (!rc) {
rc = p;
}
sd_bus_error_setf(&error, n, "Could not resolve '%s', server or network returned error %s", dns_query_string(q), rc);
}
}
case DNS_TRANSACTION_NULL:
case DNS_TRANSACTION_PENDING:
case DNS_TRANSACTION_SUCCESS:
default:
assert_not_reached("Impossible state");
}
}
int r;
if (r < 0)
return r;
if (r < 0)
return r;
if (r < 0)
return r;
if (r < 0)
return r;
} else
return -EAFNOSUPPORT;
if (r < 0)
return r;
if (r < 0)
return r;
return 0;
}
static void bus_method_resolve_hostname_complete(DnsQuery *q) {
unsigned added = 0;
int r;
assert(q);
if (q->state != DNS_TRANSACTION_SUCCESS) {
r = reply_query_state(q);
goto finish;
}
r = dns_query_process_cname(q);
if (r == -ELOOP) {
r = sd_bus_reply_method_errorf(q->request, BUS_ERROR_CNAME_LOOP, "CNAME loop detected, or CNAME resolving disabled on '%s'", dns_query_string(q));
goto finish;
}
if (r < 0)
goto finish;
if (r == DNS_QUERY_RESTARTED) /* This was a cname, and the query was restarted. */
return;
if (r < 0)
goto finish;
if (r < 0)
goto finish;
if (q->answer) {
int ifindex;
if (r < 0)
goto finish;
if (r == 0)
continue;
if (r < 0)
goto finish;
if (!canonical)
added ++;
}
}
if (added <= 0) {
r = sd_bus_reply_method_errorf(q->request, BUS_ERROR_NO_SUCH_RR, "'%s' does not have any RR of the requested type", dns_query_string(q));
goto finish;
}
if (r < 0)
goto finish;
/* Return the precise spelling and uppercasing and CNAME target reported by the server */
reply, "st",
if (r < 0)
goto finish;
if (r < 0) {
log_error_errno(r, "Failed to send hostname reply: %m");
}
dns_query_free(q);
}
if (ifindex < 0)
return 0;
}
static int bus_method_resolve_hostname(sd_bus_message *message, void *userdata, sd_bus_error *error) {
const char *hostname;
DnsQuery *q;
int r;
assert(m);
if (r < 0)
return r;
r = dns_name_is_valid(hostname);
if (r < 0)
return r;
if (r == 0)
if (r < 0)
return r;
if (r < 0)
return r;
if (r < 0)
return r;
if (r < 0)
return r;
q->request_family = family;
r = dns_query_bus_track(q, message);
if (r < 0)
goto fail;
r = dns_query_go(q);
if (r < 0)
goto fail;
return 1;
fail:
dns_query_free(q);
return r;
}
static void bus_method_resolve_address_complete(DnsQuery *q) {
unsigned added = 0;
int ifindex, r;
assert(q);
if (q->state != DNS_TRANSACTION_SUCCESS) {
r = reply_query_state(q);
goto finish;
}
r = dns_query_process_cname(q);
if (r == -ELOOP) {
r = sd_bus_reply_method_errorf(q->request, BUS_ERROR_CNAME_LOOP, "CNAME loop detected, or CNAME resolving disabled on '%s'", dns_query_string(q));
goto finish;
}
if (r < 0)
goto finish;
if (r == DNS_QUERY_RESTARTED) /* This was a cname, and the query was restarted. */
return;
if (r < 0)
goto finish;
if (r < 0)
goto finish;
if (r < 0)
goto finish;
if (r == 0)
continue;
if (r < 0)
goto finish;
added ++;
}
if (added <= 0) {
r = sd_bus_reply_method_errorf(q->request, BUS_ERROR_NO_SUCH_RR, "Address '%s' does not have any RR of requested type", strna(ip));
goto finish;
}
if (r < 0)
goto finish;
r = sd_bus_message_append(reply, "t", SD_RESOLVED_FLAGS_MAKE(q->answer_protocol, q->answer_family, q->answer_authenticated));
if (r < 0)
goto finish;
if (r < 0) {
log_error_errno(r, "Failed to send address reply: %m");
}
dns_query_free(q);
}
static int bus_method_resolve_address(sd_bus_message *message, void *userdata, sd_bus_error *error) {
const void *d;
DnsQuery *q;
int r;
assert(m);
if (r < 0)
return r;
if (r < 0)
return r;
if (r < 0)
return r;
if (r < 0)
return r;
if (r < 0)
return r;
if (r < 0)
return r;
q->request_family = family;
r = dns_query_bus_track(q, message);
if (r < 0)
goto fail;
r = dns_query_go(q);
if (r < 0)
goto fail;
return 1;
fail:
dns_query_free(q);
return r;
}
int r;
assert(m);
if (r < 0)
return r;
r = sd_bus_message_append(m, "iqq",
if (r < 0)
return r;
r = dns_resource_record_to_wire_format(rr, false);
if (r < 0)
return r;
if (r < 0)
return r;
return sd_bus_message_close_container(m);
}
static void bus_method_resolve_record_complete(DnsQuery *q) {
unsigned added = 0;
int ifindex;
int r;
assert(q);
if (q->state != DNS_TRANSACTION_SUCCESS) {
r = reply_query_state(q);
goto finish;
}
r = dns_query_process_cname(q);
if (r == -ELOOP) {
r = sd_bus_reply_method_errorf(q->request, BUS_ERROR_CNAME_LOOP, "CNAME loop detected, or CNAME resolving disabled on '%s'", dns_query_string(q));
goto finish;
}
if (r < 0)
goto finish;
if (r == DNS_QUERY_RESTARTED) /* This was a cname, and the query was restarted. */
return;
if (r < 0)
goto finish;
if (r < 0)
goto finish;
if (r < 0)
goto finish;
if (r == 0)
continue;
if (r < 0)
goto finish;
added ++;
}
if (added <= 0) {
r = sd_bus_reply_method_errorf(q->request, BUS_ERROR_NO_SUCH_RR, "Name '%s' does not have any RR of the requested type", dns_query_string(q));
goto finish;
}
if (r < 0)
goto finish;
r = sd_bus_message_append(reply, "t", SD_RESOLVED_FLAGS_MAKE(q->answer_protocol, q->answer_family, q->answer_authenticated));
if (r < 0)
goto finish;
if (r < 0) {
log_error_errno(r, "Failed to send record reply: %m");
}
dns_query_free(q);
}
static int bus_method_resolve_record(sd_bus_message *message, void *userdata, sd_bus_error *error) {
const char *name;
int r, ifindex;
DnsQuery *q;
assert(m);
if (r < 0)
return r;
r = dns_name_is_valid(name);
if (r < 0)
return r;
if (r == 0)
if (!dns_type_is_valid_query(type))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Specified resource record type %" PRIu16 " may not be used in a query.", type);
if (dns_type_is_obsolete(type))
return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Specified DNS resource record type %" PRIu16 " is obsolete.", type);
if (r < 0)
return r;
if (!question)
return -ENOMEM;
if (!key)
return -ENOMEM;
if (r < 0)
return r;
if (r < 0)
return r;
r = dns_query_bus_track(q, message);
if (r < 0)
goto fail;
r = dns_query_go(q);
if (r < 0)
goto fail;
return 1;
fail:
dns_query_free(q);
return r;
}
int r;
assert(q);
return 0;
if ((q->flags & SD_RESOLVED_NO_ADDRESS) == 0) {
/* First, let's see if we could find an appropriate A or AAAA
* record for the SRV record */
continue;
if (aux->auxiliary_result != 0)
continue;
if (r < 0)
return r;
if (r == 0)
continue;
if (r < 0)
return r;
if (r == 0)
continue;
break;
}
if (canonical)
break;
}
if (!canonical)
return 0;
}
if (r < 0)
return r;
"qqqs",
if (r < 0)
return r;
if (r < 0)
return r;
if ((q->flags & SD_RESOLVED_NO_ADDRESS) == 0) {
int ifindex;
continue;
if (aux->auxiliary_result != 0)
continue;
if (r < 0)
return r;
if (r == 0)
continue;
if (r < 0)
return r;
if (r == 0)
continue;
if (r < 0)
return r;
}
}
}
if (r < 0)
return r;
/* Note that above we appended the hostname as encoded in the
* SRV, and here the canonical hostname this maps to. */
r = sd_bus_message_append(reply, "s", canonical ? DNS_RESOURCE_KEY_NAME(canonical->key) : rr->srv.name);
if (r < 0)
return r;
if (r < 0)
return r;
return 1;
}
DnsTxtItem *i;
int r;
return 0;
if (i->length <= 0)
continue;
if (r < 0)
return r;
}
return 1;
}
static void resolve_service_all_complete(DnsQuery *q) {
unsigned added = 0;
int r;
assert(q);
if (q->block_all_complete > 0)
return;
if ((q->flags & SD_RESOLVED_NO_ADDRESS) == 0) {
bool have_success = false;
case DNS_TRANSACTION_PENDING:
/* If an auxiliary query is still pending, let's wait */
return;
case DNS_TRANSACTION_SUCCESS:
if (aux->auxiliary_result == 0)
have_success = true;
else
break;
default:
break;
}
}
if (!have_success) {
/* We can only return one error, hence pick the last error we encountered */
r = sd_bus_reply_method_errorf(q->request, BUS_ERROR_CNAME_LOOP, "CNAME loop detected, or CNAME resolving disabled on '%s'", dns_query_string(bad));
goto finish;
}
r = bad->auxiliary_result;
goto finish;
}
r = reply_query_state(bad);
goto finish;
}
}
if (r < 0)
goto finish;
if (r < 0)
goto finish;
if (r < 0)
goto finish;
if (r == 0)
continue;
if (r < 0)
goto finish;
if (r == 0) /* not an SRV record */
continue;
if (!canonical)
added++;
}
if (added <= 0) {
r = sd_bus_reply_method_errorf(q->request, BUS_ERROR_NO_SUCH_RR, "'%s' does not have any RR of the requested type", dns_query_string(q));
goto finish;
}
if (r < 0)
goto finish;
if (r < 0)
goto finish;
if (r < 0)
goto finish;
if (r == 0)
continue;
if (r < 0)
goto finish;
}
if (r < 0)
goto finish;
if (r < 0)
goto finish;
"ssst",
if (r < 0)
goto finish;
if (r < 0) {
log_error_errno(r, "Failed to send service reply: %m");
}
dns_query_free(q);
}
static void resolve_service_hostname_complete(DnsQuery *q) {
int r;
assert(q);
assert(q->auxiliary_for);
if (q->state != DNS_TRANSACTION_SUCCESS) {
return;
}
r = dns_query_process_cname(q);
if (r == DNS_QUERY_RESTARTED) /* This was a cname, and the query was restarted. */
return;
/* This auxiliary lookup is finished or failed, let's see if all are finished now. */
q->auxiliary_result = r;
}
int r;
assert(q);
/* OK, we found an SRV record for the service. Let's resolve
* the hostname included in it */
if (r < 0)
return r;
if (r < 0)
return r;
r = dns_query_make_auxiliary(aux, q);
if (r == -EAGAIN) {
/* Too many auxiliary lookups? If so, don't complain,
* let's just not add this one, we already have more
* than enough */
return 0;
}
if (r < 0)
goto fail;
/* Note that auxiliary queries do not track the original bus
* client, only the primary request does that. */
r = dns_query_go(aux);
if (r < 0)
goto fail;
return 1;
fail:
return r;
}
static void bus_method_resolve_service_complete(DnsQuery *q) {
bool has_root_domain = false;
unsigned found = 0;
int ifindex, r;
assert(q);
if (q->state != DNS_TRANSACTION_SUCCESS) {
r = reply_query_state(q);
goto finish;
}
r = dns_query_process_cname(q);
if (r == -ELOOP) {
r = sd_bus_reply_method_errorf(q->request, BUS_ERROR_CNAME_LOOP, "CNAME loop detected, or CNAME resolving disabled on '%s'", dns_query_string(q));
goto finish;
}
if (r < 0)
goto finish;
if (r == DNS_QUERY_RESTARTED) /* This was a cname, and the query was restarted. */
return;
if (r < 0)
goto finish;
if (r == 0)
continue;
continue;
has_root_domain = true;
continue;
}
if ((q->flags & SD_RESOLVED_NO_ADDRESS) == 0) {
q->block_all_complete ++;
q->block_all_complete --;
if (r < 0)
goto finish;
}
found++;
}
if (has_root_domain && found <= 0) {
/* If there's exactly one SRV RR and it uses
* the root domain as host name, then the
* service is explicitly not offered on the
* domain. Report this as a recognizable
* error. See RFC 2782, Section "Usage
* Rules". */
r = sd_bus_reply_method_errorf(q->request, BUS_ERROR_NO_SUCH_SERVICE, "'%s' does not provide the requested service", dns_query_string(q));
goto finish;
}
if (found <= 0) {
r = sd_bus_reply_method_errorf(q->request, BUS_ERROR_NO_SUCH_RR, "'%s' does not have any RR of the requested type", dns_query_string(q));
goto finish;
}
/* Maybe we are already finished? check now... */
return;
if (r < 0) {
log_error_errno(r, "Failed to send service reply: %m");
}
dns_query_free(q);
}
static int bus_method_resolve_service(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_free_ char *n = NULL;
DnsQuery *q;
int r;
assert(m);
if (r < 0)
return r;
else if (!dns_service_name_is_valid(name))
else if (!dns_srv_type_is_valid(type))
r = dns_name_is_valid(domain);
if (r < 0)
return r;
if (r == 0)
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Service name cannot be specified without service type.");
if (r < 0)
return r;
r = dns_question_new_service(&question_utf8, name, type, domain, !(flags & SD_RESOLVED_NO_TXT), false);
if (r < 0)
return r;
r = dns_question_new_service(&question_idna, name, type, domain, !(flags & SD_RESOLVED_NO_TXT), true);
if (r < 0)
return r;
if (r < 0)
return r;
q->request_family = family;
r = dns_query_bus_track(q, message);
if (r < 0)
goto fail;
r = dns_query_go(q);
if (r < 0)
goto fail;
return 1;
fail:
dns_query_free(q);
return r;
}
int r;
assert(s);
if (r < 0)
return r;
if (with_ifindex) {
if (r < 0)
return r;
}
if (r < 0)
return r;
if (r < 0)
return r;
return sd_bus_message_close_container(reply);
}
static int bus_property_get_dns_servers(
const char *path,
const char *interface,
const char *property,
void *userdata,
sd_bus_error *error) {
unsigned c = 0;
DnsServer *s;
Iterator i;
Link *l;
int r;
assert(m);
if (r < 0)
return r;
r = bus_dns_server_append(reply, s, true);
if (r < 0)
return r;
c++;
}
HASHMAP_FOREACH(l, m->links, i) {
r = bus_dns_server_append(reply, s, true);
if (r < 0)
return r;
c++;
}
}
if (c == 0) {
r = bus_dns_server_append(reply, s, true);
if (r < 0)
return r;
}
}
return sd_bus_message_close_container(reply);
}
static int bus_property_get_search_domains(
const char *path,
const char *interface,
const char *property,
void *userdata,
sd_bus_error *error) {
DnsSearchDomain *d;
Iterator i;
Link *l;
int r;
assert(m);
if (r < 0)
return r;
if (r < 0)
return r;
}
HASHMAP_FOREACH(l, m->links, i) {
if (r < 0)
return r;
}
}
return sd_bus_message_close_container(reply);
}
static int bus_property_get_transaction_statistics(
const char *path,
const char *interface,
const char *property,
void *userdata,
sd_bus_error *error) {
assert(m);
(uint64_t) m->n_transactions_total);
}
static int bus_property_get_cache_statistics(
const char *path,
const char *interface,
const char *property,
void *userdata,
sd_bus_error *error) {
DnsScope *s;
assert(m);
}
}
static int bus_property_get_dnssec_statistics(
const char *path,
const char *interface,
const char *property,
void *userdata,
sd_bus_error *error) {
assert(m);
(uint64_t) m->n_dnssec_secure,
(uint64_t) m->n_dnssec_insecure,
(uint64_t) m->n_dnssec_bogus,
(uint64_t) m->n_dnssec_indeterminate);
}
static int bus_property_get_dnssec_supported(
const char *path,
const char *interface,
const char *property,
void *userdata,
sd_bus_error *error) {
bool supported = true;
Iterator i;
Link *l;
assert(m);
server = manager_get_dns_server(m);
if (server)
HASHMAP_FOREACH(l, m->links, i) {
server = link_get_dns_server(l);
if (server)
}
}
static int bus_method_reset_statistics(sd_bus_message *message, void *userdata, sd_bus_error *error) {
DnsScope *s;
assert(m);
m->n_transactions_total = 0;
}
Link *l;
assert(m);
if (ifindex <= 0)
if (!l)
*ret = l;
return 0;
}
Link *l;
int r;
assert(m);
if (r < 0)
return r;
if (l->flags & IFF_LOOPBACK)
if (l->is_managed)
*ret = l;
return 0;
}
static int bus_method_set_link_dns_servers(sd_bus_message *message, void *userdata, sd_bus_error *error) {
int ifindex, r;
unsigned i;
Link *l;
assert(m);
if (r < 0)
return r;
if (r < 0)
return r;
if (r < 0)
return r;
for (;;) {
int family;
const void *d;
if (r < 0)
return r;
if (r == 0)
break;
if (r < 0)
return r;
if (r < 0)
return r;
if (r < 0)
return r;
return -ENOMEM;
n++;
}
if (r < 0)
return r;
for (i = 0; i < n; i++) {
DnsServer *s;
if (s)
else {
if (r < 0)
goto clear;
}
}
return r;
}
static int bus_method_set_link_domains(sd_bus_message *message, void *userdata, sd_bus_error *error) {
int ifindex, r;
char **i;
Link *l;
assert(m);
if (r < 0)
return r;
if (r < 0)
return r;
if (r < 0)
return r;
STRV_FOREACH(i, domains) {
r = dns_name_is_valid(*i);
if (r < 0)
return r;
if (r == 0)
if (dns_name_is_root(*i))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Root domain is not suitable as search domain");
}
STRV_FOREACH(i, domains) {
DnsSearchDomain *d;
r = dns_search_domain_find(l->search_domains, *i, &d);
if (r < 0)
goto clear;
if (r > 0)
else {
if (r < 0)
goto clear;
}
}
return r;
}
static int bus_method_set_link_llmnr(sd_bus_message *message, void *userdata, sd_bus_error *error) {
const char *llmnr;
int ifindex, r;
Link *l;
assert(m);
if (r < 0)
return r;
else {
if (mode < 0)
}
if (r < 0)
return r;
l->llmnr_support = mode;
link_add_rrs(l, false);
}
const char *mdns;
int ifindex, r;
Link *l;
assert(m);
if (r < 0)
return r;
else {
if (mode < 0)
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid MulticastDNS setting: %s", mdns);
}
if (r < 0)
return r;
l->mdns_support = mode;
link_add_rrs(l, false);
}
static int bus_method_set_link_dnssec(sd_bus_message *message, void *userdata, sd_bus_error *error) {
const char *dnssec;
int ifindex, r;
Link *l;
assert(m);
if (r < 0)
return r;
else {
if (mode < 0)
}
if (r < 0)
return r;
link_set_dnssec_mode(l, mode);
}
static int bus_method_set_link_dnssec_negative_trust_anchors(sd_bus_message *message, void *userdata, sd_bus_error *error) {
int ifindex, r;
char **i;
Link *l;
assert(m);
if (r < 0)
return r;
if (r < 0)
return r;
if (r < 0)
return r;
STRV_FOREACH(i, ntas) {
r = dns_name_is_valid(*i);
if (r < 0)
return r;
if (r == 0)
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid search negative trust anchor domain: %s", *i);
}
if (!ns)
return -ENOMEM;
STRV_FOREACH(i, ntas) {
r = set_put_strdup(ns, *i);
if (r < 0)
return r;
}
}
int ifindex;
Link *l;
int r;
assert(m);
if (r < 0)
return r;
if (r < 0)
return r;
link_add_rrs(l, false);
}
_cleanup_free_ char *p = NULL;
int r, ifindex;
Link *l;
assert(m);
if (r < 0)
return r;
if (r < 0)
return r;
p = link_bus_path(l);
if (!p)
return -ENOMEM;
}
static const sd_bus_vtable resolve_vtable[] = {
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("SetLinkDNSSECNegativeTrustAnchors", "ias", NULL, bus_method_set_link_dnssec_negative_trust_anchors, 0),
};
assert(s);
assert(m);
return 0;
}
static int match_prepare_for_sleep(sd_bus_message *message, void *userdata, sd_bus_error *ret_error) {
int b, r;
assert(m);
if (r < 0) {
log_debug_errno(r, "Failed to parse PrepareForSleep signal: %m");
return 0;
}
if (b)
return 0;
log_debug("Coming back from suspend, verifying all RRs...");
return 0;
}
int manager_connect_bus(Manager *m) {
int r;
assert(m);
if (m->bus)
return 0;
r = sd_bus_default_system(&m->bus);
if (r < 0) {
/* We failed to connect? Yuck, we must be in early
* boot. Let's try in 5s again. As soon as we have
* kdbus we can stop doing this... */
log_debug_errno(r, "Failed to connect to bus, trying again in 5s: %m");
r = sd_event_add_time(m->event, &m->bus_retry_event_source, CLOCK_MONOTONIC, now(CLOCK_MONOTONIC) + 5*USEC_PER_SEC, 0, on_bus_retry, m);
if (r < 0)
return log_error_errno(r, "Failed to install bus reconnect time event: %m");
return 0;
}
r = sd_bus_add_object_vtable(m->bus, NULL, "/org/freedesktop/resolve1", "org.freedesktop.resolve1.Manager", resolve_vtable, m);
if (r < 0)
return log_error_errno(r, "Failed to register object: %m");
r = sd_bus_add_fallback_vtable(m->bus, NULL, "/org/freedesktop/resolve1/link", "org.freedesktop.resolve1.Link", link_vtable, link_object_find, m);
if (r < 0)
return log_error_errno(r, "Failed to register link objects: %m");
r = sd_bus_add_node_enumerator(m->bus, NULL, "/org/freedesktop/resolve1/link", link_node_enumerator, m);
if (r < 0)
return log_error_errno(r, "Failed to register link enumerator: %m");
if (r < 0)
return log_error_errno(r, "Failed to register name: %m");
if (r < 0)
return log_error_errno(r, "Failed to attach bus to event loop: %m");
"type='signal',"
"sender='org.freedesktop.login1',"
"interface='org.freedesktop.login1.Manager',"
"member='PrepareForSleep',"
"path='/org/freedesktop/login1'",
m);
if (r < 0)
log_error_errno(r, "Failed to add match for PrepareForSleep: %m");
return 0;
}