]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
dns: fix systemd dns-updown script
authorHeiko Hund <heiko@ist.eigentlich.net>
Mon, 18 Aug 2025 16:46:08 +0000 (18:46 +0200)
committerGert Doering <gert@greenie.muc.de>
Tue, 19 Aug 2025 10:27:50 +0000 (12:27 +0200)
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>
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>
distro/dns-scripts/systemd-dns-updown.sh

index 9006e2857f76f3382cfbe5852a0915869067fdfa..ed3947a0c7c4130d1bc6117522f5f3a799695aa4 100644 (file)
@@ -189,11 +189,13 @@ function do_resolvconf {
             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"