summaryrefslogtreecommitdiffstats
path: root/src/core/unit.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2023-10-17 10:17:49 +0200
committerLennart Poettering <lennart@poettering.net>2023-10-18 14:39:33 +0200
commita7a877697f07d764b12694316917aa1dc6ff64fb (patch)
tree3ef9778396fa0313cbea2bbc45275f7631da8fae /src/core/unit.c
parentprocess-util: add pidref_get_comm() and rename get_process_comm() to pid_get_... (diff)
downloadsystemd-a7a877697f07d764b12694316917aa1dc6ff64fb.tar.xz
systemd-a7a877697f07d764b12694316917aa1dc6ff64fb.zip
pidref: add new pidref_is_self() helper
This simply checks if the specified PidRef refers to the process we are running in. (In case you wonder why this is not a static inline: to avoid cyclic header inclusion problems between pidref.h + process-util.h)
Diffstat (limited to 'src/core/unit.c')
-rw-r--r--src/core/unit.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/core/unit.c b/src/core/unit.c
index 507d350e7e..4300f18d9b 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -5949,7 +5949,7 @@ int unit_pid_attachable(Unit *u, PidRef *pid, sd_bus_error *error) {
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Process identifier is not valid.");
/* Some extra safety check */
- if (pid->pid == 1 || pid->pid == getpid_cached())
+ if (pid->pid == 1 || pidref_is_self(pid))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Process " PID_FMT " is a manager process, refusing.", pid->pid);
/* Don't even begin to bother with kernel threads */