diff options
author | Mike Yuan <me@yhndnzj.com> | 2024-05-14 18:41:06 +0200 |
---|---|---|
committer | Mike Yuan <me@yhndnzj.com> | 2024-05-14 18:46:06 +0200 |
commit | cd711b6ec93928331e2770b59f67fb907d16e4fa (patch) | |
tree | afad5008fc366f26bb249eb62a317ef815e9e101 /src/core/core-varlink.c | |
parent | core/varlink: use FOREACH_ELEMENT more (diff) | |
download | systemd-cd711b6ec93928331e2770b59f67fb907d16e4fa.tar.xz systemd-cd711b6ec93928331e2770b59f67fb907d16e4fa.zip |
core/varlink: make manager_setup_varlink_server static
Follow-up for 6906c028e83b77b35eaaf87b27d0fe5c6e1984b7
Also, use correct log level for varlink_server_add_interface_many().
Diffstat (limited to 'src/core/core-varlink.c')
-rw-r--r-- | src/core/core-varlink.c | 74 |
1 files changed, 37 insertions, 37 deletions
diff --git a/src/core/core-varlink.c b/src/core/core-varlink.c index 4e03d83975..3e6168d912 100644 --- a/src/core/core-varlink.c +++ b/src/core/core-varlink.c @@ -500,6 +500,43 @@ static void vl_disconnect(VarlinkServer *s, Varlink *link, void *userdata) { m->managed_oom_varlink = varlink_unref(link); } +static int manager_setup_varlink_server(Manager *m, VarlinkServer **ret) { + _cleanup_(varlink_server_unrefp) VarlinkServer *s = NULL; + int r; + + assert(m); + assert(ret); + + r = varlink_server_new(&s, VARLINK_SERVER_ACCOUNT_UID|VARLINK_SERVER_INHERIT_USERDATA); + if (r < 0) + return log_debug_errno(r, "Failed to allocate varlink server object: %m"); + + varlink_server_set_userdata(s, m); + + r = varlink_server_add_interface_many( + s, + &vl_interface_io_systemd_UserDatabase, + &vl_interface_io_systemd_ManagedOOM); + if (r < 0) + return log_debug_errno(r, "Failed to add interfaces to varlink server: %m"); + + r = varlink_server_bind_method_many( + s, + "io.systemd.UserDatabase.GetUserRecord", vl_method_get_user_record, + "io.systemd.UserDatabase.GetGroupRecord", vl_method_get_group_record, + "io.systemd.UserDatabase.GetMemberships", vl_method_get_memberships, + "io.systemd.ManagedOOM.SubscribeManagedOOMCGroups", vl_method_subscribe_managed_oom_cgroups); + if (r < 0) + return log_debug_errno(r, "Failed to register varlink methods: %m"); + + r = varlink_server_bind_disconnect(s, vl_disconnect); + if (r < 0) + return log_debug_errno(r, "Failed to register varlink disconnect handler: %m"); + + *ret = TAKE_PTR(s); + return 0; +} + static int manager_varlink_init_system(Manager *m) { _cleanup_(varlink_server_unrefp) VarlinkServer *s = NULL; int r; @@ -606,43 +643,6 @@ static int manager_varlink_init_user(Manager *m) { return 1; } -int manager_setup_varlink_server(Manager *m, VarlinkServer **ret) { - _cleanup_(varlink_server_unrefp) VarlinkServer *s = NULL; - int r; - - assert(m); - assert(ret); - - r = varlink_server_new(&s, VARLINK_SERVER_ACCOUNT_UID|VARLINK_SERVER_INHERIT_USERDATA); - if (r < 0) - return log_debug_errno(r, "Failed to allocate varlink server object: %m"); - - varlink_server_set_userdata(s, m); - - r = varlink_server_add_interface_many( - s, - &vl_interface_io_systemd_UserDatabase, - &vl_interface_io_systemd_ManagedOOM); - if (r < 0) - return log_error_errno(r, "Failed to add interfaces to varlink server: %m"); - - r = varlink_server_bind_method_many( - s, - "io.systemd.UserDatabase.GetUserRecord", vl_method_get_user_record, - "io.systemd.UserDatabase.GetGroupRecord", vl_method_get_group_record, - "io.systemd.UserDatabase.GetMemberships", vl_method_get_memberships, - "io.systemd.ManagedOOM.SubscribeManagedOOMCGroups", vl_method_subscribe_managed_oom_cgroups); - if (r < 0) - return log_debug_errno(r, "Failed to register varlink methods: %m"); - - r = varlink_server_bind_disconnect(s, vl_disconnect); - if (r < 0) - return log_debug_errno(r, "Failed to register varlink disconnect handler: %m"); - - *ret = TAKE_PTR(s); - return 0; -} - int manager_varlink_init(Manager *m) { return MANAGER_IS_SYSTEM(m) ? manager_varlink_init_system(m) : manager_varlink_init_user(m); } |