From: "cron2 (Code Review)" Date: Tue, 15 Jul 2025 14:02:47 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., heiko@...515..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <37f4a196cbab5bd98b76878583bf2ce543d185e6-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="5mvtQ2ViQxU="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: mac dns: compare servers before restoring backup List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: d12fk Cc: flichtenheld , plaisthos , openvpn-devel --5mvtQ2ViQxU= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/10= 75?usp=3Demail ) Change subject: mac dns: compare servers before restoring backup ...................................................................... mac dns: compare servers before restoring backup In case anything changed the global DNS server addresses, while the tunnel was connected, do not restore the backup of the global DNS configuration we made when connecting. Doing so would likely change DNS to something unexpected. Instead just clear the backup and leave a message in the log. Change-Id: I1aabd62e60dd18408a57baccbb0f4ebd6d2f8d67 Signed-off-by: Heiko Hund Acked-by: Frank Lichtenheld Message-Id: <20250711152309.286177-1-frank@...2641...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg32= 110.html Signed-off-by: Gert Doering --- M distro/dns-scripts/macos-dns-updown.sh 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/distro/dns-scripts/macos-dns-updown.sh b/distro/dns-scripts/ma= cos-dns-updown.sh index 56f1009..73bbee9 100644 --- a/distro/dns-scripts/macos-dns-updown.sh +++ b/distro/dns-scripts/macos-dns-updown.sh @@ -111,6 +111,10 @@ property_value State:/Network/Global/DNS SearchDomains } +function get_server_addresses { + property_value "$(primary_dns_key)" ServerAddresses +} + function set_search_domains { [ -n "$1" ] || return local dns_key=3D$(primary_dns_key) @@ -239,11 +243,10 @@ function unset_dns { local n=3D"$(find_compat_profile)" - local addresses=3D"$(addresses_string $n)" - local search_domains=3D"$(search_domains_string $n)" local match_domains=3D"$(match_domains_string $n)" if [ -n "$match_domains" ]; then + local search_domains=3D"$(search_domains_string $n)" echo "remove ${itf_dns_key}" | /usr/sbin/scutil unset_search_domains "$search_domains" else @@ -252,8 +255,15 @@ [[ "${dns_backup_key}" =3D~ ${dev}/ ]] || return local cmds=3D"" - cmds+=3D"get ${dns_backup_key}\n" - cmds+=3D"set $(primary_dns_key)\n" + local servers=3D"$(get_server_addresses)" + local addresses=3D"$(addresses_string $n)" + # Only restore backup if the server addresses match + if [ "${servers}" =3D "${addresses}" ]; then + cmds+=3D"get ${dns_backup_key}\n" + cmds+=3D"set $(primary_dns_key)\n" + else + echo "not restoring global DNS configuration, server addresses= have changed" + fi cmds+=3D"remove ${dns_backup_key}\n" echo -e "${cmds}" | /usr/sbin/scutil fi -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1075?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: I1aabd62e60dd18408a57baccbb0f4ebd6d2f8d67 Gerrit-Change-Number: 1075 Gerrit-PatchSet: 5 Gerrit-Owner: d12fk Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-MessageType: merged --5mvtQ2ViQxU= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 submitted this change.

View Change

mac dns: compare servers before restoring bac=
kup

In case anything changed the global DNS server addresses, while = the
tunnel was connected, do not restore the backup of the global DNSconfiguration we made when connecting. Doing so would likely change
DNS= to something unexpected. Instead just clear the backup and leave
a mess= age in the log.

Change-Id: I1aabd62e60dd18408a57baccbb0f4ebd6d2f8d67=
Signed-off-by: Heiko Hund <heiko@...2662...>
Acked-by: Frank L= ichtenheld <frank@...2641...>
Message-Id: <20250711152309.28617= 7-1-frank@...2641...>
URL: https://www.mail-archive.com/openvpn-devel= @lists.sourceforge.net/msg32110.html
Signed-off-by: Gert Doering <ger= t@...1296...>
---
M distro/dns-scripts/macos-dns-updown.sh
1 fi= le changed, 14 insertions(+), 4 deletions(-)

diff --git a/distro/dns-scripts/macos-dns-updown.sh b/distro/dns-scripts=
/macos-dns-updown.sh
index 56f1009..73bbee9 100644--- a/distro/dns-scripts/macos-dns-updown.sh
+++ b/= distro/dns-scripts/macos-dns-updown.sh
@@ -111,6 +111,10 @@=
property_value State:/Network/Global/DNS SearchDomain= s
}

+function get_server_addresses {
+ property_value "$(primary_dns_key)&= quot; ServerAddresses
+}
+
function set_search_domains {
[ -n "$1" ] = || return
local dns_key=3D$(primary_dns_key)@@ -239,11 +243,10 @@

function un= set_dns {
local n=3D"$(find_compat_profile)"=
- local addresses= =3D"$(addresses_string $n)"
- local search_domains=3D"$(search_domains_string $n= )"
local match_domains=3D"$(match_domains_st= ring $n)"

if [ -n "$match_= domains" ]; then
+ local search_domains=3D"$(search_domains_string $n)"
echo "remove ${itf_dns_key}" | /usr/sbin/s= cutil
unset_search_domains "$search_domains&q= uot;
else
@@ -252,8 +255,15 @@<= br> [[ "${dns_backup_key}" =3D~ ${dev}/ ]] || retur= n

local cmds=3D""
- cmds+=3D"get = ${dns_backup_key}\n"
- cmds+=3D"set $(primary_dns_key)\n"
+ local servers=3D"$(get_se= rver_addresses)"
+ local addresses=3D"$(addresses_string $n)"
+ # Only restore backup if= the server addresses match

+ if [ "${servers}" =3D "${addresses}" ];= then
+ cm= ds+=3D"get ${dns_backup_key}\n"
+ cmds+=3D"set $(primary_dns_key)\n&qu= ot;
+ else

+ echo "= not restoring global DNS configuration, server addresses have changed"=
+ fi cmds+=3D"remove ${dns_backup_key}\n"
<= span> echo -e "${cmds}" | /usr/sbin/scutil
fi

To view, visit change 1075. To un= subscribe, or for help writing mail filters, visit settings.

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I1aabd62e60dd18408a57baccbb0= f4ebd6d2f8d67
Gerrit-Change-Number: 1075
Gerrit-PatchSet: 5
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: merged
--5mvtQ2ViQxU=--