]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
cgroup-util: add remoteness checks to all cg_pidref_get_xyz() calls 35839/head
authorLennart Poettering <lennart@poettering.net>
Mon, 6 Jan 2025 08:54:13 +0000 (09:54 +0100)
committerLennart Poettering <lennart@poettering.net>
Mon, 6 Jan 2025 08:54:41 +0000 (09:54 +0100)
src/basic/cgroup-util.c
src/test/test-cgroup-util.c

index 9d41db288344b2b10ed88acd1f6ecda3d02550b6..25dcab91fc59a16019d3a605799c9a4c590dec5d 100644 (file)
@@ -839,6 +839,8 @@ int cg_pidref_get_path(const char *controller, const PidRef *pidref, char **ret_
 
         if (!pidref_is_set(pidref))
                 return -ESRCH;
+        if (pidref_is_remote(pidref))
+                return -EREMOTE;
 
         r = cg_pid_get_path(controller, pidref->pid, &path);
         if (r < 0)
@@ -1204,6 +1206,8 @@ int cg_pidref_get_unit(const PidRef *pidref, char **ret) {
 
         if (!pidref_is_set(pidref))
                 return -ESRCH;
+        if (pidref_is_remote(pidref))
+                return -EREMOTE;
 
         r = cg_pid_get_unit(pidref->pid, &unit);
         if (r < 0)
index 9fa3ddf9d13dd5c10ed086030c3bd42a15c1a7db..0170cb279bf915431b886d5761e70af34416cd19 100644 (file)
@@ -210,11 +210,11 @@ TEST(proc) {
                 if (pidref_is_kernel_thread(&pid) != 0)
                         continue;
 
-                cg_pid_get_path(SYSTEMD_CGROUP_CONTROLLER, pid.pid, &path);
+                cg_pidref_get_path(SYSTEMD_CGROUP_CONTROLLER, &pid, &path);
                 cg_pid_get_path_shifted(pid.pid, NULL, &path_shifted);
                 cg_pidref_get_owner_uid(&pid, &uid);
                 cg_pidref_get_session(&pid, &session);
-                cg_pid_get_unit(pid.pid, &unit);
+                cg_pidref_get_unit(&pid, &unit);
                 cg_pid_get_user_unit(pid.pid, &user_unit);
                 cg_pid_get_machine_name(pid.pid, &machine);
                 cg_pid_get_slice(pid.pid, &slice);