On Sun, 7 Oct 2018 01:57:31 +0200
Michael Biebl <bi...@debian.org> wrote:

> > - We tweak the LSB headers to make sure the udev init script is
> > called before sendsigs on shutdown. This is important!
> 
> I have to add, that this change has the potential to significantly
> change the shutdown order or cause a conflicting ordering, in case
> there are other init scripts which declare an explicit shutdown
> dependency.

yes, this would create a circular dependency

before the 791944 patch, the shutdown sequence was:
K03sendsigs     (before umountnfs)
K05umountnfs    (before umountfs)
K07umountfs     (before umountroot)
K08cryptdisks   (after umountfs, before umountroot udev)
K10umountroot

if udev is stopped before sendsigs:
- cryptdisks should be stopped before udev
- umountfs should be stopped before cryptdisks
- umountnfs should be stopped before umountfs
- but sendsigs cannot be stopped after umountnfs

it can be easily resolved removing the udev entry in the Should-Stop
header of cryptdisks (and cryptdisks-early)


> Looking at https://codesearch.debian.net/ and searching for packages
> which declare a Should-Stop or Required-Stop on udev and checking if
> any late shutdown services are involved.

wow! I didn't know this site

with this simple search "Stop(|-After):.*udev", it returned these
packages that could be affected: multipath-tools, pcsc-lite,
network-manager, mouseemu, pulseaudio, cryptsetup, nut

it seems to me none of these packages would break (except cryptsetup)

this change should be mentioned in the NEWS.Debian file, as it could
break any script that depends on udev on shutdown and that is not
distributed by debian (open/closed source packages and system
administrator scripts)

the patches attached are tested on a system with swaps and filesystems
encrypted in plain mode (no luks, no cryptroot)

ciao!
>From b8f8bcfa1c447bc0839a84c4f64a551278a33dec Mon Sep 17 00:00:00 2001
From: Trek <tre...@inbox.ru>
Date: Sun, 7 Oct 2018 17:59:25 +0200
Subject: [PATCH] Stop udev before sendsigs to fix a regression of #791944

The start-stop-daemon command with the --background argument returns
immediately, too soon to trigger events on some systems. The #791944
patch is partly reverted and a dependency to sendsigs is added in the
SysV init script at shutdown.

Closes: #908796
---
 debian/udev.init | 19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)

diff --git a/debian/udev.init b/debian/udev.init
index 9c394bb..794373d 100644
--- a/debian/udev.init
+++ b/debian/udev.init
@@ -3,6 +3,7 @@
 # Provides:          udev
 # Required-Start:    mountkernfs
 # Required-Stop:     umountroot
+# Should-Stop:       sendsigs
 # Default-Start:     S
 # Default-Stop:      0 6
 # Short-Description: Start systemd-udevd, populate /dev and load drivers.
@@ -12,9 +13,7 @@ PATH="/sbin:/bin"
 NAME="systemd-udevd"
 DAEMON="/lib/systemd/systemd-udevd"
 DESC="hotplug events dispatcher"
-PIDFILE="/run/udev.pid"
 CTRLFILE="/run/udev/control"
-OMITDIR="/run/sendsigs.omit.d"
 
 # we need to unmount /dev/pts/ and remount it later over the devtmpfs
 unmount_devpts() {
@@ -165,11 +164,7 @@ case "$1" in
     [ -x /sbin/restorecon ] && /sbin/restorecon -R /dev
 
     log_daemon_msg "Starting $DESC" "$NAME"
-    if start-stop-daemon --start --name $NAME --user root --quiet \
-        --pidfile $PIDFILE --exec $DAEMON --background --make-pidfile; then
-        # prevents udevd to be killed by sendsigs (see #791944)
-        mkdir -p $OMITDIR
-        ln -sf $PIDFILE $OMITDIR/$NAME
+    if $DAEMON --daemon; then
         log_end_msg $?
     else
         log_warning_msg $?
@@ -198,7 +193,7 @@ case "$1" in
     stop)
     log_daemon_msg "Stopping $DESC" "$NAME"
     if start-stop-daemon --stop --name $NAME --user root --quiet \
-        --pidfile $PIDFILE --remove-pidfile --oknodo --retry 5; then
+        --oknodo --retry 5; then
         # prevents cryptsetup/dmsetup hangs (see #791944)
         rm -f $CTRLFILE
         log_end_msg $?
@@ -210,7 +205,7 @@ case "$1" in
     restart)
     log_daemon_msg "Stopping $DESC" "$NAME"
     if start-stop-daemon --stop --name $NAME --user root --quiet \
-        --pidfile $PIDFILE --remove-pidfile --oknodo --retry 5; then
+        --oknodo --retry 5; then
         # prevents cryptsetup/dmsetup hangs (see #791944)
         rm -f $CTRLFILE
         log_end_msg $?
@@ -219,11 +214,7 @@ case "$1" in
     fi
 
     log_daemon_msg "Starting $DESC" "$NAME"
-    if start-stop-daemon --start --name $NAME --user root --quiet \
-        --pidfile $PIDFILE --exec $DAEMON --background --make-pidfile; then
-        # prevents udevd to be killed by sendsigs (see #791944)
-        mkdir -p $OMITDIR
-        ln -sf $PIDFILE $OMITDIR/$NAME
+    if $DAEMON --daemon; then
         log_end_msg $?
     else
         log_end_msg $?
-- 
2.1.4

>From 46ef94eb04ea03b7ef53b156439eef22e3c0a054 Mon Sep 17 00:00:00 2001
From: Trek <tre...@inbox.ru>
Date: Sun, 7 Oct 2018 17:57:54 +0200
Subject: [PATCH] Remove the shutdown dependency on udev to fix a regression of
 #791944

As udev no longer removes his control socket on exit, it is now stopped
before sendsigs, but a circular dependecy is created because cryptdisks
must be called after umountfs. Update the init scripts to remove the
dependency on udev at shutdown.

Closes: #908796
---
 debian/cryptsetup-run.cryptdisks-early.init | 2 +-
 debian/cryptsetup-run.cryptdisks.init       | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/debian/cryptsetup-run.cryptdisks-early.init b/debian/cryptsetup-run.cryptdisks-early.init
index 6498431..c027d4a 100644
--- a/debian/cryptsetup-run.cryptdisks-early.init
+++ b/debian/cryptsetup-run.cryptdisks-early.init
@@ -4,7 +4,7 @@
 # Required-Start:    checkroot
 # Required-Stop:     umountroot
 # Should-Start:      udev mdadm-raid
-# Should-Stop:       udev mdadm-raid
+# Should-Stop:       mdadm-raid
 # X-Start-Before:    lvm2
 # X-Stop-After:      lvm2 umountfs
 # X-Interactive:     true
diff --git a/debian/cryptsetup-run.cryptdisks.init b/debian/cryptsetup-run.cryptdisks.init
index 0cd4a83..17095a7 100644
--- a/debian/cryptsetup-run.cryptdisks.init
+++ b/debian/cryptsetup-run.cryptdisks.init
@@ -4,7 +4,7 @@
 # Required-Start:    checkroot cryptdisks-early
 # Required-Stop:     umountroot cryptdisks-early
 # Should-Start:      udev mdadm-raid lvm2
-# Should-Stop:       udev mdadm-raid lvm2
+# Should-Stop:       mdadm-raid lvm2
 # X-Start-Before:    checkfs
 # X-Stop-After:      umountfs
 # X-Interactive:     true
-- 
2.1.4

Reply via email to