Package: procps
Followup-For: Bug #1152188
X-Debbugs-Cc: [email protected]

With slight modification I imported commit 7425a392 on 4.0.4-9 for
Trixie - confirmed it works as expected.

I've created a debdiff and attaching it here.
diff -Nru procps-4.0.4/debian/changelog procps-4.0.4/debian/changelog
--- procps-4.0.4/debian/changelog       2025-07-30 11:58:40.000000000 +0000
+++ procps-4.0.4/debian/changelog       2026-10-26 16:38:10.000000000 +0000
@@ -1,3 +1,9 @@
+procps (2:4.0.4-9.1) trixie; urgency=medium
+
+  * Fix w -t -p SIGSEGV (Closes: 1152188) 
+
+ -- Tj <[email protected]>  Mon, 26 Oct 2026 16:38:10 +0000
+
 procps (2:4.0.4-9) unstable; urgency=medium
 
   [ Craig Small ]
diff -Nru procps-4.0.4/debian/patches/series procps-4.0.4/debian/patches/series
--- procps-4.0.4/debian/patches/series  2025-07-30 11:58:40.000000000 +0000
+++ procps-4.0.4/debian/patches/series  2026-10-26 16:34:21.000000000 +0000
@@ -22,3 +22,4 @@
 sysctl_conf5_update
 library_use_clock_gettime
 w_sessions_without_sd
+w_do_not_crash_with-pt
diff -Nru procps-4.0.4/debian/patches/w_do_not_crash_with-pt 
procps-4.0.4/debian/patches/w_do_not_crash_with-pt
--- procps-4.0.4/debian/patches/w_do_not_crash_with-pt  1970-01-01 
00:00:00.000000000 +0000
+++ procps-4.0.4/debian/patches/w_do_not_crash_with-pt  2026-10-26 
16:38:10.000000000 +0000
@@ -0,0 +1,80 @@
+Description: w: Do not crash with -pt
+ w in terminal mode may not have a sd_session leader which made
+ it try to find the ut_pid in the utmp entry, except that was
+ often NULL, causing a crash.
+ .   
+ Now we will only use that backup if the utmp entry is present.
+ Thanks to @jaredmauch for the small patch!
+ .   
+ Also, expect is quite happy to have a subprocess crash and returns 0
+ Have to use the badly-documented exp_wait or wait function to check
+ I don't even know what the extended variable names are, hence the
+ x and y names.
+Author: Craig Small <[email protected]>
+Origin: upstream, 
https://gitlab.com/procps-ng/procps/-/commit/7425a3929cc80885dba77237a17fe472eed4b88a
+Bug: https://gitlab.com/procps-ng/procps/-/work_items/407
+Applied-Upstream: 4.0.6
+Last-Update: 2026-10-26
+---
+This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
+--- a/src/w.c
++++ b/src/w.c
+@@ -1,7 +1,7 @@
+ /*
+  * w - show what logged in users are doing.
+  *
+- * Copyright © 2009-2025 Craig Small <[email protected]>
++ * Copyright © 2009-2026 Craig Small <[email protected]>
+  * Copyright © 2011-2023 Jim Warner <[email protected]>
+  * Copyright © 2011-2012 Sami Kerola <[email protected]>
+  * Copyright © 2002-2006 Albert Cahalan
+@@ -866,7 +866,7 @@
+ #if (defined(WITH_SYSTEMD) || defined(WITH_ELOGIND)) && 
defined(HAVE_SD_SESSION_GET_LEADER)
+         sd_session_get_leader(session, &ut_pid);
+ #endif
+-        if (ut_pid == -1)
++        if (ut_pid == -1 && u != NULL)
+             ut_pid = u->ut_pid;
+         pids_length = printf(" %6d/%6d", ut_pid, last_pid);
+         if (pids_length > maxcmd) {
+--- a/testsuite/config/unix.exp
++++ b/testsuite/config/unix.exp
+@@ -146,8 +146,11 @@
+ }
+ 
+ proc expect_spawn_retval { test retval } {
+-    foreach {pid spawnid os_error_flag value} [wait] break
++    foreach {pid spawnid os_error_flag value x y} [wait] break
+ 
++    if {$y != "" } {
++        fail "$test (subprocess returned $y)"
++    }
+     if {$value == $retval} {
+       return
+     }
+--- a/testsuite/w.test/w.exp
++++ b/testsuite/w.test/w.exp
+@@ -17,12 +17,12 @@
+ set w_idle  "\(\\?xdm\\?\|\\?\|\\d+days\|\\d+:\\d+m?\|\\d+.\\d+s\)"
+ set w_ival7  "\(\\?\|\\d+days\|\\d+:\\d+m?\|\\d+.\\d+s\)"
+ set w_what  "\[A-Za-z0-9_\/\\-\]+"
+-set w_pids  "\\d+/\\d+"
++set w_pids  "-?\\d+/\\d+"
+ set w_from_userlines 
"\(${w_user}\\s+${w_tty}\\s+${w_login}\\s+${w_idle}\\s+${w_ival7}\\s+${w_ival7}\\s+${w_what}\\s*\)*"
+ set w_fromshort_userlines 
"\(${w_user}\\s+${w_tty}\\s+${w_idle}\\s+${w_what}\\s*\)*"
+ set w_std_userlines 
"\(${w_user}\\s+${w_tty}\\s+${w_from}\\s+${w_login}\\s+${w_idle}\\s+${w_ival7}\\s+${w_ival7}\\s+${w_what}\\s*\)*"
+ set w_short_userlines 
"\(${w_user}\\s+${w_tty}\\s+${w_from}\\s+${w_idle}\\s+${w_what}\\s*\)*"
+-set w_pid_userlines 
"\(${w_user}\\s+${w_tty}\\s+${w_idle}\\s+%{w_pids}\s+${w_what}\\s*\)*"
++set w_pid_userlines 
"\(${w_user}\\s+${w_tty}\\s+${w_idle}\\s+${w_pids}\s+${w_what}\\s*\)*"
+ 
+ set test "w with no arguments"
+ spawn $w
+@@ -64,3 +64,8 @@
+ set test "w with terminal mode from and short flags"
+ spawn $w -tfs
+ expect_pass "$test" "^${w_fromshort_header}${w_fromshort_userlines}"
++
++set test "w with terminal mode and pids flag"
++spawn $w -tp
++expect_spawn_retval "$test" 0
++expect_pass "$test" "^${w_std_header}${w_pid_userlines}"

Reply via email to