#1146047 Xorg fails to get its own session

Package:
elogind
Source:
elogind
Description:
user, seat and session management daemon
Submitter:
Abasileuton Ltd
Date:
2026-08-29 12:25:02 UTC
Severity:
normal
#1146047#5
Date:
2026-08-29 11:07:30 UTC
From:
To:
Dear maintainers,

I hope this bug report finds you well!

Elogind stopped working with Xorg since trixie.
The relevant line in Xorg.0.log says:

[...] (EE) systemd-logind: failed to get session: PID ... does not
belong to any known session

I managed to track the issue down to your patch
for using systemd-compatible cgroups.

The issue is due to missing logic in elogind
compared to what systemd's logind does.
In particular, when the function
"manager_get_session_by_pidref"
calls the function "cg_pidref_get_unit",
the returned hashtable is always empty.

I can confirm that Xorg works as expected
both with systemd's logind
and with elogind after removing this patch.

The problem is triggered only because Xorg
calls the dbus interface method "GetSessionByPID"
passing its own PID as argument.
If it were to call "GetSession"
or, even, call "GetSessionByPID" with an argument of zero
instead of its own PID,
the code path in elogind that calls
"manager_get_session_by_pidref" is not traversed.

After testing, I can confirm that,
if one change the source code of Xorg to pass zero as argument,
all works as expected.

Now, I can suggest to you three solutions:

(i)	Stop using the patch
	"Use-libsystemd0-compatible-cgroups-layout.patch"
(ii)	File a bug against Xorg
	to use "GetSession" instead of "GetSessionByPID"
(iii)	Implement, in elogind, the missing bits that systemd has.

The easiest solution is (i),
but I guess you want to link against
libsystemd0 in Debian,
so this may not be an option.

Meanwhile, I doubt anyone could convince upstream Xorg
to make this change,
since it is not really a bug in Xorg.
So (ii) is probably only an option
if one were to add a patch to the Debian xserver-xorg package.

And (iii) seems like quite a bit of work,
though I might be able to help if you choose this option.

Yours faithfully,
B.R.S. Roso,
Abasileuton Ltd.

#1146047#8
Date:
2026-08-29 11:28:32 UTC
From:
To:
Hi,

Thanks for this.

Your analysis here is pretty close to my thinking. I am reluctant to remove the
patch in (i) as it would mean going back to having to keep the libelogind0 and
libsystemd0 ABIs in sync. That was always problematic with variable levels of
activity upstream. Even now Debian systemd is 261.2 and elogind upstream is at
257.16.

(ii) also seems unlikely for the reasons you identify.

So, (iii) is the way to go, irrespective of the work.

Mark

#1146047#11
Date:
2026-08-29 12:22:45 UTC
From:
To:
manager_get_session_by_pidref() are misplaced. Reverting them to elogind
upstream at least passes a compile test. I'll have to set up a test
environment. But you might want to try the attached patch.

Mark

commit 83b0ef382d2d043a58107862d0917b40e02cf8ca
Author: Mark Hindley <mark@hindley.org.uk>
Date:   Sat Aug 29 13:10:18 2026 +0100

    Drop changes in manager_get_session_by_pidref.

diff --git a/debian/patches/Use-libsystemd0-compatible-cgroups-layout.patch b/debian/patches/Use-libsystemd0-compatible-cgroups-layout.patch
index 7955fe73ec..9dcec5eac6 100644
--- a/debian/patches/Use-libsystemd0-compatible-cgroups-layout.patch
+++ b/debian/patches/Use-libsystemd0-compatible-cgroups-layout.patch
@@ -404,54 +404,6 @@ index 80c3282..40bc721 100644

  int unit_name_build(const char *prefix, const char *instance, const char *suffix, char **ret);
  int unit_name_build_from_type(const char *prefix, const char *instance, UnitType, char **ret);
-diff --git a/src/login/logind-core.c b/src/login/logind-core.c
-index 7807a49..63d2112 100644
---- a/src/login/logind-core.c
-+++ b/src/login/logind-core.c
-@@ -372,11 +372,11 @@ int manager_process_button_device(Manager *m, sd_device *d) {
- }
-
- int manager_get_session_by_pidref(Manager *m, const PidRef *pid, Session **ret) {
--#if 0 /// elogind does not support systemd units, but its own session system
-+#if LIBSYSTEMD_COMPATIBLE_CGROUPS /// elogind does not support systemd units, but its own session system
-         _cleanup_free_ char *unit = NULL;
--#else // 0
-+#else // LIBSYSTEMD_COMPATIBLE_CGROUPS
-         _cleanup_free_ char *session_name = NULL;
--#endif // 0
-+#endif // LIBSYSTEMD_COMPATIBLE_CGROUPS
-         Session *s;
-         int r;
-
-@@ -385,13 +385,14 @@ int manager_get_session_by_pidref(Manager *m, const PidRef *pid, Session **ret)
-         if (!pidref_is_set(pid))
-                 return -EINVAL;
-
-+
-         s = hashmap_get(m->sessions_by_leader, pid);
-         if (s) {
--                r = pidref_verify(pid);
--                if (r < 0)
--                        return r;
--        } else {
--#if 0 /// elogind does not support systemd units, but its own session system
-+               r = pidref_verify(pid);
-+               if (r < 0)
-+                       return r;
-+       } else  {
-+#ifdef LIBSYSTEMD_COMPATIBLE_CGROUPS /// elogind does not support systemd units, but its own session system
-                 r = cg_pidref_get_unit(pid, &unit);
-                 if (r >= 0)
-                         s = hashmap_get(m->session_units, unit);
-@@ -404,7 +405,7 @@ int manager_get_session_by_pidref(Manager *m, const PidRef *pid, Session **ret)
-
-                 log_debug_elogind("Session Name \"%s\" -> Session \"%s\"",
-                                   strnull(session_name), s && s->id ? s->id : "(null)");
--#endif // 0
-+#endif // LIBSYSTEMD_COMPATIBLE_CGROUPS
-         }
-
-         if (ret)
 diff --git a/src/login/logind-session.c b/src/login/logind-session.c
 index 4a2cde9..b13ddb4 100644
 --- a/src/login/logind-session.c