[Openvpn-devel,v1] dns: fix systemd dns-updown script

Message ID 20250818164608.39836-1-frank@lichtenheld.com
State New
Headers show
Series [Openvpn-devel,v1] dns: fix systemd dns-updown script | expand

Commit Message

Frank Lichtenheld Aug. 18, 2025, 4:46 p.m. UTC
From: Heiko Hund <heiko@ist.eigentlich.net>

In the resolvconf part of the script there was one instance of a dynamic
variable using _* left. The _* ones do not work as the regular ones, but
only when you directly place them within ${!}, not indirectly using a
variable.

Convert the code to use a loop and a check, like in all the other places
in the script.

Change-Id: Id800cad0e92e0abc0d96079fdb5a9d57578e1446
Signed-off-by: Heiko Hund <heiko@ist.eigentlich.net>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
---

This change was reviewed on Gerrit and approved by at least one
developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1144
This mail reflects revision 1 of this Change.

Acked-by according to Gerrit (reflected above):
Frank Lichtenheld <frank@lichtenheld.com>

Comments

Gert Doering Aug. 19, 2025, 10:51 a.m. UTC | #1
In addition to the ACK from Frank I tested this on a "Debian Unstable"
system, after "apt install resolvconf" gave me a resolvconf binary
(and kicked out systemd-resolvconf).  Does not work without the patch,
with the error message reported by Ralf Hildebrandt on -users, works
with the patch.

Your patch has been applied to the master branch.

commit 72a0e6f94f16a6dcfe2b445758d42dedaba11b92
Author: Heiko Hund
Date:   Mon Aug 18 18:46:08 2025 +0200

     dns: fix systemd dns-updown script

     Signed-off-by: Heiko Hund <heiko@ist.eigentlich.net>
     Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
     Message-Id: <20250818164608.39836-1-frank@lichtenheld.com>
     URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg32621.html
     Signed-off-by: Gert Doering <gert@greenie.muc.de>


--
kind regards,

Gert Doering

Patch

diff --git a/distro/dns-scripts/systemd-dns-updown.sh b/distro/dns-scripts/systemd-dns-updown.sh
index 9006e28..ed3947a 100644
--- a/distro/dns-scripts/systemd-dns-updown.sh
+++ b/distro/dns-scripts/systemd-dns-updown.sh
@@ -189,11 +189,13 @@ 
             domains+="${!domain_var} "
         done
         {
+            local i=1
             local maxns=3
-            local server_var=dns_server_${n}_address_*
-            for addr_var in ${!server_var}; do
-                [ $((maxns--)) -gt 0 ] || break
+            while [ "${i}" -le "${maxns}" ]; do
+                local addr_var=dns_server_${n}_address_${i}
+                [ -n "${!addr_var}" ] || break
                 echo "nameserver ${!addr_var}"
+                i=$((i+1))
             done
             [ -z "$domains" ] || echo "search $domains"
         } | /sbin/resolvconf -a "$dev"