Source: resolvconf Source-Version: 1.92 Severity: normal Tags: patch Forwarded: https://salsa.debian.org/debian/resolvconf/-/merge_requests/6
Hi! This is a repost of the MR in salsa, to improve the general handling for third-party commands, and performs a full canonical move to /usr, which will be eventually needed anyway (once the dh_movetousr hack goes away). But if there are intentions to backport this version as is then the full move will not be doable right now I guess. Patches attached. Thanks, Guillem
From a1c7d9be017a18fa7499c7668b27bab37f1ceea5 Mon Sep 17 00:00:00 2001 From: Guillem Jover <guil...@hadrons.org> Date: Mon, 27 Nov 2023 04:22:00 +0100 Subject: [PATCH 1/3] Add a debian/.gitignore file --- debian/.gitignore | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 debian/.gitignore diff --git a/debian/.gitignore b/debian/.gitignore new file mode 100644 index 0000000..5424e80 --- /dev/null +++ b/debian/.gitignore @@ -0,0 +1,7 @@ +*.debhelper +*.debhelper.log +*.substvars +.debhelper/ +debhelper-build-stamp +files +resolvconf/ -- 2.45.2
From 1771e1127e37be5527930eace044ac8e5c8f0d5f Mon Sep 17 00:00:00 2001 From: Guillem Jover <guil...@hadrons.org> Date: Mon, 27 Nov 2023 03:49:07 +0100 Subject: [PATCH 2/3] Do not hardcode absolute pathnames to third-party commands MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hardcoding pathnames for commands from third-party projects forces specific filesystem layouts and directory locations (for example /usr vs /, /sbin vs /bin, which might change depending on the downstream), and makes potential moves across directories more difficult, and potentially breakage points for the code calling those commands. Avoid that by simply using the PATH environment variable, and using «command -v» instead of «test -x». --- debian/config | 4 +++- debian/resolvconf-update-bind | 6 +++--- debian/resolvconf.init | 6 +++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/debian/config b/debian/config index 0a12a42..7194d4a 100644 --- a/debian/config +++ b/debian/config @@ -2,6 +2,8 @@ set -e +PATH=/usr/sbin:/usr/bin:/sbin:/bin + . /usr/share/debconf/confmodule eni_seems_adequate() @@ -10,7 +12,7 @@ eni_seems_adequate() # the interfaces file then that is adequate. # Formerly: [ -f /etc/network/interfaces ] && grep -q dns-nameservers /etc/network/interfaces > /dev/null # but now we use ifquery for correctness. - [ -x /sbin/ifquery ] && ifquery $(ifquery --list -a) | grep -q '^dns-nameserver' + command -v ifquery >/dev/null && ifquery $(ifquery --list -a) | grep -q '^dns-nameserver' } original_seems_nm_generated() diff --git a/debian/resolvconf-update-bind b/debian/resolvconf-update-bind index 71a5067..e6d3f7b 100755 --- a/debian/resolvconf-update-bind +++ b/debian/resolvconf-update-bind @@ -23,9 +23,9 @@ # Licensed under the GNU GPL. See /usr/share/doc/resolvconf/copyright. set -e -PATH=/sbin:/bin +PATH=/usr/sbin:/usr/bin:/sbin:/bin -[ -x /usr/sbin/named ] || exit 0 +command -v named >/dev/null || exit 0 [ -x /lib/resolvconf/list-records ] || exit 1 [ -f /etc/bind/named.conf.options ] || exit 0 @@ -98,7 +98,7 @@ cat /etc/bind/named.conf.options \ >> "$TMP_FILE" # Reload named unless we know its options haven't changed -if [ -x /usr/bin/diff ] && [ -f "$DYNAMIC_OPTS_FILE" ] && /usr/bin/diff -q "$DYNAMIC_OPTS_FILE" "$TMP_FILE" > /dev/null ; then +if command -v diff >/dev/null && [ -f "$DYNAMIC_OPTS_FILE" ] && diff -q "$DYNAMIC_OPTS_FILE" "$TMP_FILE" > /dev/null ; then # No change rm -f "$TMP_FILE" else diff --git a/debian/resolvconf.init b/debian/resolvconf.init index 51b88b4..f18f7ec 100755 --- a/debian/resolvconf.init +++ b/debian/resolvconf.init @@ -25,7 +25,7 @@ [ -x /sbin/resolvconf ] || exit 0 -PATH=/sbin:/bin +PATH=/usr/sbin:/usr/bin:/sbin:/bin RUN_DIR=/run/resolvconf ENABLE_UPDATES_FLAGFILE="${RUN_DIR}/enable-updates" POSTPONED_UPDATE_FLAGFILE="${RUN_DIR}/postponed-update" @@ -57,13 +57,13 @@ create_runtime_directories() # Create directory at the target mkdir "$RUN_DIR" || log_action_end_msg_and_exit 1 "Error creating directory $RUN_DIR" fi - [ -x /sbin/restorecon ] && /sbin/restorecon "$RUN_CANONICALDIR" + command -v restorecon >/dev/null && restorecon "$RUN_CANONICALDIR" # The resolvconf run directory now exists. if [ ! -d "${RUN_DIR}/interface" ] ; then mkdir "${RUN_DIR}/interface" || log_action_end_msg_and_exit 1 "Error creating directory ${RUN_DIR}/interface" fi - [ -x /sbin/restorecon ] && /sbin/restorecon "${RUN_DIR}/interface" "${RUN_DIR}/resolv.conf "${RUN_DIR}/enable-updates + command -v restorecon >/dev/null && restorecon "${RUN_DIR}/interface" "${RUN_DIR}/resolv.conf "${RUN_DIR}/enable-updates # The interface directory now exists. We are done. return -- 2.45.2
From 1e7f28d3dbdab02c1949f0fa90ce8ce34332f9c7 Mon Sep 17 00:00:00 2001 From: Guillem Jover <guil...@hadrons.org> Date: Mon, 27 Nov 2023 03:55:02 +0100 Subject: [PATCH 3/3] =?UTF-8?q?Fully=20move=20files=20from=20=C2=AB/=C2=BB?= =?UTF-8?q?=20to=20canonical=20=C2=AB/usr=C2=BB=20locations?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of using the dh_movetousr hack, which will eventually disappear and this work will need to be done anyway, do it right away. This means all references use the canonical location, in the packaging, the binary packages, and documentation, so that we avoid pointless indirections from symlinks, and when confronted with such pathnames passing them to stuff like «dpkg -S» will work properly. --- README | 24 +++++++++---------- bin/resolvconf | 6 ++--- debian/NOTES | 2 +- debian/control | 1 - debian/install | 6 ++--- debian/postinst | 2 +- debian/resolvconf-update-bind | 4 ++-- debian/resolvconf.000resolvconf.if-up | 4 ++-- debian/resolvconf.000resolvconf.ppp.ip-down | 4 ++-- debian/resolvconf.000resolvconf.ppp.ip-up | 4 ++-- debian/resolvconf.init | 2 +- ...esolvconf.resolvconf-pull-resolved.service | 4 ++-- debian/resolvconf.resolvconf.if-down | 4 ++-- debian/resolvconf.service | 4 ++-- debian/rules | 2 +- etc/dhcp/dhclient-enter-hooks.d/resolvconf | 10 ++++---- etc/resolvconf/update.d/libc | 4 ++-- man/interface-order.5 | 2 +- 18 files changed, 44 insertions(+), 45 deletions(-) diff --git a/README b/README index 3697c6a..26ec516 100644 --- a/README +++ b/README @@ -243,10 +243,10 @@ configuration. 6. Check /etc/resolv.conf to make sure that its contents make sense. If /etc/resolv.conf is not symlinked to /run/resolvconf/resolv.conf then -a warning message will be printed when /sbin/resolvconf is run. If you want -to keep resolvconf installed but for some reason do not want /etc/resolv.conf -to be symlinked to /run/resolvconf/resolv.conf then you can disable the -warning message by setting REPORT_ABSENT_SYMLINK=no in +a warning message will be printed when /usr/sbin/resolvconf is run. If you +want to keep resolvconf installed but for some reason do not want +/etc/resolv.conf to be symlinked to /run/resolvconf/resolv.conf then you +can disable the warning message by setting REPORT_ABSENT_SYMLINK=no in /etc/default/resolvconf. Order of entries in resolv.conf @@ -330,10 +330,10 @@ Technical overview + update-libc.d/ Scripts to run when the resolv.conf file changes * Symlink /etc/resolv.conf -> /run/resolvconf/resolv.conf -* Configurers of interfaces call /sbin/resolvconf to provide +* Configurers of interfaces call /usr/sbin/resolvconf to provide resolv.conf-like information after the interface is brought up. They call it again to delete the information when the interface is brought - down. /sbin/resolvconf then does the equivalent of + down. /usr/sbin/resolvconf then does the equivalent of "/etc/init.d/resolvconf reload". * "/etc/init.d/resolvconf reload" calls scripts in /etc/resolvconf/update.d/ which update DNS cache configuration file @@ -372,17 +372,17 @@ adapted to work with resolvconf while preserving backward compatibility by introducing a code fragment like the following. MYNAME=foo - if [ -x /sbin/resolvconf ] ; then + if [ -x /usr/sbin/resolvconf ] ; then if [ "$DIRECTION" = "up" ] ; then - echo -n "$RESOLVINFO" | /sbin/resolvconf -a "${IFACE}.${MYNAME}" + echo -n "$RESOLVINFO" | /usr/sbin/resolvconf -a "${IFACE}.${MYNAME}" else - /sbin/resolvconf -d "${IFACE}.${MYNAME}" + /usr/sbin/resolvconf -d "${IFACE}.${MYNAME}" fi else # Do clever things to /etc/resolv.conf fi -/sbin/resolvconf stores the information sent to it and then runs the scripts +/usr/sbin/resolvconf stores the information sent to it and then runs the scripts in /etc/resolvconf/update.d/ . One of the latter generates the libc resolver configuration file. Others generate lists of forwarders for dnsmasq or pdnsd to use. Any other program that needs to take action when resolver information @@ -421,7 +421,7 @@ not lost when resolvconf is installed. Unfortunately this also means that those addresses are not removed when interfaces are brought down. Another way that the resolvconf package helps to address the problem is to -allow other parties to call /sbin/resolvconf as soon as it appears in the +allow other parties to call /usr/sbin/resolvconf as soon as it appears in the filesystem: nameserver information can be registered with resolvconf before the resolvconf's postinst runs. This means that when, for example, dnsmasq and resolvconf are installed in the same dpkg run, and dnsmasq happens to be @@ -523,7 +523,7 @@ The admin can of course disable resolv.conf automagic by deleting the /etc/resolv.conf symlink and putting a static file at that location. Once you have installed resolvconf properly you don't normally need to run -/sbin/resolvconf from the command line. However, I once encountered a +/usr/sbin/resolvconf from the command line. However, I once encountered a situation in which I did that. Perhaps it is a useful illustration. My ISP's nameserver went down and thus my caching nameserver could not resolve names. I knew of another host belonging to my ISP that I could use so I simply did: diff --git a/bin/resolvconf b/bin/resolvconf index 1375a79..54af75b 100755 --- a/bin/resolvconf +++ b/bin/resolvconf @@ -83,7 +83,7 @@ case "$CMD" in --list|-l) ;; -i) - echo $(/lib/resolvconf/list-records) + echo $(/usr/lib/resolvconf/list-records) exit 0 ;; *) @@ -130,7 +130,7 @@ case "$CMD" in fi ;; --list|-l) - for f in $(/lib/resolvconf/list-records) + for f in $(/usr/lib/resolvconf/list-records) do echo "# resolv.conf from $f" cat $f @@ -170,7 +170,7 @@ case "$CMD" in -a) OLD_CONTENT="" [ -f "$IFACE" ] && OLD_CONTENT="$(cat "$IFACE")" - NEW_CONTENT="$(/lib/resolvconf/normalize-resolvconf)" + NEW_CONTENT="$(/usr/lib/resolvconf/normalize-resolvconf)" # Proceed only if content has changed. The test here can't # eliminate 100% of redundant invocations of update scripts # because we don't do any locking; however it certainly does diff --git a/debian/NOTES b/debian/NOTES index 9c942a7..6f2569b 100644 --- a/debian/NOTES +++ b/debian/NOTES @@ -39,7 +39,7 @@ in debian/test-normalization. Loop dangers ------------ Remember the interesting fact that postinst runs dpkg-event.d/foo -which probably runs /sbin/resolvconf which probably runs update.d/foo. +which probably runs /usr/sbin/resolvconf which probably runs update.d/foo. Famous quotations diff --git a/debian/control b/debian/control index 943a326..69f2487 100644 --- a/debian/control +++ b/debian/control @@ -8,7 +8,6 @@ Uploaders: Marco Nenciarini <mnen...@debian.org> Build-Depends: debhelper-compat (= 13), - dh-sequence-movetousr, Homepage: https://salsa.debian.org/debian/resolvconf Vcs-Git: https://salsa.debian.org/debian/resolvconf.git Vcs-Browser: https://salsa.debian.org/debian/resolvconf diff --git a/debian/install b/debian/install index 8bf82a4..7856107 100644 --- a/debian/install +++ b/debian/install @@ -1,5 +1,5 @@ etc -bin/resolvconf sbin -bin/list-records lib/resolvconf +bin/resolvconf usr/sbin +bin/list-records usr/lib/resolvconf bin/dump-debug-info usr/share/resolvconf -bin/normalize-resolvconf lib/resolvconf +bin/normalize-resolvconf usr/lib/resolvconf diff --git a/debian/postinst b/debian/postinst index 40cd101..9202ac7 100755 --- a/debian/postinst +++ b/debian/postinst @@ -96,7 +96,7 @@ case "$1" in cp -a /etc/resolv.conf /etc/resolv.conf.dpkg-old fi # Before creating the link, make sure that the original file is - # at the target of the link. /sbin/resolvconf will overwrite + # at the target of the link. /usr/sbin/resolvconf will overwrite # this when it does an update, of course. if [ ! -e /run/resolvconf/resolv.conf ] ; then cp -aH /etc/resolv.conf /run/resolvconf/resolv.conf diff --git a/debian/resolvconf-update-bind b/debian/resolvconf-update-bind index e6d3f7b..49d4d52 100755 --- a/debian/resolvconf-update-bind +++ b/debian/resolvconf-update-bind @@ -26,7 +26,7 @@ set -e PATH=/usr/sbin:/usr/bin:/sbin:/bin command -v named >/dev/null || exit 0 -[ -x /lib/resolvconf/list-records ] || exit 1 +[ -x /usr/lib/resolvconf/list-records ] || exit 1 [ -f /etc/bind/named.conf.options ] || exit 0 # Defaults @@ -55,7 +55,7 @@ uniquify() } # Get list of records, excluding all those for the loopback interface -RSLVCNFFILES="$(/lib/resolvconf/list-records | sed -e '/^lo$/d' -e '/^lo[.]/d')" +RSLVCNFFILES="$(/usr/lib/resolvconf/list-records | sed -e '/^lo$/d' -e '/^lo[.]/d')" ### Compile semicolon-separated list nameservers ### NMSRVRS="" diff --git a/debian/resolvconf.000resolvconf.if-up b/debian/resolvconf.000resolvconf.if-up index 96045d6..b704a05 100755 --- a/debian/resolvconf.000resolvconf.if-up +++ b/debian/resolvconf.000resolvconf.if-up @@ -5,7 +5,7 @@ # This file is part of the resolvconf package. # -[ -x /sbin/resolvconf ] || exit 0 +[ -x /usr/sbin/resolvconf ] || exit 0 case "$ADDRFAM" in inet|inet6) : ;; @@ -45,5 +45,5 @@ for OPT in $IF_DNS_NAMESERVER ; do done IFS="$STANDARD_IFS" -echo -n "$R" | /sbin/resolvconf -a "${IFACE}.${ADDRFAM}" || : +echo -n "$R" | /usr/sbin/resolvconf -a "${IFACE}.${ADDRFAM}" || : diff --git a/debian/resolvconf.000resolvconf.ppp.ip-down b/debian/resolvconf.000resolvconf.ppp.ip-down index 561ef41..951bb61 100755 --- a/debian/resolvconf.000resolvconf.ppp.ip-down +++ b/debian/resolvconf.000resolvconf.ppp.ip-down @@ -8,7 +8,7 @@ # This file is part of the resolvconf package. # -[ -x /sbin/resolvconf ] || exit 0 +[ -x /usr/sbin/resolvconf ] || exit 0 case "$6" in nm-pptp-service-*|nm-l2tp-service-*|/org/freedesktop/NetworkManager/PPP/*) @@ -17,5 +17,5 @@ case "$6" in ;; esac -/sbin/resolvconf -d "${PPP_IFACE}.pppd" +/usr/sbin/resolvconf -d "${PPP_IFACE}.pppd" diff --git a/debian/resolvconf.000resolvconf.ppp.ip-up b/debian/resolvconf.000resolvconf.ppp.ip-up index c83ea18..af8458b 100755 --- a/debian/resolvconf.000resolvconf.ppp.ip-up +++ b/debian/resolvconf.000resolvconf.ppp.ip-up @@ -8,7 +8,7 @@ # This file is part of the resolvconf package. # -[ -x /sbin/resolvconf ] || exit 0 +[ -x /usr/sbin/resolvconf ] || exit 0 [ "$USEPEERDNS" ] || exit 0 @@ -29,5 +29,5 @@ if [ "$DNS2" ] ; then " fi -echo -n "$R" | /sbin/resolvconf -a "${PPP_IFACE}.pppd" +echo -n "$R" | /usr/sbin/resolvconf -a "${PPP_IFACE}.pppd" diff --git a/debian/resolvconf.init b/debian/resolvconf.init index f18f7ec..a8429d3 100755 --- a/debian/resolvconf.init +++ b/debian/resolvconf.init @@ -23,7 +23,7 @@ # Don't use set -e; check return status instead. -[ -x /sbin/resolvconf ] || exit 0 +[ -x /usr/sbin/resolvconf ] || exit 0 PATH=/usr/sbin:/usr/bin:/sbin:/bin RUN_DIR=/run/resolvconf diff --git a/debian/resolvconf.resolvconf-pull-resolved.service b/debian/resolvconf.resolvconf-pull-resolved.service index e5d8d25..13ef44e 100644 --- a/debian/resolvconf.resolvconf-pull-resolved.service +++ b/debian/resolvconf.resolvconf-pull-resolved.service @@ -1,11 +1,11 @@ [Unit] ConditionPathExists=/run/resolvconf/enable-updates -ConditionFileIsExecutable=/sbin/resolvconf +ConditionFileIsExecutable=/usr/sbin/resolvconf After=systemd-resolved.service [Service] Type=oneshot -ExecStart=+-/bin/sh -c 'cat /run/systemd/resolve/stub-resolv.conf | grep -v edns0 | /sbin/resolvconf -a systemd-resolved' +ExecStart=+-/bin/sh -c 'cat /run/systemd/resolve/stub-resolv.conf | grep -v edns0 | /usr/sbin/resolvconf -a systemd-resolved' [Install] WantedBy=systemd-resolved.service diff --git a/debian/resolvconf.resolvconf.if-down b/debian/resolvconf.resolvconf.if-down index e6d4790..d31407f 100755 --- a/debian/resolvconf.resolvconf.if-down +++ b/debian/resolvconf.resolvconf.if-down @@ -5,7 +5,7 @@ # This file is part of the resolvconf package. # -[ -x /sbin/resolvconf ] || exit 0 +[ -x /usr/sbin/resolvconf ] || exit 0 case "$ADDRFAM" in inet|inet6) : ;; @@ -13,5 +13,5 @@ case "$ADDRFAM" in *) exit 0 ;; esac -/sbin/resolvconf -d "${IFACE}.${ADDRFAM}" || : +/usr/sbin/resolvconf -d "${IFACE}.${ADDRFAM}" || : diff --git a/debian/resolvconf.service b/debian/resolvconf.service index 6efe63e..212bd3a 100644 --- a/debian/resolvconf.service +++ b/debian/resolvconf.service @@ -8,8 +8,8 @@ Wants=network-pre.target [Service] RemainAfterExit=yes -ExecStart=/sbin/resolvconf --enable-updates -ExecStop=/sbin/resolvconf --disable-updates +ExecStart=/usr/sbin/resolvconf --enable-updates +ExecStop=/usr/sbin/resolvconf --disable-updates [Install] WantedBy=sysinit.target diff --git a/debian/rules b/debian/rules index 9daca7d..8211b32 100755 --- a/debian/rules +++ b/debian/rules @@ -14,7 +14,7 @@ override_dh_auto_test: debian/test-normalization execute_after_dh_install: - sed -i 's/^VERSION=.*/VERSION="$(DEB_VERSION)"/' debian/*/sbin/resolvconf + sed -i 's/^VERSION=.*/VERSION="$(DEB_VERSION)"/' debian/*/usr/sbin/resolvconf override_dh_installinit: dh_installinit --no-start diff --git a/etc/dhcp/dhclient-enter-hooks.d/resolvconf b/etc/dhcp/dhclient-enter-hooks.d/resolvconf index 72b2be7..fcbbe0d 100644 --- a/etc/dhcp/dhclient-enter-hooks.d/resolvconf +++ b/etc/dhcp/dhclient-enter-hooks.d/resolvconf @@ -14,7 +14,7 @@ # (D) = master script downs interface # (-) = master script does nothing with this -if [ -x /sbin/resolvconf ] ; then +if [ -x /usr/sbin/resolvconf ] ; then # For safety, first undefine the nasty default make_resolv_conf() make_resolv_conf() { : ; } case "$reason" in @@ -37,7 +37,7 @@ if [ -x /sbin/resolvconf ] ; then R="${R}nameserver $N " done - [ ! "$interface" ] || echo -n "$R" | /sbin/resolvconf -a "${interface}.dhclient" + [ ! "$interface" ] || echo -n "$R" | /usr/sbin/resolvconf -a "${interface}.dhclient" } ;; BOUND6|RENEW6|REBIND6) @@ -66,16 +66,16 @@ if [ -x /sbin/resolvconf ] ; then R="${R}nameserver $N$ZONE_ID " done - [ ! "$interface" ] || echo -n "$R" | /sbin/resolvconf -a "${interface}.ip6.dhclient" + [ ! "$interface" ] || echo -n "$R" | /usr/sbin/resolvconf -a "${interface}.ip6.dhclient" } ;; EXPIRE|FAIL|RELEASE|STOP) # Delete resolv.conf info - [ ! "$interface" ] || /sbin/resolvconf -d "${interface}.dhclient" + [ ! "$interface" ] || /usr/sbin/resolvconf -d "${interface}.dhclient" ;; EXPIRE6|RELEASE6|STOP6) # Delete resolv.conf info - [ ! "$interface" ] || /sbin/resolvconf -d "${interface}.ip6.dhclient" + [ ! "$interface" ] || /usr/sbin/resolvconf -d "${interface}.ip6.dhclient" ;; esac fi diff --git a/etc/resolvconf/update.d/libc b/etc/resolvconf/update.d/libc index 1c4f6bc..e500167 100755 --- a/etc/resolvconf/update.d/libc +++ b/etc/resolvconf/update.d/libc @@ -18,7 +18,7 @@ set -e PATH=/sbin:/bin:/usr/sbin:/usr/bin -[ -x /lib/resolvconf/list-records ] || exit 1 +[ -x /usr/lib/resolvconf/list-records ] || exit 1 # Default override [ -r /etc/default/resolvconf ] && . /etc/default/resolvconf @@ -107,7 +107,7 @@ uniquify_nameserver_list() done } -RSLVCNFFILES="$(/lib/resolvconf/list-records)" +RSLVCNFFILES="$(/usr/lib/resolvconf/list-records)" [ -f "$BASEFILE" ] && RSLVCNFFILES="$RSLVCNFFILES $BASEFILE" diff --git a/man/interface-order.5 b/man/interface-order.5 index b5e176a..2868870 100644 --- a/man/interface-order.5 +++ b/man/interface-order.5 @@ -31,7 +31,7 @@ and .IR libc . (Actually they don't read the file directly; they call the utility program -.I /lib/resolvconf/list-records +.I /usr/lib/resolvconf/list-records which lists records in the specified order and omits the names of empty records.) .SH EXAMPLE -- 2.45.2