From: "cron2 (Code Review)" Date: Tue, 15 Jul 2025 14:10:10 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., heiko@...515..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <6d4379c8a29df93cc939222cbd8cb3e532f778b0-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="nItMJyzDBGw="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: mac dns: do not run dns-updown in parallel List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: d12fk Cc: plaisthos , flichtenheld , openvpn-devel --nItMJyzDBGw= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/10= 76?usp=3Demail ) Change subject: mac dns: do not run dns-updown in parallel ...................................................................... mac dns: do not run dns-updown in parallel In case more than one openvpn connection is coming up or going down at the same time, there is potential for breakage, since the operations performed are not atomic. Introduce a locking mechanism, which let's scripts run in sequence, to prevent races between them. Change-Id: I7adfaa08df6a17545cca8264d7230b5e65e49719 Signed-off-by: Heiko Hund Acked-by: Arne Schwabe Message-Id: <20250711100700.241668-1-frank@...2641...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg32= 108.html Signed-off-by: Gert Doering --- M distro/dns-scripts/macos-dns-updown.sh 1 file changed, 17 insertions(+), 0 deletions(-) diff --git a/distro/dns-scripts/macos-dns-updown.sh b/distro/dns-scripts/ma= cos-dns-updown.sh index 73bbee9..fb17b2b0 100644 --- a/distro/dns-scripts/macos-dns-updown.sh +++ b/distro/dns-scripts/macos-dns-updown.sh @@ -26,6 +26,23 @@ # dns_server_1_sni dns.mycorp.in # +lockdir=3D/var/lock +if [ ! -d "${lockdir}" ]; then + /bin/mkdir "${lockdir}" + /bin/chmod 1777 "${lockdir}" +fi + +i=3D1 +lockfile=3D"${lockdir}/openvpn-dns-updown.lock" +while ! /usr/bin/shlock -f $lockfile -p $$; do + if [ $((++i)) -gt 10 ]; then + echo "dns-updown failed, could not acquire lock" + exit 1 + fi + sleep 0.2 +done +trap "/bin/rm -f ${lockfile}" EXIT + [ -z "${dns_vars_file}" ] || . "${dns_vars_file}" itf_dns_key=3D"State:/Network/Service/openvpn-${dev}/DNS" -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1076?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: I7adfaa08df6a17545cca8264d7230b5e65e49719 Gerrit-Change-Number: 1076 Gerrit-PatchSet: 5 Gerrit-Owner: d12fk Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-MessageType: merged --nItMJyzDBGw= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 submitted this change.

View Change

mac dns: do not run dns-updown in parallel
In case more than one openvpn connection is coming up or going down at=
the same time, there is potential for breakage, since the operationsperformed are not atomic.

Introduce a locking mechanism, which let&= #39;s scripts run in sequence, to
prevent races between them.

Cha= nge-Id: I7adfaa08df6a17545cca8264d7230b5e65e49719
Signed-off-by: Heiko H= und <heiko@...2662...>
Acked-by: Arne Schwabe <arne-openvpn@...493...= 1227...>
Message-Id: <20250711100700.241668-1-frank@...2641...>=
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/m= sg32108.html
Signed-off-by: Gert Doering <gert@...1296...>
---<= br>M distro/dns-scripts/macos-dns-updown.sh
1 file changed, 17 insertion= s(+), 0 deletions(-)

diff --git a/distro/dns-scripts/macos-dns-updown.sh b/distro/dns-scripts=
/macos-dns-updown.sh
index 73bbee9..fb17b2b0 100644<= br>--- a/distro/dns-scripts/macos-dns-updown.sh
+++ b= /distro/dns-scripts/macos-dns-updown.sh
@@ -26,6 +26,23 @@<= /span>
# dns_server_1_sni dns.mycorp.in
#

+lockdi= r=3D/var/lock
+if [ != -d "${lockdir}" ]; then
+ /bin/mkdir "${lockdir}"
+ /bin/chmod 1777 "${lockdir}"= ;
+fi
+

+i=3D1
+lockfile=3D"${lockdir}/openvpn-dns-updown.lock"
= +while ! /usr/bin/shlock -f $lo= ckfile -p $$; do
+ = if [ $((++i)) -gt 10 ]; then
+ echo "dns-updown failed, could not acquire lock"= ;
+ exit 1

+ fi
+ sleep 0.2
+done
+trap "/bin/rm -f ${lockfile}" EXIT
<= span style=3D"color: hsl(120, 100%, 40%);">+
[ -z "${= dns_vars_file}" ] || . "${dns_vars_file}"
<= /span>
itf_dns_key=3D"State:/Network/Service/openvpn-${dev}/= DNS"

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

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I7adfaa08df6a17545cca8264d72= 30b5e65e49719
Gerrit-Change-Number: 1076
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
--nItMJyzDBGw=--