1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
4 This file is part of systemd.
6 Copyright 2010 Lennart Poettering
8 systemd is free software; you can redistribute it and/or modify it
9 under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 2.1 of the License, or
11 (at your option) any later version.
13 systemd is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
18 You should have received a copy of the GNU Lesser General Public License
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
22 #include <sys/epoll.h>
23 #include <sys/timerfd.h>
32 #include "dbus-unit.h"
34 #include "dbus-manager.h"
35 #include "dbus-execute.h"
36 #include "dbus-kill.h"
37 #include "dbus-cgroup.h"
41 #include "bus-error.h"
42 #include "bus-errors.h"
44 #include "bus-internal.h"
45 #include "selinux-access.h"
47 #define CONNECTIONS_MAX 512
49 static void destroy_bus(Manager *m, sd_bus **bus);
51 int bus_send_queued_message(Manager *m) {
56 if (!m->queued_message)
59 assert(m->queued_message_bus);
61 /* If we cannot get rid of this message we won't dispatch any
62 * D-Bus messages, so that we won't end up wanting to queue
65 r = sd_bus_send(m->queued_message_bus, m->queued_message, NULL);
67 log_warning("Failed to send queued message: %s", strerror(-r));
69 m->queued_message = sd_bus_message_unref(m->queued_message);
70 m->queued_message_bus = sd_bus_unref(m->queued_message_bus);
75 static int signal_agent_released(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
76 Manager *m = userdata;
84 r = sd_bus_message_read(message, "s", &cgroup);
86 bus_log_parse_error(r);
90 manager_notify_cgroup_empty(m, cgroup);
92 if (m->running_as == SYSTEMD_SYSTEM && m->system_bus) {
93 /* If we are running as system manager, forward the
94 * message to the system bus */
96 r = sd_bus_send(m->system_bus, message, NULL);
98 log_warning("Failed to forward Released message: %s", strerror(-r));
104 static int signal_disconnected(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
105 Manager *m = userdata;
111 if (bus == m->api_bus)
112 destroy_bus(m, &m->api_bus);
113 if (bus == m->system_bus)
114 destroy_bus(m, &m->system_bus);
115 if (set_remove(m->private_buses, bus)) {
116 log_debug("Got disconnect on private connection.");
117 destroy_bus(m, &bus);
123 static int signal_name_owner_changed(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
124 const char *name, *old_owner, *new_owner;
125 Manager *m = userdata;
132 r = sd_bus_message_read(message, "sss", &name, &old_owner, &new_owner);
134 bus_log_parse_error(r);
138 manager_dispatch_bus_name_owner_changed(
140 isempty(old_owner) ? NULL : old_owner,
141 isempty(new_owner) ? NULL : new_owner);
146 static int signal_activation_request(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *ret_error) {
147 _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
148 _cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
149 Manager *m = userdata;
158 r = sd_bus_message_read(message, "s", &name);
160 bus_log_parse_error(r);
164 if (manager_unit_inactive_or_pending(m, SPECIAL_DBUS_SERVICE) ||
165 manager_unit_inactive_or_pending(m, SPECIAL_DBUS_SOCKET)) {
166 r = sd_bus_error_setf(&error, BUS_ERROR_SHUTTING_DOWN, "Refusing activation, D-Bus is shutting down.");
170 r = manager_load_unit(m, name, NULL, &error, &u);
174 if (u->refuse_manual_start) {
175 r = sd_bus_error_setf(&error, BUS_ERROR_ONLY_BY_DEPENDENCY, "Operation refused, %s may be requested by dependency only.", u->id);
179 r = manager_add_job(m, JOB_START, u, JOB_REPLACE, true, &error, NULL);
183 /* Successfully queued, that's it for us */
187 if (!sd_bus_error_is_set(&error))
188 sd_bus_error_set_errno(&error, r);
190 log_debug("D-Bus activation failed for %s: %s", name, bus_error_message(&error, r));
192 r = sd_bus_message_new_signal(bus, &reply, "/org/freedesktop/systemd1", "org.freedesktop.systemd1.Activator", "ActivationFailure");
194 bus_log_create_error(r);
198 r = sd_bus_message_append(reply, "sss", name, error.name, error.message);
200 bus_log_create_error(r);
204 r = sd_bus_send_to(bus, reply, "org.freedesktop.DBus", NULL);
206 log_error("Failed to respond with to bus activation request: %s", strerror(-r));
214 static int selinux_filter(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
215 Manager *m = userdata;
216 const char *verb, *path;
224 /* Our own method calls are all protected individually with
225 * selinux checks, but the built-in interfaces need to be
228 if (sd_bus_message_is_method_call(message, "org.freedesktop.DBus.Properties", "Set"))
230 else if (sd_bus_message_is_method_call(message, "org.freedesktop.DBus.Introspectable", NULL) ||
231 sd_bus_message_is_method_call(message, "org.freedesktop.DBus.Properties", NULL) ||
232 sd_bus_message_is_method_call(message, "org.freedesktop.DBus.ObjectManager", NULL) ||
233 sd_bus_message_is_method_call(message, "org.freedesktop.DBus.Peer", NULL))
238 path = sd_bus_message_get_path(message);
240 if (object_path_startswith("/org/freedesktop/systemd1", path)) {
242 r = selinux_access_check(bus, message, verb, error);
249 if (streq_ptr(path, "/org/freedesktop/systemd1/unit/self")) {
250 _cleanup_bus_creds_unref_ sd_bus_creds *creds = NULL;
253 r = sd_bus_query_sender_creds(message, SD_BUS_CREDS_PID, &creds);
257 r = sd_bus_creds_get_pid(creds, &pid);
261 u = manager_get_unit_by_pid(m, pid);
263 r = manager_get_job_from_dbus_path(m, path, &j);
267 manager_load_unit_from_dbus_path(m, path, NULL, &u);
273 r = selinux_unit_access_check(u, bus, message, verb, error);
281 static int bus_job_find(sd_bus *bus, const char *path, const char *interface, void *userdata, void **found, sd_bus_error *error) {
282 Manager *m = userdata;
292 r = manager_get_job_from_dbus_path(m, path, &j);
300 static int find_unit(Manager *m, sd_bus *bus, const char *path, Unit **unit, sd_bus_error *error) {
308 if (streq_ptr(path, "/org/freedesktop/systemd1/unit/self")) {
309 _cleanup_bus_creds_unref_ sd_bus_creds *creds = NULL;
310 sd_bus_message *message;
313 message = sd_bus_get_current(bus);
317 r = sd_bus_query_sender_creds(message, SD_BUS_CREDS_PID, &creds);
321 r = sd_bus_creds_get_pid(creds, &pid);
325 u = manager_get_unit_by_pid(m, pid);
327 r = manager_load_unit_from_dbus_path(m, path, error, &u);
339 static int bus_unit_find(sd_bus *bus, const char *path, const char *interface, void *userdata, void **found, sd_bus_error *error) {
340 Manager *m = userdata;
348 return find_unit(m, bus, path, (Unit**) found, error);
351 static int bus_unit_interface_find(sd_bus *bus, const char *path, const char *interface, void *userdata, void **found, sd_bus_error *error) {
352 Manager *m = userdata;
362 r = find_unit(m, bus, path, &u, error);
366 if (!streq_ptr(interface, UNIT_VTABLE(u)->bus_interface))
373 static int bus_unit_cgroup_find(sd_bus *bus, const char *path, const char *interface, void *userdata, void **found, sd_bus_error *error) {
374 Manager *m = userdata;
384 r = find_unit(m, bus, path, &u, error);
388 if (!streq_ptr(interface, UNIT_VTABLE(u)->bus_interface))
391 if (!unit_get_cgroup_context(u))
398 static int bus_cgroup_context_find(sd_bus *bus, const char *path, const char *interface, void *userdata, void **found, sd_bus_error *error) {
399 Manager *m = userdata;
410 r = find_unit(m, bus, path, &u, error);
414 if (!streq_ptr(interface, UNIT_VTABLE(u)->bus_interface))
417 c = unit_get_cgroup_context(u);
425 static int bus_exec_context_find(sd_bus *bus, const char *path, const char *interface, void *userdata, void **found, sd_bus_error *error) {
426 Manager *m = userdata;
437 r = find_unit(m, bus, path, &u, error);
441 if (!streq_ptr(interface, UNIT_VTABLE(u)->bus_interface))
444 c = unit_get_exec_context(u);
452 static int bus_kill_context_find(sd_bus *bus, const char *path, const char *interface, void *userdata, void **found, sd_bus_error *error) {
453 Manager *m = userdata;
464 r = find_unit(m, bus, path, &u, error);
468 if (!streq_ptr(interface, UNIT_VTABLE(u)->bus_interface))
471 c = unit_get_kill_context(u);
479 static int bus_job_enumerate(sd_bus *bus, const char *path, void *userdata, char ***nodes, sd_bus_error *error) {
480 _cleanup_free_ char **l = NULL;
481 Manager *m = userdata;
486 l = new0(char*, hashmap_size(m->jobs)+1);
490 HASHMAP_FOREACH(j, m->jobs, i) {
491 l[k] = job_dbus_path(j);
498 assert(hashmap_size(m->jobs) == k);
506 static int bus_unit_enumerate(sd_bus *bus, const char *path, void *userdata, char ***nodes, sd_bus_error *error) {
507 _cleanup_free_ char **l = NULL;
508 Manager *m = userdata;
513 l = new0(char*, hashmap_size(m->units)+1);
517 HASHMAP_FOREACH(u, m->units, i) {
518 l[k] = unit_dbus_path(u);
531 static int bus_setup_api_vtables(Manager *m, sd_bus *bus) {
539 r = sd_bus_add_filter(bus, selinux_filter, m);
541 log_error("Failed to add SELinux access filter: %s", strerror(-r));
546 r = sd_bus_add_object_vtable(bus, "/org/freedesktop/systemd1", "org.freedesktop.systemd1.Manager", bus_manager_vtable, m);
548 log_error("Failed to register Manager vtable: %s", strerror(-r));
552 r = sd_bus_add_fallback_vtable(bus, "/org/freedesktop/systemd1/job", "org.freedesktop.systemd1.Job", bus_job_vtable, bus_job_find, m);
554 log_error("Failed to register Job vtable: %s", strerror(-r));
558 r = sd_bus_add_node_enumerator(bus, "/org/freedesktop/systemd1/job", bus_job_enumerate, m);
560 log_error("Failed to add job enumerator: %s", strerror(-r));
564 r = sd_bus_add_fallback_vtable(bus, "/org/freedesktop/systemd1/unit", "org.freedesktop.systemd1.Unit", bus_unit_vtable, bus_unit_find, m);
566 log_error("Failed to register Unit vtable: %s", strerror(-r));
570 r = sd_bus_add_node_enumerator(bus, "/org/freedesktop/systemd1/unit", bus_unit_enumerate, m);
572 log_error("Failed to add job enumerator: %s", strerror(-r));
576 for (t = 0; t < _UNIT_TYPE_MAX; t++) {
577 r = sd_bus_add_fallback_vtable(bus, "/org/freedesktop/systemd1/unit", unit_vtable[t]->bus_interface, unit_vtable[t]->bus_vtable, bus_unit_interface_find, m);
579 log_error("Failed to register type specific vtable for %s: %s", unit_vtable[t]->bus_interface, strerror(-r));
583 if (unit_vtable[t]->cgroup_context_offset > 0) {
584 r = sd_bus_add_fallback_vtable(bus, "/org/freedesktop/systemd1/unit", unit_vtable[t]->bus_interface, bus_unit_cgroup_vtable, bus_unit_cgroup_find, m);
586 log_error("Failed to register control group unit vtable for %s: %s", unit_vtable[t]->bus_interface, strerror(-r));
590 r = sd_bus_add_fallback_vtable(bus, "/org/freedesktop/systemd1/unit", unit_vtable[t]->bus_interface, bus_cgroup_vtable, bus_cgroup_context_find, m);
592 log_error("Failed to register control group vtable for %s: %s", unit_vtable[t]->bus_interface, strerror(-r));
597 if (unit_vtable[t]->exec_context_offset > 0) {
598 r = sd_bus_add_fallback_vtable(bus, "/org/freedesktop/systemd1/unit", unit_vtable[t]->bus_interface, bus_exec_vtable, bus_exec_context_find, m);
600 log_error("Failed to register execute vtable for %s: %s", unit_vtable[t]->bus_interface, strerror(-r));
605 if (unit_vtable[t]->kill_context_offset > 0) {
606 r = sd_bus_add_fallback_vtable(bus, "/org/freedesktop/systemd1/unit", unit_vtable[t]->bus_interface, bus_kill_vtable, bus_kill_context_find, m);
608 log_error("Failed to register kill vtable for %s: %s", unit_vtable[t]->bus_interface, strerror(-r));
617 static int bus_setup_disconnected_match(Manager *m, sd_bus *bus) {
623 r = sd_bus_add_match(
625 "sender='org.freedesktop.DBus.Local',"
627 "path='/org/freedesktop/DBus/Local',"
628 "interface='org.freedesktop.DBus.Local',"
629 "member='Disconnected'",
630 signal_disconnected, m);
633 log_error("Failed to register match for Disconnected message: %s", strerror(-r));
640 static int bus_on_connection(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
641 _cleanup_bus_unref_ sd_bus *bus = NULL;
642 _cleanup_close_ int nfd = -1;
643 Manager *m = userdata;
650 nfd = accept4(fd, NULL, NULL, SOCK_NONBLOCK|SOCK_CLOEXEC);
652 log_warning("Failed to accept private connection, ignoring: %m");
656 if (set_size(m->private_buses) >= CONNECTIONS_MAX) {
657 log_warning("Too many concurrent connections, refusing");
661 r = set_ensure_allocated(&m->private_buses, trivial_hash_func, trivial_compare_func);
667 r = sd_bus_new(&bus);
669 log_warning("Failed to allocate new private connection bus: %s", strerror(-r));
673 r = sd_bus_set_fd(bus, nfd, nfd);
675 log_warning("Failed to set fd on new connection bus: %s", strerror(-r));
681 r = bus_check_peercred(bus);
683 log_warning("Incoming private connection from unprivileged client, refusing: %s", strerror(-r));
687 assert_se(sd_id128_randomize(&id) >= 0);
689 r = sd_bus_set_server(bus, 1, id);
691 log_warning("Failed to enable server support for new connection bus: %s", strerror(-r));
695 r = sd_bus_start(bus);
697 log_warning("Failed to start new connection bus: %s", strerror(-r));
701 r = sd_bus_attach_event(bus, m->event, SD_EVENT_PRIORITY_NORMAL);
703 log_warning("Failed to attach new connection bus to event loop: %s", strerror(-r));
707 if (m->running_as == SYSTEMD_SYSTEM) {
708 /* When we run as system instance we get the Released
709 * signal via a direct connection */
711 r = sd_bus_add_match(
714 "interface='org.freedesktop.systemd1.Agent',"
716 "path='/org/freedesktop/systemd1/agent'",
717 signal_agent_released, m);
720 log_warning("Failed to register Released match on new connection bus: %s", strerror(-r));
725 r = bus_setup_disconnected_match(m, bus);
729 r = bus_setup_api_vtables(m, bus);
731 log_warning("Failed to set up API vtables on new connection bus: %s", strerror(-r));
735 r = set_put(m->private_buses, bus);
737 log_warning("Failed to add new conenction bus to set: %s", strerror(-r));
743 log_debug("Accepted new private connection.");
748 static int bus_list_names(Manager *m, sd_bus *bus) {
749 _cleanup_strv_free_ char **names = NULL;
756 r = sd_bus_list_names(bus, &names, NULL);
758 log_error("Failed to get initial list of names: %s", strerror(-r));
762 /* This is a bit hacky, we say the owner of the name is the
763 * name itself, because we don't want the extra traffic to
764 * figure out the real owner. */
765 STRV_FOREACH(i, names)
766 manager_dispatch_bus_name_owner_changed(m, *i, NULL, *i);
771 static int bus_setup_api(Manager *m, sd_bus *bus) {
777 r = bus_setup_api_vtables(m, bus);
781 r = sd_bus_add_match(
784 "sender='org.freedesktop.DBus',"
785 "path='/org/freedesktop/DBus',"
786 "interface='org.freedesktop.DBus',"
787 "member='NameOwnerChanged'",
788 signal_name_owner_changed, m);
790 log_warning("Failed to subscribe to NameOwnerChanged signal: %s", strerror(-r));
792 r = sd_bus_add_match(
795 "sender='org.freedesktop.DBus',"
796 "path='/org/freedesktop/DBus',"
797 "interface='org.freedesktop.systemd1.Activator',"
798 "member='ActivationRequest'",
799 signal_activation_request, m);
801 log_warning("Failed to subscribe to activation signal: %s", strerror(-r));
803 /* Allow replacing of our name, to ease implementation of
804 * reexecution, where we keep the old connection open until
805 * after the new connection is set up and the name installed
806 * to allow clients to synchronously wait for reexecution to
808 r = sd_bus_request_name(bus,"org.freedesktop.systemd1", SD_BUS_NAME_REPLACE_EXISTING|SD_BUS_NAME_ALLOW_REPLACEMENT);
810 log_error("Failed to register name: %s", strerror(-r));
814 bus_list_names(m, bus);
816 log_debug("Successfully connected to API bus.");
820 static int bus_init_api(Manager *m) {
821 _cleanup_bus_unref_ sd_bus *bus = NULL;
827 /* The API and system bus is the same if we are running in system mode */
828 if (m->running_as == SYSTEMD_SYSTEM && m->system_bus)
829 bus = sd_bus_ref(m->system_bus);
831 if (m->running_as == SYSTEMD_SYSTEM)
832 r = sd_bus_open_system(&bus);
834 r = sd_bus_open_user(&bus);
837 log_debug("Failed to connect to API bus, retrying later...");
841 r = sd_bus_attach_event(bus, m->event, SD_EVENT_PRIORITY_NORMAL);
843 log_error("Failed to attach API bus to event loop: %s", strerror(-r));
847 r = bus_setup_disconnected_match(m, bus);
852 r = bus_setup_api(m, bus);
854 log_error("Failed to set up API bus: %s", strerror(-r));
864 static int bus_setup_system(Manager *m, sd_bus *bus) {
870 if (m->running_as == SYSTEMD_SYSTEM)
873 /* If we are a user instance we get the Released message via
875 r = sd_bus_add_match(
878 "interface='org.freedesktop.systemd1.Agent',"
880 "path='/org/freedesktop/systemd1/agent'",
881 signal_agent_released, m);
884 log_warning("Failed to register Released match on system bus: %s", strerror(-r));
886 log_debug("Successfully connected to system bus.");
890 static int bus_init_system(Manager *m) {
891 _cleanup_bus_unref_ sd_bus *bus = NULL;
897 /* The API and system bus is the same if we are running in system mode */
898 if (m->running_as == SYSTEMD_SYSTEM && m->api_bus) {
899 m->system_bus = sd_bus_ref(m->api_bus);
903 r = sd_bus_open_system(&bus);
905 log_debug("Failed to connect to system bus, retrying later...");
909 r = bus_setup_disconnected_match(m, bus);
913 r = sd_bus_attach_event(bus, m->event, SD_EVENT_PRIORITY_NORMAL);
915 log_error("Failed to attach system bus to event loop: %s", strerror(-r));
919 r = bus_setup_system(m, bus);
921 log_error("Fauiled to set up system bus: %s", strerror(-r));
931 static int bus_init_private(Manager *m) {
932 _cleanup_close_ int fd = -1;
933 union sockaddr_union sa = {
934 .un.sun_family = AF_UNIX
942 if (m->private_listen_fd >= 0)
945 /* We don't need the private socket if we have kdbus */
946 if (m->kdbus_fd >= 0)
949 if (m->running_as == SYSTEMD_SYSTEM) {
951 /* We want the private bus only when running as init */
955 strcpy(sa.un.sun_path, "/run/systemd/private");
956 salen = offsetof(union sockaddr_union, un.sun_path) + strlen("/run/systemd/private");
958 size_t left = sizeof(sa.un.sun_path);
959 char *p = sa.un.sun_path;
962 e = secure_getenv("XDG_RUNTIME_DIR");
964 log_error("Failed to determine XDG_RUNTIME_DIR");
968 left = strpcpy(&p, left, e);
969 left = strpcpy(&p, left, "/systemd/private");
971 salen = sizeof(sa.un) - left;
973 mkdir_parents_label(sa.un.sun_path, 0755);
976 unlink(sa.un.sun_path);
978 fd = socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0);
980 log_error("Failed to allocate private socket: %m");
984 r = bind(fd, &sa.sa, salen);
986 log_error("Failed to bind private socket: %m");
990 r = listen(fd, SOMAXCONN);
992 log_error("Failed to make private socket listening: %m");
996 r = sd_event_add_io(m->event, &s, fd, EPOLLIN, bus_on_connection, m);
998 log_error("Failed to allocate event source: %s", strerror(-r));
1002 m->private_listen_fd = fd;
1003 m->private_listen_event_source = s;
1006 log_debug("Successfully created private D-Bus server.");
1011 int bus_init(Manager *m, bool try_bus_connect) {
1014 if (try_bus_connect) {
1015 r = bus_init_system(m);
1019 r = bus_init_api(m);
1024 r = bus_init_private(m);
1031 static void destroy_bus(Manager *m, sd_bus **bus) {
1041 /* Get rid of tracked clients on this bus */
1042 if (m->subscribed && sd_bus_track_get_bus(m->subscribed) == *bus)
1043 m->subscribed = sd_bus_track_unref(m->subscribed);
1045 HASHMAP_FOREACH(j, m->jobs, i)
1046 if (j->subscribed && sd_bus_track_get_bus(j->subscribed) == *bus)
1047 j->subscribed = sd_bus_track_unref(j->subscribed);
1049 /* Get rid of queued message on this bus */
1050 if (m->queued_message_bus == *bus) {
1051 m->queued_message_bus = sd_bus_unref(m->queued_message_bus);
1053 if (m->queued_message)
1054 m->queued_message = sd_bus_message_unref(m->queued_message);
1057 /* Possibly flush unwritten data, but only if we are
1058 * unprivileged, since we don't want to sync here */
1059 if (m->running_as != SYSTEMD_SYSTEM)
1062 /* And destroy the object */
1064 *bus = sd_bus_unref(*bus);
1067 void bus_done(Manager *m) {
1073 destroy_bus(m, &m->api_bus);
1075 destroy_bus(m, &m->system_bus);
1076 while ((b = set_steal_first(m->private_buses)))
1079 set_free(m->private_buses);
1080 m->private_buses = NULL;
1082 m->subscribed = sd_bus_track_unref(m->subscribed);
1083 strv_free(m->deserialized_subscribed);
1084 m->deserialized_subscribed = NULL;
1086 if (m->private_listen_event_source)
1087 m->private_listen_event_source = sd_event_source_unref(m->private_listen_event_source);
1089 m->private_listen_fd = safe_close(m->private_listen_fd);
1092 int bus_fdset_add_all(Manager *m, FDSet *fds) {
1100 /* When we are about to reexecute we add all D-Bus fds to the
1101 * set to pass over to the newly executed systemd. They won't
1102 * be used there however, except thatt they are closed at the
1103 * very end of deserialization, those making it possible for
1104 * clients to synchronously wait for systemd to reexec by
1105 * simply waiting for disconnection */
1108 fd = sd_bus_get_fd(m->api_bus);
1110 fd = fdset_put_dup(fds, fd);
1116 SET_FOREACH(b, m->private_buses, i) {
1117 fd = sd_bus_get_fd(b);
1119 fd = fdset_put_dup(fds, fd);
1125 /* We don't offer any APIs on the system bus (well, unless it
1126 * is the same as the API bus) hence we don't bother with it
1132 int bus_foreach_bus(
1134 sd_bus_track *subscribed2,
1135 int (*send_message)(sd_bus *bus, void *userdata),
1142 /* Send to all direct busses, unconditionally */
1143 SET_FOREACH(b, m->private_buses, i) {
1144 r = send_message(b, userdata);
1149 /* Send to API bus, but only if somebody is subscribed */
1150 if (sd_bus_track_count(m->subscribed) > 0 ||
1151 sd_bus_track_count(subscribed2) > 0) {
1152 r = send_message(m->api_bus, userdata);
1160 void bus_track_serialize(sd_bus_track *t, FILE *f) {
1165 for (n = sd_bus_track_first(t); n; n = sd_bus_track_next(t))
1166 fprintf(f, "subscribed=%s\n", n);
1169 int bus_track_deserialize_item(char ***l, const char *line) {
1175 e = startswith(line, "subscribed=");
1179 return strv_extend(l, e);
1182 int bus_track_coldplug(Manager *m, sd_bus_track **t, char ***l) {
1189 if (!strv_isempty(*l) && m->api_bus) {
1193 r = sd_bus_track_new(m->api_bus, t, NULL, NULL);
1199 STRV_FOREACH(i, *l) {
1202 k = sd_bus_track_add_name(*t, *i);