From: Yu Watanabe Date: Tue, 8 Oct 2024 21:08:11 +0000 (+0900) Subject: core/dbus: move bus_verify_xyz() to dbus-util.c X-Git-Tag: v257-rc1~287^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d0309467650be331362ec4196d720a791e3e7c23;p=thirdparty%2Fsystemd.git core/dbus: move bus_verify_xyz() to dbus-util.c --- diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c index 91c10a4e00c..3538296d64b 100644 --- a/src/core/dbus-manager.c +++ b/src/core/dbus-manager.c @@ -22,6 +22,7 @@ #include "dbus-scope.h" #include "dbus-service.h" #include "dbus-unit.h" +#include "dbus-util.h" #include "dbus.h" #include "env-util.h" #include "fd-util.h" diff --git a/src/core/dbus-util.c b/src/core/dbus-util.c index b871d893682..28cb095cb27 100644 --- a/src/core/dbus-util.c +++ b/src/core/dbus-util.c @@ -177,6 +177,50 @@ int bus_verify_manage_units_async_full( error); } +int bus_verify_manage_units_async(Manager *m, sd_bus_message *call, sd_bus_error *error) { + return bus_verify_polkit_async( + call, + "org.freedesktop.systemd1.manage-units", + /* details= */ NULL, + &m->polkit_registry, + error); +} + +int bus_verify_manage_unit_files_async(Manager *m, sd_bus_message *call, sd_bus_error *error) { + return bus_verify_polkit_async( + call, + "org.freedesktop.systemd1.manage-unit-files", + /* details= */ NULL, + &m->polkit_registry, + error); +} + +int bus_verify_reload_daemon_async(Manager *m, sd_bus_message *call, sd_bus_error *error) { + return bus_verify_polkit_async( + call, + "org.freedesktop.systemd1.reload-daemon", + /* details= */ NULL, + &m->polkit_registry, error); +} + +int bus_verify_set_environment_async(Manager *m, sd_bus_message *call, sd_bus_error *error) { + return bus_verify_polkit_async( + call, + "org.freedesktop.systemd1.set-environment", + /* details= */ NULL, + &m->polkit_registry, + error); +} + +int bus_verify_bypass_dump_ratelimit_async(Manager *m, sd_bus_message *call, sd_bus_error *error) { + return bus_verify_polkit_async( + call, + "org.freedesktop.systemd1.bypass-dump-ratelimit", + /* details= */ NULL, + &m->polkit_registry, + error); +} + /* ret_format_str is an accumulator, so if it has any pre-existing content, new options will be appended to it */ int bus_read_mount_options( sd_bus_message *message, diff --git a/src/core/dbus-util.h b/src/core/dbus-util.h index 0fc3a949610..5eb4e836c72 100644 --- a/src/core/dbus-util.h +++ b/src/core/dbus-util.h @@ -250,7 +250,13 @@ static inline int bus_set_transient_usec(Unit *u, const char *name, usec_t *p, s static inline int bus_set_transient_usec_fix_0(Unit *u, const char *name, usec_t *p, sd_bus_message *message, UnitWriteFlags flags, sd_bus_error *error) { return bus_set_transient_usec_internal(u, name, p, true, message, flags, error); } + int bus_verify_manage_units_async_full(Unit *u, const char *verb, const char *polkit_message, sd_bus_message *call, sd_bus_error *error); +int bus_verify_manage_units_async(Manager *m, sd_bus_message *call, sd_bus_error *error); +int bus_verify_manage_unit_files_async(Manager *m, sd_bus_message *call, sd_bus_error *error); +int bus_verify_reload_daemon_async(Manager *m, sd_bus_message *call, sd_bus_error *error); +int bus_verify_set_environment_async(Manager *m, sd_bus_message *call, sd_bus_error *error); +int bus_verify_bypass_dump_ratelimit_async(Manager *m, sd_bus_message *call, sd_bus_error *error); int bus_read_mount_options(sd_bus_message *message, sd_bus_error *error, MountOptions **ret_options, char **ret_format_str, const char *separator); diff --git a/src/core/dbus.c b/src/core/dbus.c index b6480937ee1..2692dde1518 100644 --- a/src/core/dbus.c +++ b/src/core/dbus.c @@ -1172,49 +1172,6 @@ int bus_track_coldplug(Manager *m, sd_bus_track **t, bool recursive, char **l) { return bus_track_add_name_many(*t, l); } -int bus_verify_manage_units_async(Manager *m, sd_bus_message *call, sd_bus_error *error) { - return bus_verify_polkit_async( - call, - "org.freedesktop.systemd1.manage-units", - /* details= */ NULL, - &m->polkit_registry, - error); -} - -int bus_verify_manage_unit_files_async(Manager *m, sd_bus_message *call, sd_bus_error *error) { - return bus_verify_polkit_async( - call, - "org.freedesktop.systemd1.manage-unit-files", - /* details= */ NULL, - &m->polkit_registry, - error); -} - -int bus_verify_reload_daemon_async(Manager *m, sd_bus_message *call, sd_bus_error *error) { - return bus_verify_polkit_async( - call, - "org.freedesktop.systemd1.reload-daemon", - /* details= */ NULL, - &m->polkit_registry, error); -} - -int bus_verify_set_environment_async(Manager *m, sd_bus_message *call, sd_bus_error *error) { - return bus_verify_polkit_async( - call, - "org.freedesktop.systemd1.set-environment", - /* details= */ NULL, - &m->polkit_registry, - error); -} -int bus_verify_bypass_dump_ratelimit_async(Manager *m, sd_bus_message *call, sd_bus_error *error) { - return bus_verify_polkit_async( - call, - "org.freedesktop.systemd1.bypass-dump-ratelimit", - /* details= */ NULL, - &m->polkit_registry, - error); -} - uint64_t manager_bus_n_queued_write(Manager *m) { uint64_t c = 0; sd_bus *b; diff --git a/src/core/dbus.h b/src/core/dbus.h index ae754040761..d00c14d3b72 100644 --- a/src/core/dbus.h +++ b/src/core/dbus.h @@ -23,12 +23,6 @@ int bus_track_coldplug(Manager *m, sd_bus_track **t, bool recursive, char **l); int bus_foreach_bus(Manager *m, sd_bus_track *subscribed2, int (*send_message)(sd_bus *bus, void *userdata), void *userdata); -int bus_verify_manage_units_async(Manager *m, sd_bus_message *call, sd_bus_error *error); -int bus_verify_manage_unit_files_async(Manager *m, sd_bus_message *call, sd_bus_error *error); -int bus_verify_reload_daemon_async(Manager *m, sd_bus_message *call, sd_bus_error *error); -int bus_verify_set_environment_async(Manager *m, sd_bus_message *call, sd_bus_error *error); -int bus_verify_bypass_dump_ratelimit_async(Manager *m, sd_bus_message *call, sd_bus_error *error); - int bus_forward_agent_released(Manager *m, const char *path); uint64_t manager_bus_n_queued_write(Manager *m);