Bug#1060089: isc-dhcp: install dhclient into /usr/sbin, with DEP17 M18 diversions

2024-01-25 Thread Santiago Ruano Rincón
El 23/01/24 a las 10:34, Helmut Grohne escribió:
> On Tue, Jan 23, 2024 at 01:29:51AM +0100, Chris Hofstaedtler wrote:
> > Attached is an improved patch, that avoids the temporary file loss
> > that could occur in the old version. This is mostly based on work by
> > Helmut Grohne.
> 
> Thank you.
> 
> Reviewed-by: Helmut Grohne 
> 
> I could not identify issues. The begin-remove-after markup feels
> slightly inconsistent as it partially cleans up the mitigation, but
> cleaning up the part in -ddns using this simple markup is non-trivial
> and keeping those snippets a little longer shall not cause breakage, so
> while this isn't perfect, I think it's good to go as is.
> 
> I also locally built this change and performed bootstrap testing with
> debootstrap, cdebootstrap and mmebstrap (which include isc-dhcp-client
> in the larger variants).
> 
> > Please consider this version of the patch.
> 
> I second this request. I appreciate to have this resolved by the end of
> February. Preferrably, we have this change in experimental for a few
> days before transitioning to unstable to allow for more QA.
> 
> Helmut

Done. Thanks a lot to both of your for your work.


signature.asc
Description: PGP signature


Bug#1060089: isc-dhcp: install dhclient into /usr/sbin, with DEP17 M18 diversions

2024-01-23 Thread Helmut Grohne
On Tue, Jan 23, 2024 at 01:29:51AM +0100, Chris Hofstaedtler wrote:
> Attached is an improved patch, that avoids the temporary file loss
> that could occur in the old version. This is mostly based on work by
> Helmut Grohne.

Thank you.

Reviewed-by: Helmut Grohne 

I could not identify issues. The begin-remove-after markup feels
slightly inconsistent as it partially cleans up the mitigation, but
cleaning up the part in -ddns using this simple markup is non-trivial
and keeping those snippets a little longer shall not cause breakage, so
while this isn't perfect, I think it's good to go as is.

I also locally built this change and performed bootstrap testing with
debootstrap, cdebootstrap and mmebstrap (which include isc-dhcp-client
in the larger variants).

> Please consider this version of the patch.

I second this request. I appreciate to have this resolved by the end of
February. Preferrably, we have this change in experimental for a few
days before transitioning to unstable to allow for more QA.

Helmut



Bug#1060089: isc-dhcp: install dhclient into /usr/sbin, with DEP17 M18 diversions

2024-01-22 Thread Chris Hofstaedtler
Hi,

On Fri, Jan 05, 2024 at 08:53:30PM +0100, Chris Hofstaedtler wrote:
> I'm attaching a patch that moves /sbin/dhclient and applies the
> required workarounds for diversions ("DEP17 M18").

Attached is an improved patch, that avoids the temporary file loss
that could occur in the old version. This is mostly based on work by
Helmut Grohne.

Please consider this version of the patch.

Chris

