]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
logind: do not fail creating a session when request is not from a unit 32934/head
authorLuca Boccassi <bluca@debian.org>
Mon, 20 May 2024 12:12:03 +0000 (13:12 +0100)
committerLuca Boccassi <bluca@debian.org>
Mon, 20 May 2024 12:14:50 +0000 (13:14 +0100)
When running inside an LXC container the 'su' process will not be part of
any unit or slice.

manager_get_user_by_pid() which was used until v255 (included) does not fail
if it cannot find a unit/slice, but simply returns 'not found'. Do the same
in manager_get_session_by_pidref().

This was not detected as Semaphore CI does not reboot the testbed before
the logind test, so the session is started by the old logind from the base
distro, instead of the one being tested.

Follow-up for 8494f562c8963d8a936b0598e23eab277ff29374
Follow-up for 5099a50d4398e190387d204f5df81cc176bd33e2

Fixes https://github.com/systemd/systemd/issues/32929

src/login/logind-core.c

index d20ff3d4d485c5822091e5759027062fd2cee970..71e4247a7991c7bbd8a96f6361aa3f9a383782f0 100644 (file)
@@ -371,10 +371,8 @@ int manager_get_session_by_pidref(Manager *m, const PidRef *pid, Session **ret)
                         return r;
         } else {
                 r = cg_pidref_get_unit(pid, &unit);
-                if (r < 0)
-                        return r;
-
-                s = hashmap_get(m->session_units, unit);
+                if (r >= 0)
+                        s = hashmap_get(m->session_units, unit);
         }
 
         if (ret)