From b027767dc65d3e9abe48f59b527370dcacc86dcadde6fc99b3fa59c68cf3343f Mon Sep 17 00:00:00 2001 From: Bernhard Voelker Date: Wed, 20 Sep 2023 07:05:48 +0000 Subject: [PATCH] Accepting request 1111796 from home:berny:branches:Base:System - gnulib-readutmp-under-gdm.patch: Add upstream gnulib patch to fix crash of who/uptime when gdm is in use. [bsc#1215361] - gnulib-readutmp.patch: Update with upstream patch. OBS-URL: https://build.opensuse.org/request/show/1111796 OBS-URL: https://build.opensuse.org/package/show/Base:System/coreutils?expand=0&rev=354 --- coreutils.changes | 7 +++++++ coreutils.spec | 6 +++++- gnulib-readutmp-under-gdm.patch | 35 +++++++++++++++++++++++++++++++++ gnulib-readutmp.patch | 32 +++++++++++++++++++++++++++++- 4 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 gnulib-readutmp-under-gdm.patch diff --git a/coreutils.changes b/coreutils.changes index 4051060..61aad6d 100644 --- a/coreutils.changes +++ b/coreutils.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Sun Sep 17 16:15:24 UTC 2023 - Bernhard Voelker + +- gnulib-readutmp-under-gdm.patch: Add upstream gnulib patch to fix crash + of who/uptime when gdm is in use. [bsc#1215361] +- gnulib-readutmp.patch: Update with upstream patch. + ------------------------------------------------------------------- Thu Aug 31 09:56:48 UTC 2023 - Thorsten Kukuk diff --git a/coreutils.spec b/coreutils.spec index 95d6c20..405a12c 100644 --- a/coreutils.spec +++ b/coreutils.spec @@ -50,9 +50,12 @@ Patch100: coreutils-build-timeout-as-pie.patch Patch112: coreutils-getaddrinfo.patch # Assorted fixes Patch113: coreutils-misc.patch -# gnulib seg.faults if there is no session +# Upstream gnulib commits (squashed) to fix gnulib seg.faults +# if there is no session: # https://debbugs.gnu.org/cgi/bugreport.cgi?bug=65617 Patch114: gnulib-readutmp.patch +# Upstream gnulib patch to fix crash when gdm is in use. [bsc#1215361] +Patch115: gnulib-readutmp-under-gdm.patch # Skip 2 valgrind'ed sort tests on ppc/ppc64 which would fail due to # a glibc issue in mkstemp. Patch300: coreutils-skip-some-sort-tests-on-ppc.patch @@ -155,6 +158,7 @@ This package contains the documentation for the GNU Core Utilities. %patch112 %patch113 %patch114 -p1 +%patch115 -p1 %patch300 diff --git a/gnulib-readutmp-under-gdm.patch b/gnulib-readutmp-under-gdm.patch new file mode 100644 index 0000000..711cde3 --- /dev/null +++ b/gnulib-readutmp-under-gdm.patch @@ -0,0 +1,35 @@ +Upstream gnulib patch to fix crash when gdm is in use. [bsc#1215361] + +From 579f2d6f3d1d817c2f7e2c603c9a3ded63dcaa92 Mon Sep 17 00:00:00 2001 +From: Bruno Haible +Date: Fri, 15 Sep 2023 17:40:10 +0200 +Subject: [PATCH] readutmp: Fix crash when gdm is in use. + +Reported by Thorsten Kukuk in +. + +* lib/readutmp.c (read_utmp_from_systemd): Don't use the value returned +by sd_session_get_display if it is NULL. +--- + lib/readutmp.c | 5 ++++- + 1 files changed, 4 insertions(+), 1 deletion(-) + +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 +-- +2.42.0 + diff --git a/gnulib-readutmp.patch b/gnulib-readutmp.patch index e1bf4f9..acf7d1d 100644 --- a/gnulib-readutmp.patch +++ b/gnulib-readutmp.patch @@ -1,3 +1,30 @@ +This squashes 2 consecutive upstream gnulib commits +to fix gnulib seg.faults if there is no session: + +https://debbugs.gnu.org/cgi/bugreport.cgi?bug=65617 + +Upstream gnulib commit 3af1d7b0ce3a8e3ae565e7cea10cee6fd7cb8109 + +2023-08-31 Bruno Haible + + readutmp: Fix memory leak introduced by last commit. + * lib/readutmp.c (read_utmp_from_systemd): If num_sessions == 0 and + sessions != NULL, do call free (sessions). + +Upstream gnulib commit 1e6a26f9312bb47e070f94b17b14dc1a6ffbb74f + +2023-08-30 Paul Eggert + + readutmp: fix core dump if --enable-systemd + Problem reported by Thorsten Kukuk . + * lib/readutmp.c (read_utmp_from_systemd): + Don’t assume session_ptr != NULL if num_sessions == 0. + In practice it can be null, and the man page OKs this behavior. + +--- + lib/readutmp.c | 2 +- + 1 files changed, 1 insertions(+), 1 deletion(-) + diff --git a/lib/readutmp.c b/lib/readutmp.c index 0173b7e0c1..e99158677c 100644 --- a/lib/readutmp.c @@ -7,7 +34,10 @@ index 0173b7e0c1..e99158677c 100644 char **sessions; int num_sessions = sd_get_sessions (&sessions); - if (num_sessions >= 0) -+ if (num_sessions > 0) ++ if (num_sessions >= 0 && sessions != NULL) { char **session_ptr; for (session_ptr = sessions; *session_ptr != NULL; session_ptr++) +-- +2.42.0 +