diff -Nru isc-dhcp-4.4.3-P1/debian/changelog isc-dhcp-4.4.3-P1/debian/changelog
--- isc-dhcp-4.4.3-P1/debian/changelog  2023-10-20 14:16:37.0 +0200
+++ isc-dhcp-4.4.3-P1/debian/changelog  2024-01-21 17:17:47.0 +0100
@@ -1,3 +1,11 @@
+isc-dhcp (4.4.3-P1-4.1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Move dhclient to /usr/sbin and add duplicated diversions (DEP17 P3 M18).
+Also add Conflicts: older isc-dhcp-client-ddns. (Closes: #1060089)
+
+ -- Chris Hofstaedtler   Sun, 21 Jan 2024 17:17:47 +0100
+
 isc-dhcp (4.4.3-P1-4) unstable; urgency=low
 
   [ Athos Ribeiro ]
diff -Nru isc-dhcp-4.4.3-P1/debian/control isc-dhcp-4.4.3-P1/debian/control
--- isc-dhcp-4.4.3-P1/debian/control2023-09-15 18:19:55.0 +0200
+++ isc-dhcp-4.4.3-P1/debian/control2024-01-21 17:17:47.0 +0100
@@ -107,6 +107,8 @@
  isc-dhcp-client-ddns,
 Provides:
  dhcp-client,
+Conflicts:
+ isc-dhcp-client-ddns (<< 4.4.3-P1-4.1),
 Description: DHCP client for automatically obtaining an IP address
  This is the Internet Software Consortium's DHCP client.
  .
diff -Nru isc-dhcp-4.4.3-P1/debian/isc-dhcp-client-ddns.install 
isc-dhcp-4.4.3-P1/debian/isc-dhcp-client-ddns.install
--- isc-dhcp-4.4.3-P1/debian/isc-dhcp-client-ddns.install   2022-02-23 
10:28:51.0 +0100
+++ isc-dhcp-4.4.3-P1/debian/isc-dhcp-client-ddns.install   2024-01-05 
18:51:22.0 +0100
@@ -1 +1 @@
-client/dhclient sbin
+client/dhclient usr/sbin
diff -Nru isc-dhcp-4.4.3-P1/debian/isc-dhcp-client-ddns.postinst 
isc-dhcp-4.4.3-P1/debian/isc-dhcp-client-ddns.postinst
--- isc-dhcp-4.4.3-P1/debian/isc-dhcp-client-ddns.postinst  1970-01-01 
01:00:00.0 +0100
+++ isc-dhcp-4.4.3-P1/debian/isc-dhcp-client-ddns.postinst  2024-01-21 
17:17:47.0 +0100
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+set -e
+
+# DEP17 M18: Duplicate diversion in aliased location /sbin.
+
+if [ "$1" = "configure" ]; then
+   # Remove diversion in aliased path, which is only needed for upgrades.
+   dpkg-divert --package isc-dhcp-client-ddns --remove --no-rename \
+   --divert /sbin/dhclient-noddns.usr-is-merged /sbin/dhclient
+fi
+
+#DEBHELPER#
diff -Nru isc-dhcp-4.4.3-P1/debian/isc-dhcp-client-ddns.postrm 
isc-dhcp-4.4.3-P1/debian/isc-dhcp-client-ddns.postrm
--- isc-dhcp-4.4.3-P1/debian/isc-dhcp-client-ddns.postrm2022-02-23 
10:28:51.0 +0100
+++ isc-dhcp-4.4.3-P1/debian/isc-dhcp-client-ddns.postrm2024-01-05 
18:51:22.0 +0100
@@ -3,8 +3,8 @@
 set -e 
 
 if [ "$1" = "remove" -o "$1" = "abort-install" -o "$1" = "disappear" ]; then
-dpkg-divert --package isc-dhcp-client-ddns --remove \
-   --rename --divert /sbin/dhclient-noddns /sbin/dhclient
+   dpkg-divert --package isc-dhcp-client-ddns --remove \
+   --rename --divert /usr/sbin/dhclient-noddns /usr/sbin/dhclient
 fi
 
 #DEBHELPER#
diff -Nru isc-dhcp-4.4.3-P1/debian/isc-dhcp-client-ddns.preinst 
isc-dhcp-4.4.3-P1/debian/isc-dhcp-client-ddns.preinst
--- isc-dhcp-4.4.3-P1/debian/isc-dhcp-client-ddns.preinst   2022-02-23 
10:28:51.0 +0100
+++ isc-dhcp-4.4.3-P1/debian/isc-dhcp-client-ddns.preinst   2024-01-21 
17:17:47.0 +0100
@@ -2,9 +2,47 @@
 
 set -e 
 
-if [ "$1" != "upgrade" ]; then
-   dpkg-divert --package isc-dhcp-client-ddns --add --rename \
-   --divert /sbin/dhclient-noddns /sbin/dhclient
-fi
+# DEP17 M18: Duplicate diversion in aliased location /sbin.
+
+case "$1" in
+   install)
+   # canonical path; the one we are using going forward.
+   dpkg-divert --package isc-dhcp-client-ddns --add --rename \
+   --divert /usr/sbin/dhclient-noddns /usr/sbin/dhclient
+   # aliased path, for upgrades. postinst will --remove it.
+   dpkg-divert --package isc-dhcp-client-ddns --add --rename \
+   --divert /sbin/dhclient-noddns.usr-is-merged 
/sbin/dhclient
+
+   ;;
+
+   upgrade)
+   TRUENAME=$(dpkg-divert --truename /usr/sbin/dhclient)
+   if test "$TRUENAME" = /usr/sbin/dhclient.usr-is-merged; then
+   # isc-dhcp-client.preinst duplicated the diversion for 
us.
+   # Remove duplicated diversion.
+   dpkg-divert --package isc-dhcp-client-ddns --remove 
--no-rename \
+   --divert /usr/sbin/dhclient.usr-is-merged 
/usr/sbin/dhclient
+   dpkg-divert --package isc-dhcp-client-ddns --add 
--no-rename \
+   

