From: "cron2 (Code Review)" Date: Thu, 26 Jun 2025 09:26:37 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., heiko@...515..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <9c5fcf9f5d86195510e4cf8f6ea62e093c472110-EmailReplacePatchSet-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="NSsfH6sHqdU="; charset=UTF-8 Subject: [Openvpn-devel] [XS] Change in openvpn[master]: fix macOS dns-updown handling of parallel full redirects List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: d12fk , plaisthos , flichtenheld Cc: openvpn-devel --NSsfH6sHqdU= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has uploaded a new patch set (#3) to the change originally created by= d12fk. ( http://gerrit.openvpn.net/c/openvpn/+/1066?usp=3Demail ) The following approvals got outdated and were removed: Code-Review+2 by plaisthos Change subject: fix macOS dns-updown handling of parallel full redirects ...................................................................... fix macOS dns-updown handling of parallel full redirects The script didn't handle scenarios well where two or more parallel VPN connections want to replace the default DNS server. The DNS configuration has a chance to get broken by the connections going down in a different order than they came up in. Disallowing all but the first connection to modify the default DNS server will effectively prevent this issue. While it may break DNS for the latter connections, it is the best we can do without knowing specifics about the configurations. Change-Id: I7b413578a8fc0c65fca26f72b901a9f7bc34b137 Signed-off-by: Heiko Hund Acked-by: Arne Schwabe Message-Id: <20250626091959.23505-1-gert@...1296...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31= 988.html Signed-off-by: Gert Doering --- M distro/dns-scripts/macos-dns-updown.sh 1 file changed, 9 insertions(+), 0 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/66/1066/3 diff --git a/distro/dns-scripts/macos-dns-updown.sh b/distro/dns-scripts/ma= cos-dns-updown.sh index 89d6882..c15abaa 100644 --- a/distro/dns-scripts/macos-dns-updown.sh +++ b/distro/dns-scripts/macos-dns-updown.sh @@ -30,6 +30,7 @@ itf_dns_key=3D"State:/Network/Service/openvpn-${dev}/DNS" dns_backup_key=3D"State:/Network/Service/openvpn-${dev}/DnsBackup" +dns_backup_key_pattern=3D"State:/Network/Service/openvpn-.*/DnsBackup" function primary_dns_key { local uuid=3D$(echo "show State:/Network/Global/IPv4" | /usr/sbin/scut= il | grep "PrimaryService" | cut -d: -f2 | xargs) @@ -166,6 +167,11 @@ echo -e "${cmds}" | /usr/sbin/scutil set_search_domains "$search_domains" else + echo list ${dns_backup_key_pattern} | /usr/sbin/scutil | grep -q '= no key' || { + echo "setting DNS failed, already redirecting to another tunne= l" + exit 1 + } + local cmds=3D"" cmds+=3D"get $(primary_dns_key)\n" cmds+=3D"set ${dns_backup_key}\n" @@ -200,6 +206,9 @@ echo "remove ${itf_dns_key}" | /usr/sbin/scutil unset_search_domains "$search_domains" else + # Do not unset if this tunnel did not set/backup DNS before + echo list ${dns_backup_key} | /usr/sbin/scutil | grep -qv 'no key'= || return + local cmds=3D"" cmds+=3D"get ${dns_backup_key}\n" cmds+=3D"set $(primary_dns_key)\n" -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1066?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I7b413578a8fc0c65fca26f72b901a9f7bc34b137 Gerrit-Change-Number: 1066 Gerrit-PatchSet: 3 Gerrit-Owner: d12fk Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-MessageType: newpatchset --NSsfH6sHqdU= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 uploaded patch set #3 to the change originally cr= eated by d12fk.

View Change

The following approvals got outdated an= d were removed: Code-Review+2 by plaisthos

fix macOS dns-updown handling of parallel full r=
edirects

The script didn't handle scenarios well where two or mo= re parallel VPN
connections want to replace the default DNS server. The = DNS configuration
has a chance to get broken by the connections going do= wn in a different
order than they came up in.

Disallowing all but= the first connection to modify the default DNS server
will effectively = prevent this issue. While it may break DNS for the
latter connections, i= t is the best we can do without knowing specifics
about the configuratio= ns.

Change-Id: I7b413578a8fc0c65fca26f72b901a9f7bc34b137
Signed-o= ff-by: Heiko Hund <heiko@...2662...>
Acked-by: Arne Schwabe <ar= ne-openvpn@...1227...>
Message-Id: <20250626091959.23505-1-gert@...1186...= .1296...>
URL: https://www.mail-archive.com/openvpn-devel@...1011...= eforge.net/msg31988.html
Signed-off-by: Gert Doering <gert@...1296...= >
---
M distro/dns-scripts/macos-dns-updown.sh
1 file changed, = 9 insertions(+), 0 deletions(-)

git pull ssh://gerrit.openvpn.net=
:29418/openvpn refs/changes/66/1066/3
diff --git a/distro/dns-scrip=
ts/macos-dns-updown.sh b/distro/dns-scripts/macos-dns-updown.sh
<= span>index 89d6882..c15abaa 100644
--- a/distro/dns-scripts= /macos-dns-updown.sh
+++ b/distro/dns-scripts/macos-dns-upd= own.sh
@@ -30,6 +30,7 @@

= itf_dns_key=3D"State:/Network/Service/openvpn-${dev}/DNS"=
dns_backup_key=3D"State:/Network/Service/openvpn-${dev}/Dns= Backup"
+dns_bac= kup_key_pattern=3D"State:/Network/Service/openvpn-.*/DnsBackup"

function primary_dns_key {
local uuid=3D$(echo "show State:/Network/Global/IPv4" | /u= sr/sbin/scutil | grep "PrimaryService" | cut -d: -f2 | xargs)
@@ -166,6 +167,11 @@
echo -e "${= cmds}" | /usr/sbin/scutil
set_search_domains = "$search_domains"
else
+ echo list ${dns_backup_key_patter= n} | /usr/sbin/scutil | grep -q 'no key' || {
+ echo "setting DNS failed= , already redirecting to another tunnel"
+ exit 1
+ }
+
local cmds=3D"" cmds+=3D"get $(primary_dns_key)\n"
cmds+=3D"set ${dns_backup_key}\n"

@@ = -200,6 +206,9 @@
echo "remove ${itf_dns_key}&= quot; | /usr/sbin/scutil
unset_search_domains &quo= t;$search_domains"
else
+ # Do not unset if this tunnel did not= set/backup DNS before
= +
local cmds=3D""
= cmds+=3D"get ${dns_backup_key}\n"
cmd= s+=3D"set $(primary_dns_key)\n"

=

To view, visit change 1066. To unsubscribe, or for help writing mail filters= , visit settings.

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I7b413578a8fc0c65fca26f72b90= 1a9f7bc34b137
Gerrit-Change-Number: 1066
Gerrit-PatchSet: 3
Gerrit-Owner: d12fk <heiko@...515...>
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-MessageType: newpatchset
--NSsfH6sHqdU=--