bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: who/uptime segfaults if DISPLAY=:0 is missing in logind session


From: Bruno Haible
Subject: Re: who/uptime segfaults if DISPLAY=:0 is missing in logind session
Date: Fri, 15 Sep 2023 17:47:07 +0200

Thorsten Kukuk wrote:
> Create a file with the content I did add to the report in
> /run/systemd/session and call who.

Oh, I see. That's indeed a nice trick to force libsystemd to return specific
values.

Thanks. With this I reproduce it (on an arbitrary machine with systemd ≥ 254,
with libsystemd installed, and with coreutils configured with --enable-systemd).

I'm pushing this fix (equivalent to yours).


2023-09-15  Bruno Haible  <bruno@clisp.org>

        readutmp: Fix crash when gdm is in use.
        Reported by Thorsten Kukuk <kukuk@suse.com> in
        <https://lists.gnu.org/archive/html/bug-gnulib/2023-09/msg00093.html>.
        * lib/readutmp.c (read_utmp_from_systemd): Don't use the value returned
        by sd_session_get_display if it is NULL.

diff --git a/lib/readutmp.c b/lib/readutmp.c
index ec09feb59b..d8213e7ad5 100644
--- a/lib/readutmp.c
+++ b/lib/readutmp.c
@@ -873,7 +873,10 @@ read_utmp_from_systemd (idx_t *n_entries, STRUCT_UTMP 
**utmp_buf, int options)
                           char *display;
                           if (sd_session_get_display (session, &display) < 0)
                             display = NULL;
-                          host = display;
+                          /* Workaround: gdm "forgets" to pass the display to
+                             systemd, thus display may be NULL here.  */
+                          if (display != NULL)
+                            host = display;
                         }
                     }
                   else






reply via email to

[Prev in Thread] Current Thread [Next in Thread]