Hi!

On Wed, 2024-01-03 at 16:56:36 +0100, Helmut Grohne wrote:
> Source: ifupdown
> Version: 0.8.41
> Tags: patch
> User: helm...@debian.org
> Usertags: dep17m2

> ifupdown still is part of the debootstrap package set. I know you want
> to change this, but since it still is, it should be converted for the
> /usr-move (DEP17) sooner rather than later. I'm attaching a patch and
> note that it wasn't entirely trivial. I expect that dumat will not moan
> about it in any way, but giving it some project exposure in experimental
> for volunteers to test might not be the worst of ideas. As with similar
> patches, this should not be uploaded to bookworm-backports, so you may
> want to use dh_movetousr instead.

The provided patch seems to be missing canonicalization for the lib/
scripts from `inet6.defn` which will break downstreams of this project
that are not aliasing directories, and in Debian would fail to be located
if a user reading the code passed them to «dpkg -S» for example.

I had a patch locally (yet untested, but I'm happy to do that) to make
the program accesses relative, which should increase portability and
make these more independent of the system filesystem layout. For the
programs and lib/ scripts owned by this project though this seems
unnecessary as the destination is controlled by the build system
machinery, so those could perhaps be replaced at build/install time to
make them coherent, but that seemed like more work. :) But I'm happy to
switch to that approach if you'd prefer. Alternatively they could simply
be hardcoded to the new locations.

The original patch in this bug report could then perhaps be adapted on
top of the one I'm attaching here (or a variation of it). Otherwise I
can provide parts of it independently on top of the original patch, as
a MR or similar.

Thanks,
Guillem
From 6044af67053f8aa9ebf4e8aa3d6b9ce1c640212e Mon Sep 17 00:00:00 2001
From: Guillem Jover <guil...@hadrons.org>
Date: Sun, 3 Dec 2023 02:51:43 +0100
Subject: [PATCH] Use relative names when executing programs

This switches program invocations to use relative names, so that we are
then not concerned about the filesystem layout of the system we are
installing into.

While for programs we ship and install we will know the end destination
and could simply replace that at build or install time, that seemed more
effort than simply making all usage relative.
---
 Makefile                    | 8 +++++---
 debian/ifupdown-hotplug     | 2 +-
 examples/network-interfaces | 5 +++--
 examples/pcmcia-compat.sh   | 4 +++-
 execute.c                   | 2 +-
 inet6.defn                  | 6 +++---
 6 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/Makefile b/Makefile
index 0ce2fa3..85c887e 100644
--- a/Makefile
+++ b/Makefile
@@ -3,9 +3,11 @@ CFLAGS ?= -Wall -W -Wno-unused-parameter -g -O2
 ARCH := $(shell dpkg-architecture -qDEB_HOST_ARCH_OS)
 
 BASEDIR ?= $(DESTDIR)
+PKGLIBDIR ?= /lib/ifupdown
 
 CFLAGS += -std=c99 -D_DEFAULT_SOURCE
 CFLAGS += -D'IFUPDOWN_VERSION="$(VERSION)"'
+CFLAGS += -D'PKGLIBDIR="$(PKGLIBDIR)"'
 
 DEFNFILES := inet.defn ipx.defn inet6.defn can.defn
 
@@ -26,9 +28,9 @@ install :
 	install -m 0755 ifup   ${BASEDIR}/sbin
 	ln -s /sbin/ifup ${BASEDIR}/sbin/ifdown
 	ln -s /sbin/ifup ${BASEDIR}/sbin/ifquery
-	install -D -m 0755 settle-dad.sh $(BASEDIR)/lib/ifupdown/settle-dad.sh
-	install -D -m 0755 wait-for-ll6.sh $(BASEDIR)/lib/ifupdown/wait-for-ll6.sh
-	install -D -m 0755 wait-online.sh $(BASEDIR)/lib/ifupdown/wait-online.sh
+	install -D -m 0755 settle-dad.sh $(BASEDIR)$(PKGLIBDIR)/settle-dad.sh
+	install -D -m 0755 wait-for-ll6.sh $(BASEDIR)$(PKGLIBDIR)/wait-for-ll6.sh
+	install -D -m 0755 wait-online.sh $(BASEDIR)$(PKGLIBDIR)/wait-online.sh
 
 clean :
 	rm -f *.o $(patsubst %.defn,%.c,$(DEFNFILES)) *~
diff --git a/debian/ifupdown-hotplug b/debian/ifupdown-hotplug
index 6e5f6c5..f53b87b 100755
--- a/debian/ifupdown-hotplug
+++ b/debian/ifupdown-hotplug
@@ -1,6 +1,6 @@
 #!/bin/sh -e
 #
-# run /sbin/{ifup,ifdown} with the --allow=hotplug option.
+# run {ifup,ifdown} with the --allow=hotplug option.
 #
 
 PATH='/sbin:/bin:/usr/sbin:/usr/bin'
diff --git a/examples/network-interfaces b/examples/network-interfaces
index d8bba2b..3dd1d7e 100644
--- a/examples/network-interfaces
+++ b/examples/network-interfaces
@@ -119,14 +119,15 @@
 # Note, this won't work unless you specifically change the file
 # /etc/pcmcia/network to look more like:
 #