Bug#1060089: isc-dhcp: install dhclient into /usr/sbin, with DEP17 M18 diversions

2024-01-05 Thread Chris Hofstaedtler
Source: isc-dhcp
Version: 4.4.3-P1-4
Severity: normal
Tags: patch
User: helm...@debian.org
Usertags: dep17p3

isc-dhcp-client and isc-dhcp-client-ddns both install
/sbin/dhclient, with the latter diverting it. The diversions become
ineffective when one of them moves to /usr/sbin/dhclient.

I'm attaching a patch that moves /sbin/dhclient and applies the
required workarounds for diversions ("DEP17 M18").

Getting this right is hard. I would welcome additional testing and
reviews.

I would also advise uploading to experimental first. Please do so
soon, so we can all check the result (again).

Chris

[1] https://wiki.debian.org/UsrMerge
diff -Nru isc-dhcp-4.4.3-P1/debian/changelog isc-dhcp-4.4.3-P1/debian/changelog
--- isc-dhcp-4.4.3-P1/debian/changelog	2023-10-20 14:16:37.0 +0200
+++ isc-dhcp-4.4.3-P1/debian/changelog	2024-01-04 19:40:32.0 +0100
@@ -1,3 +1,10 @@
+isc-dhcp (4.4.3-P1-4.1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Move dhclient to /usr/sbin and add duplicated diversions (DEP17 P3 M18)
+
+ -- Chris Hofstaedtler   Thu, 04 Jan 2024 19:40:32 +0100
+
 isc-dhcp (4.4.3-P1-4) unstable; urgency=low
 
   [ Athos Ribeiro ]
diff -Nru isc-dhcp-4.4.3-P1/debian/control isc-dhcp-4.4.3-P1/debian/control
--- isc-dhcp-4.4.3-P1/debian/control	2023-09-15 18:19:55.0 +0200
+++ isc-dhcp-4.4.3-P1/debian/control	2024-01-04 19:40:32.0 +0100
@@ -107,6 +107,8 @@
  isc-dhcp-client-ddns,
 Provides:
  dhcp-client,
+Conflicts:
+ isc-dhcp-client-ddns (<< 4.4.3-P1-4.1),
 Description: DHCP client for automatically obtaining an IP address
  This is the Internet Software Consortium's DHCP client.
  .
diff -Nru isc-dhcp-4.4.3-P1/debian/isc-dhcp-client-ddns.install isc-dhcp-4.4.3-P1/debian/isc-dhcp-client-ddns.install
--- isc-dhcp-4.4.3-P1/debian/isc-dhcp-client-ddns.install	2022-02-23 10:28:51.0 +0100
+++ isc-dhcp-4.4.3-P1/debian/isc-dhcp-client-ddns.install	2024-01-04 19:40:32.0 +0100
@@ -1 +1 @@
-client/dhclient sbin
+client/dhclient usr/sbin
diff -Nru isc-dhcp-4.4.3-P1/debian/isc-dhcp-client-ddns.postinst isc-dhcp-4.4.3-P1/debian/isc-dhcp-client-ddns.postinst
--- isc-dhcp-4.4.3-P1/debian/isc-dhcp-client-ddns.postinst	1970-01-01 01:00:00.0 +0100
+++ isc-dhcp-4.4.3-P1/debian/isc-dhcp-client-ddns.postinst	2024-01-04 19:40:32.0 +0100
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+set -e
+
+# DEP17 M18: Duplicate diversion in aliased location /sbin.
+
+if [ "$1" = "configure" ]; then
+	# Remove diversion in aliased path, which is only needed for upgrades.
+	dpkg-divert --package isc-dhcp-client-ddns --remove --no-rename --divert /sbin/dhclient-noddns.usr-is-merged /sbin/dhclient
+fi
diff -Nru isc-dhcp-4.4.3-P1/debian/isc-dhcp-client-ddns.postrm isc-dhcp-4.4.3-P1/debian/isc-dhcp-client-ddns.postrm
--- isc-dhcp-4.4.3-P1/debian/isc-dhcp-client-ddns.postrm	2022-02-23 10:28:51.0 +0100
+++ isc-dhcp-4.4.3-P1/debian/isc-dhcp-client-ddns.postrm	2024-01-04 19:40:32.0 +0100
@@ -3,8 +3,8 @@
 set -e 
 
 if [ "$1" = "remove" -o "$1" = "abort-install" -o "$1" = "disappear" ]; then
-dpkg-divert --package isc-dhcp-client-ddns --remove \
-		--rename --divert /sbin/dhclient-noddns /sbin/dhclient
+	dpkg-divert --package isc-dhcp-client-ddns --remove \
+		--rename --divert /usr/sbin/dhclient-noddns /usr/sbin/dhclient
 fi
 
 #DEBHELPER#
diff -Nru isc-dhcp-4.4.3-P1/debian/isc-dhcp-client-ddns.preinst isc-dhcp-4.4.3-P1/debian/isc-dhcp-client-ddns.preinst
--- isc-dhcp-4.4.3-P1/debian/isc-dhcp-client-ddns.preinst	2022-02-23 10:28:51.0 +0100
+++ isc-dhcp-4.4.3-P1/debian/isc-dhcp-client-ddns.preinst	2024-01-04 19:40:32.0 +0100
@@ -2,9 +2,33 @@
 
 set -e 
 
-if [ "$1" != "upgrade" ]; then
-	dpkg-divert --package isc-dhcp-client-ddns --add --rename \
-		--divert /sbin/dhclient-noddns /sbin/dhclient
-fi
+# DEP17 M18: Duplicate diversion in aliased location /sbin.
+
+case "$1" in
+	install)
+		# canonical path; the one we are using going forward.
+		dpkg-divert --package isc-dhcp-client-ddns --add --rename \
+			--divert /usr/sbin/dhclient-noddns /usr/sbin/dhclient
+		# aliased path, for upgrades. postinst will --remove it.
+		dpkg-divert --package isc-dhcp-client-ddns --add --rename \
+			--divert /sbin/dhclient-noddns.usr-is-merged /sbin/dhclient
+
+		;;
+
+	upgrade)
+		dpkg-divert --package isc-dhcp-client-ddns --add --no-rename --divert /usr/sbin/dhclient-noddns /usr/sbin/dhclient
+
+		# convert a pre-existing, aliased diversion. postinst will remove it.
+		TRUENAME=$(dpkg-divert --truename /sbin/dhclient)
+		if test "$TRUENAME" != "/sbin/dhclient-noddns.usr-is-merged" -a "$TRUENAME" != "/sbin/dhclient"; then
+			dpkg-divert --package isc-dhcp-client-ddns --remove --no-rename /sbin/dhclient
+			dpkg-divert --package isc-dhcp-client-ddns --add --no-rename --divert /sbin/dhclient-noddns.usr-is-merged /sbin/dhclient
+			if test -e "$DPKG_ROOT$TRUENAME" -o -h "$DPKG_ROOT$TRUENAME"; then
+mv "$DPKG_ROOT$TRUENAME"