diff options
Diffstat (limited to 'src/core/dbus.c')
-rw-r--r-- | src/core/dbus.c | 95 |
1 files changed, 56 insertions, 39 deletions
diff --git a/src/core/dbus.c b/src/core/dbus.c index 56b43adcda..bf5917696e 100644 --- a/src/core/dbus.c +++ b/src/core/dbus.c @@ -1,22 +1,4 @@ /* SPDX-License-Identifier: LGPL-2.1+ */ -/*** - This file is part of systemd. - - Copyright 2010 Lennart Poettering - - systemd is free software; you can redistribute it and/or modify it - 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 <errno.h> #include <sys/epoll.h> @@ -29,11 +11,22 @@ #include "bus-error.h" #include "bus-internal.h" #include "bus-util.h" +#include "dbus-automount.h" #include "dbus-cgroup.h" +#include "dbus-device.h" #include "dbus-execute.h" #include "dbus-job.h" #include "dbus-kill.h" #include "dbus-manager.h" +#include "dbus-mount.h" +#include "dbus-path.h" +#include "dbus-scope.h" +#include "dbus-service.h" +#include "dbus-slice.h" +#include "dbus-socket.h" +#include "dbus-swap.h" +#include "dbus-target.h" +#include "dbus-timer.h" #include "dbus-unit.h" #include "dbus.h" #include "fd-util.h" @@ -43,6 +36,7 @@ #include "mkdir.h" #include "process-util.h" #include "selinux-access.h" +#include "service.h" #include "special.h" #include "string-util.h" #include "strv.h" @@ -242,7 +236,6 @@ static int mac_selinux_filter(sd_bus_message *message, void *userdata, sd_bus_er path = sd_bus_message_get_path(message); if (object_path_startswith("/org/freedesktop/systemd1", path)) { - r = mac_selinux_access_check(message, verb, error); if (r < 0) return r; @@ -270,7 +263,6 @@ static int mac_selinux_filter(sd_bus_message *message, void *userdata, sd_bus_er else manager_load_unit_from_dbus_path(m, path, NULL, &u); } - if (!u) return 0; @@ -501,8 +493,7 @@ static int bus_job_enumerate(sd_bus *bus, const char *path, void *userdata, char assert(hashmap_size(m->jobs) == k); - *nodes = l; - l = NULL; + *nodes = TAKE_PTR(l); return k; } @@ -526,8 +517,7 @@ static int bus_unit_enumerate(sd_bus *bus, const char *path, void *userdata, cha k++; } - *nodes = l; - l = NULL; + *nodes = TAKE_PTR(l); return k; } @@ -897,9 +887,9 @@ int bus_init_api(Manager *m) { bus = sd_bus_ref(m->system_bus); else { if (MANAGER_IS_SYSTEM(m)) - r = sd_bus_open_system(&bus); + r = sd_bus_open_system_with_description(&bus, "bus-api-system"); else - r = sd_bus_open_user(&bus); + r = sd_bus_open_user_with_description(&bus, "bus-api-user"); if (r < 0) return log_error_errno(r, "Failed to connect to API bus: %m"); @@ -916,8 +906,7 @@ int bus_init_api(Manager *m) { if (r < 0) return log_error_errno(r, "Failed to set up API bus: %m"); - m->api_bus = bus; - bus = NULL; + m->api_bus = TAKE_PTR(bus); r = manager_enqueue_sync_bus_names(m); if (r < 0) @@ -961,7 +950,7 @@ int bus_init_system(Manager *m) { if (MANAGER_IS_SYSTEM(m) && m->api_bus) bus = sd_bus_ref(m->api_bus); else { - r = sd_bus_open_system(&bus); + r = sd_bus_open_system_with_description(&bus, "bus-system"); if (r < 0) return log_error_errno(r, "Failed to connect to system bus: %m"); @@ -978,8 +967,7 @@ int bus_init_system(Manager *m) { if (r < 0) return log_error_errno(r, "Failed to set up system bus: %m"); - m->system_bus = bus; - bus = NULL; + m->system_bus = TAKE_PTR(bus); return 0; } @@ -1105,17 +1093,11 @@ static void destroy_bus(Manager *m, sd_bus **bus) { } void bus_done_api(Manager *m) { - assert(m); - - if (m->api_bus) - destroy_bus(m, &m->api_bus); + destroy_bus(m, &m->api_bus); } void bus_done_system(Manager *m) { - assert(m); - - if (m->system_bus) - destroy_bus(m, &m->system_bus); + destroy_bus(m, &m->system_bus); } void bus_done_private(Manager *m) { @@ -1310,3 +1292,38 @@ uint64_t manager_bus_n_queued_write(Manager *m) { return c; } + +static void vtable_dump_bus_properties(FILE *f, const sd_bus_vtable *table) { + const sd_bus_vtable *i; + + for (i = table; i->type != _SD_BUS_VTABLE_END; i++) { + if (!IN_SET(i->type, _SD_BUS_VTABLE_PROPERTY, _SD_BUS_VTABLE_WRITABLE_PROPERTY) || + (i->flags & (SD_BUS_VTABLE_DEPRECATED | SD_BUS_VTABLE_HIDDEN)) != 0) + continue; + + fprintf(f, "%s\n", i->x.property.member); + } +} + +void dump_bus_properties(FILE *f) { + assert(f); + + vtable_dump_bus_properties(f, bus_automount_vtable); + vtable_dump_bus_properties(f, bus_cgroup_vtable); + vtable_dump_bus_properties(f, bus_device_vtable); + vtable_dump_bus_properties(f, bus_exec_vtable); + vtable_dump_bus_properties(f, bus_job_vtable); + vtable_dump_bus_properties(f, bus_kill_vtable); + vtable_dump_bus_properties(f, bus_manager_vtable); + vtable_dump_bus_properties(f, bus_mount_vtable); + vtable_dump_bus_properties(f, bus_path_vtable); + vtable_dump_bus_properties(f, bus_scope_vtable); + vtable_dump_bus_properties(f, bus_service_vtable); + vtable_dump_bus_properties(f, bus_slice_vtable); + vtable_dump_bus_properties(f, bus_socket_vtable); + vtable_dump_bus_properties(f, bus_swap_vtable); + vtable_dump_bus_properties(f, bus_target_vtable); + vtable_dump_bus_properties(f, bus_timer_vtable); + vtable_dump_bus_properties(f, bus_unit_vtable); + vtable_dump_bus_properties(f, bus_unit_cgroup_vtable); +} |