Subject: elogind crashes with needrestart's defaults

From: Rene Kita <[email-masked]>
Date: Mon, 18 Oct 2021 12:32:52 +0200

Package: elogind
Version: 246.10-2
Severity: normal

Dear Maintainer,

   * What led up to the situation?
   After upgrading 'elogind' 'needrestart' prompts to choose which
   services should be restarted. 'elogind' is checked by default.
   When confirming the default choice 'X' crashes and I end up on a
   virtual console.

   * What outcome did you expect instead?
   I expected it to either not crash or not suggest to restart.

My system boots to a virtual console and I use 'startx' to get a
graphical session. My window manager is i3.

If more information or testing is needed, I'll provide it.

-- System Information:
Distributor ID:	Devuan
Description:	Devuan GNU/Linux 4 (chimaera)
Release:	4
Codename:	chimaera
Architecture: x86_64

Kernel: Linux 5.10.0-9-amd64 (SMP w/2 CPU threads)
Kernel taint flags: TAINT_WARN
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE=en_US:en
Shell: /bin/sh linked to /bin/dash
Init: sysvinit (via /sbin/init)
LSM: AppArmor: enabled

Versions of packages elogind depends on:
ii  dbus                  1.12.20-2+devuan2
ii  debconf               1.5.77
ii  init-system-helpers   1.60+devuan1
ii  libacl1               2.2.53-10
ii  libc6                 2.31-13+deb11u2
ii  libcap2               1:2.44-1
ii  libelogind0           246.10-2
ii  libeudev1 [libudev1]  3.2.9-10~chimaera1
ii  libpam0g              1.4.0-9+deb11u1
ii  libselinux1           3.1-3
ii  lsb-base              11.1.0

Versions of packages elogind recommends:
ii  libpam-elogind  246.10-2
ii  policykit-1     0.105-31+devuan1

elogind suggests no packages.

-- no debconf information

---

From: Mark Hindley <[email-masked]>
Date: Mon, 18 Oct 2021 12:03:08 +0100

Thanks.

It looks as if needrestart needs to know how to restart elogind gracefully with
SIGINT.

Mark

---

From: Mark Hindley <[email-masked]>
Date: Mon, 18 Oct 2021 12:23:35 +0100

> It looks as if needrestart needs to know how to restart elogind gracefully with

Actually, AFAICS on a quick look at needrestart, it should work OK.

Hmmm. Can you verify that

 sudo service elogind restart

works without crashing your GUI?

That should be OK since about 239.3

Which version of Devuan and elogind did you upgrade to Chimaera from? Did you
start from ASCII and miss out Beowulf?

Mark

---

From: Rene Kita <[email-masked]>
Date: Mon, 18 Oct 2021 15:35:51 +0200

> works without crashing your GUI?
# service elogind restart

crashes the GUI. And I have to use Magic SysRq with 'r' command to get
my keyboard back. I tested this on two different laptops.

> start from ASCII and miss out Beowulf?
At least on one machine I did start out from Beowulf. Another one was
installed from the Chimaera Alpha installer.
I only use the elogind version from the repos and do not skip any updates.

> Mark
Rene

---

From: Rene Kita <[email-masked]>
Date: Mon, 18 Oct 2021 15:59:53 +0200

(Mark: Sorry, if this message reaches you twice. I accidentally send it via my
work account)

On Mon, Oct 18, 2021 at 12:23:35PM +0100, Mark Hindley wrote:
> > It looks as if needrestart needs to know how to restart elogind gracefully
+with

Rene

---

From: Mark Hindley <[email-masked]>
Date: Mon, 18 Oct 2021 18:31:48 +0100

Rene,

> my keyboard back. I tested this on two different laptops.

OK, that is unexpected. I can't reproduce that behaviour.

What desktop are you using?

> I only use the elogind version from the repos and do not skip any updates.

And they all show the same behaviour?

I have tried xfce and openbox on both chimaera and beowulf and

restarts elogind without crashing the current GUI.

Mark

---

From: Rene Kita <[email-masked]>
Date: Mon, 18 Oct 2021 21:16:16 +0200

> What desktop are you using?
i3 with i3-status and dmenu, started with 'startx'.

> And they all show the same behaviour?
Yes. I can reproduce it on 3 different laptops, which all have the same
setup, though.

Rene

---

From: Mark Hindley <[email-masked]>
Date: Mon, 18 Oct 2021 20:48:59 +0100

> i3 with i3-status and dmenu, started with 'startx'.

OK, I have managed to reproduce this now. It only happens for me in a GUI
started with startx. The display managers I tried (slim, lightdm) were OK.

I will take this upstream.

Mark

---

From: Mark Hindley <[email-masked]>
Date: Tue, 19 Oct 2021 12:29:52 +0100

Control: forwarded -1 https://github.com/elogind/elogind/issues/216

Forwarded upstream.

Mark

---

From: Mark Hindley <[email-masked]>
Date: Wed, 20 Oct 2021 16:35:01 +0100

Rena,

Whilst we are waiting for a proper fix for this upstream, does the attached
patch prevent the restart?

Thanks

Mark
From 6a86b28d8e80c3605418b4571dc166324a51fd41 Mon Sep 17 00:00:00 2001
From: Mark Hindley <[email-masked]>
Date: Wed, 20 Oct 2021 16:31:08 +0100
Subject: [PATCH] Prevent restart if session has a tty and DISPLAY is set
 (startx).

Restarting elogind in this situation still crashes the GUI. Work around this
until it is fixed upstream.
---
 debian/elogind.init | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/debian/elogind.init b/debian/elogind.init
index fc3cb24a7..4a718fb2f 100644
--- a/debian/elogind.init
+++ b/debian/elogind.init
@@ -53,12 +53,18 @@ case "$1" in
     ;;
   force-reload|restart)
     log_daemon_msg "Restarting session management daemon" "elogind" || true
-    # Use SIGINT for graceful restart so that existing sessions are not lost.
-    start-stop-daemon --stop --quiet --oknodo --signal INT --retry 30 --pidfile $ELOGIND_PID
-    if start-stop-daemon --start --quiet --oknodo --pidfile $ELOGIND_PID --exec $ELOGIND -- $ELOGIND_OPTS; then
-        log_end_msg 0 || true
+    if loginctl session-status | grep -q tty && [ -n "$DISPLAY" ] ; then
+            # Work around #619
+            log_progress_msg "(Unable to restart from a startx GUI)" || true
+            log_end_msg 1 || true
     else
-        log_end_msg 1 || true
+            # Use SIGINT for graceful restart so that existing sessions are not lost.
+            start-stop-daemon --stop --quiet --oknodo --signal INT --retry 30 --pidfile $ELOGIND_PID
+            if start-stop-daemon --start --quiet --oknodo --pidfile $ELOGIND_PID --exec $ELOGIND -- $ELOGIND_OPTS; then
+                    log_end_msg 0 || true
+            else
+                    log_end_msg 1 || true
+            fi
     fi
     ;;
   try-restart)
-- 
2.20.1