mirror of
https://github.com/morgan9e/systemd
synced 2026-04-15 08:56:15 +09:00
core-varlink: switch to PidRef + manager_get_unit_by_pidref()
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
#include "varlink-internal.h"
|
||||
#include "varlink-io.systemd.UserDatabase.h"
|
||||
#include "varlink-io.systemd.ManagedOOM.h"
|
||||
#include "varlink-util.h"
|
||||
|
||||
typedef struct LookupParameters {
|
||||
const char *user_name;
|
||||
@@ -218,19 +219,18 @@ static int vl_method_subscribe_managed_oom_cgroups(
|
||||
sd_varlink_method_flags_t flags,
|
||||
void *userdata) {
|
||||
|
||||
_cleanup_(sd_json_variant_unrefp) sd_json_variant *v = NULL;
|
||||
Manager *m = ASSERT_PTR(userdata);
|
||||
pid_t pid;
|
||||
_cleanup_(pidref_done) PidRef pidref = PIDREF_NULL;
|
||||
Unit *u;
|
||||
int r;
|
||||
|
||||
assert(link);
|
||||
|
||||
r = sd_varlink_get_peer_pid(link, &pid);
|
||||
r = varlink_get_peer_pidref(link, &pidref);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
u = manager_get_unit_by_pid(m, pid);
|
||||
u = manager_get_unit_by_pidref(m, &pidref);
|
||||
if (!u)
|
||||
return sd_varlink_error(link, SD_VARLINK_ERROR_PERMISSION_DENIED, NULL);
|
||||
|
||||
@@ -247,6 +247,8 @@ static int vl_method_subscribe_managed_oom_cgroups(
|
||||
if (FLAGS_SET(flags, SD_VARLINK_METHOD_MORE) && m->managed_oom_varlink)
|
||||
return sd_varlink_error(link, "io.systemd.ManagedOOM.SubscriptionTaken", NULL);
|
||||
|
||||
_cleanup_(sd_json_variant_unrefp) sd_json_variant *v = NULL;
|
||||
|
||||
r = build_managed_oom_cgroups_json(m, &v);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
Reference in New Issue
Block a user