}
r = sd_bus_send_to(bus, reply, "org.freedesktop.DBus", NULL);
- if (r < 0) {
- log_error_errno(r, "Failed to respond with to bus activation request: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to respond with to bus activation request: %m");
return 0;
}
#ifdef HAVE_SELINUX
r = sd_bus_add_filter(bus, NULL, mac_selinux_filter, m);
- if (r < 0) {
- log_error_errno(r, "Failed to add SELinux access filter: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to add SELinux access filter: %m");
#endif
r = sd_bus_add_object_vtable(bus, NULL, "/org/freedesktop/systemd1", "org.freedesktop.systemd1.Manager", bus_manager_vtable, m);
- if (r < 0) {
- log_error_errno(r, "Failed to register Manager vtable: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to register Manager vtable: %m");
r = sd_bus_add_fallback_vtable(bus, NULL, "/org/freedesktop/systemd1/job", "org.freedesktop.systemd1.Job", bus_job_vtable, bus_job_find, m);
- if (r < 0) {
- log_error_errno(r, "Failed to register Job vtable: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to register Job vtable: %m");
r = sd_bus_add_node_enumerator(bus, NULL, "/org/freedesktop/systemd1/job", bus_job_enumerate, m);
- if (r < 0) {
- log_error_errno(r, "Failed to add job enumerator: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to add job enumerator: %m");
r = sd_bus_add_fallback_vtable(bus, NULL, "/org/freedesktop/systemd1/unit", "org.freedesktop.systemd1.Unit", bus_unit_vtable, bus_unit_find, m);
- if (r < 0) {
- log_error_errno(r, "Failed to register Unit vtable: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to register Unit vtable: %m");
r = sd_bus_add_node_enumerator(bus, NULL, "/org/freedesktop/systemd1/unit", bus_unit_enumerate, m);
- if (r < 0) {
- log_error_errno(r, "Failed to add job enumerator: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to add job enumerator: %m");
for (t = 0; t < _UNIT_TYPE_MAX; t++) {
r = sd_bus_add_fallback_vtable(bus, NULL, "/org/freedesktop/systemd1/unit", unit_vtable[t]->bus_interface, unit_vtable[t]->bus_vtable, bus_unit_interface_find, m);
- if (r < 0) {
- log_error_errno(r, "Failed to register type specific vtable for %s: %m", unit_vtable[t]->bus_interface);
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to register type specific vtable for %s: %m", unit_vtable[t]->bus_interface);
if (unit_vtable[t]->cgroup_context_offset > 0) {
r = sd_bus_add_fallback_vtable(bus, NULL, "/org/freedesktop/systemd1/unit", unit_vtable[t]->bus_interface, bus_unit_cgroup_vtable, bus_unit_cgroup_find, m);
- if (r < 0) {
- log_error_errno(r, "Failed to register control group unit vtable for %s: %m", unit_vtable[t]->bus_interface);
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to register control group unit vtable for %s: %m", unit_vtable[t]->bus_interface);
r = sd_bus_add_fallback_vtable(bus, NULL, "/org/freedesktop/systemd1/unit", unit_vtable[t]->bus_interface, bus_cgroup_vtable, bus_cgroup_context_find, m);
- if (r < 0) {
- log_error_errno(r, "Failed to register control group vtable for %s: %m", unit_vtable[t]->bus_interface);
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to register control group vtable for %s: %m", unit_vtable[t]->bus_interface);
}
if (unit_vtable[t]->exec_context_offset > 0) {
r = sd_bus_add_fallback_vtable(bus, NULL, "/org/freedesktop/systemd1/unit", unit_vtable[t]->bus_interface, bus_exec_vtable, bus_exec_context_find, m);
- if (r < 0) {
- log_error_errno(r, "Failed to register execute vtable for %s: %m", unit_vtable[t]->bus_interface);
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to register execute vtable for %s: %m", unit_vtable[t]->bus_interface);
}
if (unit_vtable[t]->kill_context_offset > 0) {
r = sd_bus_add_fallback_vtable(bus, NULL, "/org/freedesktop/systemd1/unit", unit_vtable[t]->bus_interface, bus_kill_vtable, bus_kill_context_find, m);
- if (r < 0) {
- log_error_errno(r, "Failed to register kill vtable for %s: %m", unit_vtable[t]->bus_interface);
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to register kill vtable for %s: %m", unit_vtable[t]->bus_interface);
}
}
"member='Disconnected'",
signal_disconnected, m);
- if (r < 0) {
- log_error_errno(r, "Failed to register match for Disconnected message: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to register match for Disconnected message: %m");
return 0;
}
nfd = accept4(fd, NULL, NULL, SOCK_NONBLOCK|SOCK_CLOEXEC);
if (nfd < 0) {
- log_warning("Failed to accept private connection, ignoring: %m");
+ log_warning_errno(errno, "Failed to accept private connection, ignoring: %m");
return 0;
}
assert(bus);
r = sd_bus_list_names(bus, &names, NULL);
- if (r < 0) {
- log_error_errno(r, "Failed to get initial list of names: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to get initial list of names: %m");
/* This is a bit hacky, we say the owner of the name is the
* name itself, because we don't want the extra traffic to
* to allow clients to synchronously wait for reexecution to
* finish */
r = sd_bus_request_name(bus,"org.freedesktop.systemd1", SD_BUS_NAME_REPLACE_EXISTING|SD_BUS_NAME_ALLOW_REPLACEMENT);
- if (r < 0) {
- log_error_errno(r, "Failed to register name: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to register name: %m");
bus_list_names(m, bus);
(void) unlink(sa.un.sun_path);
fd = socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0);
- if (fd < 0) {
- log_error("Failed to allocate private socket: %m");
- return -errno;
- }
+ if (fd < 0)
+ return log_error_errno(errno, "Failed to allocate private socket: %m");
r = bind(fd, &sa.sa, salen);
- if (r < 0) {
- log_error("Failed to bind private socket: %m");
- return -errno;
- }
+ if (r < 0)
+ return log_error_errno(errno, "Failed to bind private socket: %m");
r = listen(fd, SOMAXCONN);
- if (r < 0) {
- log_error("Failed to make private socket listening: %m");
- return -errno;
- }
+ if (r < 0)
+ return log_error_errno(errno, "Failed to make private socket listening: %m");
r = sd_event_add_io(m->event, &s, fd, EPOLLIN, bus_on_connection, m);
- if (r < 0) {
- log_error_errno(r, "Failed to allocate event source: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to allocate event source: %m");
m->private_listen_fd = fd;
m->private_listen_event_source = s;
int bus_track_deserialize_item(char ***l, const char *line) {
const char *e;
+ int r;
assert(l);
assert(line);
e = startswith(line, "subscribed=");
if (!e)
- return -EINVAL;
+ return 0;
- return strv_extend(l, e);
+ r = strv_extend(l, e);
+ if (r < 0)
+ return r;
+
+ return 1;
}
int bus_track_coldplug(Manager *m, sd_bus_track **t, char ***l) {