Source: opensysusers
Version: 0.7.3-4
Severity: serious
Justification: loss of systemd files
Tags: patch
User: helm...@debian.org
Usertags: dep17

Hi,

I'm sorry to tell you that I got the DEP17 mitigation for opensysusers
wrong. The details are at
https://lists.debian.org/debian-devel/2025/01/msg00125.html.
opensysusers is affected, because it has a code path that uses --rename
for aliased diversions.

While looking into it and trying to fix it, I noticed that systemd and
systemd-standalone-sysusers now both declare Conflicts: opensysusers and
Conflicts: systemd-sysusers respectively. The latter is being provided
by all sysusers implementations including opensysusers. In trixie and
later, sysusers implementations are no longer coinstallable but mutually
exclusive. This simplifies the story a lot. I propose mirroring the
conflict and declaring "Conflicts: systemd-sysusers". As a result, we
may do away with all of the diversions (and the file loss problem).

At the time of writing my earlier patch, systemd did not yet declare
Conflicts with opensysusers. Hence, I tried to support coinstallation
there. The present simplification is a result of changes in systemd.

Please find my patch and test cases attached.

Helmut
diff --minimal -Nru opensysusers-0.7.3/debian/changelog 
opensysusers-0.7.3/debian/changelog
--- opensysusers-0.7.3/debian/changelog 2024-09-17 19:38:59.000000000 +0200
+++ opensysusers-0.7.3/debian/changelog 2025-01-10 15:34:02.000000000 +0100
@@ -1,3 +1,10 @@
+opensysusers (0.7.3-4.1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Declare Conflicts: systemd-sysusers and remove diversions. (Closes: #-1)
+
+ -- Helmut Grohne <hel...@subdivi.de>  Fri, 10 Jan 2025 15:34:02 +0100
+
 opensysusers (0.7.3-4) unstable; urgency=medium
 
   * d/changelog: correct closed bug for previous entry
diff --minimal -Nru opensysusers-0.7.3/debian/control 
opensysusers-0.7.3/debian/control
--- opensysusers-0.7.3/debian/control   2024-09-17 19:38:59.000000000 +0200
+++ opensysusers-0.7.3/debian/control   2025-01-10 15:34:02.000000000 +0100
@@ -17,6 +17,8 @@
 Package: opensysusers
 Provides:
  systemd-sysusers,
+Conflicts:
+ systemd-sysusers,
 Architecture: all
 Depends:
  passwd,
diff --minimal -Nru opensysusers-0.7.3/debian/opensysusers.postinst 
opensysusers-0.7.3/debian/opensysusers.postinst
--- opensysusers-0.7.3/debian/opensysusers.postinst     1970-01-01 
01:00:00.000000000 +0100
+++ opensysusers-0.7.3/debian/opensysusers.postinst     2025-01-10 
15:34:02.000000000 +0100
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+set -e
+
+if [ configure = "$1" ] && [ -n "$2" ] && dpkg --compare-versions "$2" lt 
0.7.3-4.1~; then
+    # We are upgrading from an earlier version that used to divert
+    # systemd-sysusers. Since this version Conflicts: systemd-sysusers, there
+    # should not be any divertees left during postinst and we may safely remove
+    # all remaining diversions. If anything is left behind, --rename will fail.
+    dpkg-divert --remove --rename /usr/bin/systemd-sysusers
+    dpkg-divert --remove --rename /bin/systemd-sysusers
+fi
+
+#DEBHELPER#
+
+exit 0
diff --minimal -Nru opensysusers-0.7.3/debian/opensysusers.postrm 
opensysusers-0.7.3/debian/opensysusers.postrm
--- opensysusers-0.7.3/debian/opensysusers.postrm       2024-09-17 
19:38:59.000000000 +0200
+++ opensysusers-0.7.3/debian/opensysusers.postrm       1970-01-01 
01:00:00.000000000 +0100
@@ -1,32 +0,0 @@
-#!/bin/sh
-
-set -e
-
-if [ "$1" = "remove" ] || [ "$1" = "abort-install" ] || [ "$1" = "disappear" ] 
; then
-       dpkg-divert --package opensysusers --remove --no-rename \
-        --divert /bin/systemd-sysusers.real /bin/systemd-sysusers
-       dpkg-divert --package opensysusers --remove --no-rename \
-       --divert /usr/bin/systemd-sysusers.real /usr/bin/systemd-sysusers
-fi
-
-if [ "abort-upgrade" = "$1" ] && dpkg --compare-versions "$2" lt 0.6-1; then
-       dpkg-divert --package opensysusers --remove --no-rename \
-        --divert /bin/systemd-sysusers.real /bin/systemd-sysusers
-fi
-
-if [ "$1" = abort-upgrade ] && dpkg --compare-versions "$2" lt 0.7.3-2.1~; then
-       dpkg-divert --package opensysusers --remove --no-rename \
-       --divert /usr/bin/systemd-sysusers.real /usr/bin/systemd-sysusers
-fi
-
-if [ "$1" = "remove" ] || [ "$1" = "abort-install" ] || [ "$1" = "disappear" ] 
; then
-       for f in /usr/bin/systemd-sysusers /bin/systemd-sysusers; do
-               if [ -e "$DPKG_ROOT$f.real" ] && ! [ -e "$DPKG_ROOT$f" ]; then
-                       mv "$DPKG_ROOT$f.real" "$DPKG_ROOT$f"
-               fi
-       done
-fi
-
-#DEBHELPER#
-
-exit 0
diff --minimal -Nru opensysusers-0.7.3/debian/opensysusers.preinst 
opensysusers-0.7.3/debian/opensysusers.preinst
--- opensysusers-0.7.3/debian/opensysusers.preinst      2024-09-17 
19:38:59.000000000 +0200
+++ opensysusers-0.7.3/debian/opensysusers.preinst      2025-01-10 
15:34:02.000000000 +0100
@@ -6,24 +6,6 @@
        update-alternatives --remove-all sysusers
 fi
 
-if [ upgrade != "$1" ] || dpkg --compare-versions "$2" lt 0.6-1; then
-    dpkg-divert --package opensysusers --add --no-rename \
-        --divert /bin/systemd-sysusers.real /bin/systemd-sysusers
-fi
-
-if [ upgrade != "$1" ] || dpkg --compare-versions "$2" lt 0.7.3-2.1~; then
-    dpkg-divert --package opensysusers --add --no-rename \
-       --divert /usr/bin/systemd-sysusers.real /usr/bin/systemd-sysusers
-fi
-
-if [ upgrade != "$1" ]; then
-    for f in /usr/bin/systemd-sysusers /bin/systemd-sysusers; do
-        if [ -e "$DPKG_ROOT$f" ] && ! [ -e "$DPKG_ROOT$f.real" ]; then
-            mv "$DPKG_ROOT$f" "$DPKG_ROOT$f.real"
-        fi
-    done
-fi
-
 #DEBHELPER#
 
 exit 0

Attachment: test.sh
Description: Bourne shell script

Reply via email to