]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: fix manager_get_unit_by_pid() special casing of manager PID
authorLennart Poettering <lennart@poettering.net>
Thu, 11 Jan 2018 22:38:46 +0000 (23:38 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 23 Jan 2018 20:22:50 +0000 (21:22 +0100)
Previously, we'd hard map PID 1 to the manager scope unit. That's wrong
however when we are run in --user mode, as the PID 1 is outside of the
subtree we manage and the manager PID might be very differently. Correct
that by checking for getpid() rather than hardcoding 1.

src/core/cgroup.c

index c2c4ef1b428c8d15bde6004929b5aabcf71f8136..b3cd12000e0f5385b1fc28ae8fd82d41774c51a5 100644 (file)
@@ -2183,7 +2183,7 @@ Unit *manager_get_unit_by_pid(Manager *m, pid_t pid) {
         if (pid <= 0)
                 return NULL;
 
-        if (pid == 1)
+        if (pid == getpid_cached())
                 return hashmap_get(m->units, SPECIAL_INIT_SCOPE);
 
         u = hashmap_get(m->watch_pids1, PID_TO_PTR(pid));