Browse code

dns: fix systemd dns-updown script

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>

Heiko Hund authored on 2025/08/19 01:46:08
Showing 1 changed files
... ...
@@ -189,11 +189,13 @@ function do_resolvconf {
189 189
             domains+="${!domain_var} "
190 190
         done
191 191
         {
192
+            local i=1
192 193
             local maxns=3
193
-            local server_var=dns_server_${n}_address_*
194
-            for addr_var in ${!server_var}; do
195
-                [ $((maxns--)) -gt 0 ] || break
194
+            while [ "${i}" -le "${maxns}" ]; do
195
+                local addr_var=dns_server_${n}_address_${i}
196
+                [ -n "${!addr_var}" ] || break
196 197
                 echo "nameserver ${!addr_var}"
198
+                i=$((i+1))
197 199
             done
198 200
             [ -z "$domains" ] || echo "search $domains"
199 201
         } | /sbin/resolvconf -a "$dev"