+#     PATH="$PATH:/sbin:/usr/sbin"
 #     if [ -r ./shared ] ; then . ./shared ; else . /etc/pcmcia/shared ; fi
 #     get_info $DEVICE
 #     case "$ACTION" in
 #         'start')
-#             /sbin/ifup $DEVICE
+#             ifup $DEVICE
 #             ;;
 #         'stop')
-#             /sbin/ifdown $DEVICE
+#             ifdown $DEVICE
 #             ;;
 #     esac
 #     exit 0
diff --git a/examples/pcmcia-compat.sh b/examples/pcmcia-compat.sh
index 4b31fdb..a45a236 100644
--- a/examples/pcmcia-compat.sh
+++ b/examples/pcmcia-compat.sh
@@ -1,5 +1,7 @@
 #!/bin/sh
 
+PATH="$PATH:/sbin:/usr/sbin"
+
 if [ ! -e /etc/pcmcia/shared ]; then exit 1; fi
 
 pcmcia_shared () {
@@ -15,7 +17,7 @@ usage () {
 }
 
 get_info $iface
-HWADDR=`/sbin/ifconfig $DEVICE | sed -n -e 's/.*addr \([^ ]*\) */\1/p'`
+HWADDR=`ifconfig $DEVICE | sed -n -e 's/.*addr \([^ ]*\) */\1/p'`
 
 which=""
 while read glob scheme; do
diff --git a/execute.c b/execute.c
index 487c8ca..8c57c60 100644
--- a/execute.c
+++ b/execute.c
@@ -104,7 +104,7 @@ static void set_environ(interface_defn *iface, char *mode, char *phase) {
 	*ppch++ = setlocalenv("%s=%s", "MODE", mode);
 	*ppch++ = setlocalenv("%s=%s", "PHASE", phase);
 	*ppch++ = setlocalenv("%s=%s", "VERBOSITY", verbose ? "1" : "0");
-	*ppch++ = setlocalenv("%s=%s", "PATH", "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin");
+	*ppch++ = setlocalenv("%s=%s", "PATH", PKGLIBDIR ":/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin");
 	if (allow_class || do_all)
 		*ppch++ = setlocalenv("%s=%s", "CLASS", allow_class ? allow_class : "auto");
 	*ppch = NULL;
diff --git a/inet6.defn b/inet6.defn
index d62123b..0dc741a 100644
--- a/inet6.defn
+++ b/inet6.defn
@@ -28,7 +28,7 @@ method auto
     ip addr flush dev %iface% mngtmpaddr \
         if (var_set("accept_ra", ifd) && !var_true("accept_ra", ifd))
     ip link set dev %iface% up
-    /lib/ifupdown/wait-for-ll6.sh if (var_true("dhcp", ifd) && execable("/lib/ifupdown/wait-for-ll6.sh"))
+    wait-for-ll6.sh if (var_true("dhcp", ifd) && execable("wait-for-ll6.sh"))
     dhclient -6 -v -P -pf /run/dhclient6.%iface%.pid -lf /var/lib/dhcp/dhclient6.%iface%.leases -I -df /var/lib/dhcp/dhclient.%iface%.leases %iface% \
         if (var_true("dhcp", ifd) && execable("dhclient") && var_true("request_prefix", ifd))
     dhclient -6 -1 -v -S -pf /run/dhclient6.%iface%.pid -lf /var/lib/dhcp/dhclient6.%iface%.leases -I -df /var/lib/dhcp/dhclient.%iface%.leases %iface% \
@@ -99,7 +99,7 @@ method static
     ip -6 addr add %address%[[/%netmask%]] [[scope %scope%]] dev %iface% [[preferred_lft %preferred-lifetime%]] nodad \
                 if (var_set("dad-attempts", ifd) && !var_true("dad-attempts", ifd))
     [[ ip -6 route replace default via %gateway% [[metric %metric%]] dev %iface% onlink ]]
-    /lib/ifupdown/settle-dad.sh if (!no_act_commands && execable("/lib/ifupdown/settle-dad.sh") && (var_true("dad-attempts", ifd)))
+    settle-dad.sh if (!no_act_commands && execable("settle-dad.sh") && (var_true("dad-attempts", ifd)))
 
   down
     [[ ip -6 route del default via %gateway% [[metric %metric%]] dev %iface% ]]
@@ -157,7 +157,7 @@ method dhcp
     ip addr flush dev %iface% mngtmpaddr \
         if (var_set("accept_ra", ifd) && !var_true("accept_ra", ifd))
     ip link set dev %iface% [[address %hwaddress%]] up
-    /lib/ifupdown/wait-for-ll6.sh if (execable("/lib/ifupdown/wait-for-ll6.sh"))
+    wait-for-ll6.sh if (execable("wait-for-ll6.sh"))
     dhclient -6 -v -pf /run/dhclient6.%iface%.pid -lf /var/lib/dhcp/dhclient6.%iface%.leases -I -P -N -df /var/lib/dhcp/dhclient.%iface%.leases %iface% \
         if (execable("dhclient") && var_true("request_prefix", ifd))
     dhclient -6 -v -pf /run/dhclient6.%iface%.pid -lf /var/lib/dhcp/dhclient6.%iface%.leases -I -df /var/lib/dhcp/dhclient.%iface%.leases %iface% \
-- 
2.43.0

Reply via email to