From: "cron2 (Code Review)" Date: Tue, 13 Aug 2024 06:55:19 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641..., lstipakov@...277... Message-ID: <45fabc205c9ac7fb05916ee2e2738e2ccbd67a6c-EmailReplacePatchSet-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="gIklQw6VHZk="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: Use a more robust way to get dco-win version List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: stipa , plaisthos , flichtenheld Cc: openvpn-devel --gIklQw6VHZk= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has uploaded a new patch set (#2) to the change originally created by= stipa. ( http://gerrit.openvpn.net/c/openvpn/+/723?usp=3Demail ) The following approvals got outdated and were removed: Code-Review+2 by cron2 Change subject: Use a more robust way to get dco-win version ...................................................................... Use a more robust way to get dco-win version The current way doesn't work if the device is already in use. Starting from 1.3.0, dco-win creates a non-exclusive control device \\.\ovpn-dco-ver which can be opened by multiple apps and supports a single IOCTL to get a version number. https://github.com/OpenVPN/ovpn-dco-win/pull/76 This will be expecially handy later when checking which features driver supports. Change-Id: Ieb6f3a9d14d76000c1caf8ee1e959c6d0de832bf Signed-off-by: Lev Stipakov Acked-by: Gert Doering Message-Id: <20240809192257.24208-1-gert@...1296...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29= 009.html Signed-off-by: Gert Doering --- M src/openvpn/dco_win.c 1 file changed, 10 insertions(+), 3 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/23/723/2 diff --git a/src/openvpn/dco_win.c b/src/openvpn/dco_win.c index e3ada76..3ec946f 100644 --- a/src/openvpn/dco_win.c +++ b/src/openvpn/dco_win.c @@ -389,9 +389,16 @@ OVPN_VERSION version; ZeroMemory(&version, sizeof(OVPN_VERSION)); - /* try to open device by symbolic name */ - HANDLE h =3D CreateFile("\\\\.\\ovpn-dco", GENERIC_READ | GENERIC_WRIT= E, - 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_SYSTEM | = FILE_FLAG_OVERLAPPED, NULL); + /* first, try a non-exclusive control device, available from 1.3.0 */ + HANDLE h =3D CreateFile("\\\\.\\ovpn-dco-ver", GENERIC_READ, + 0, NULL, OPEN_EXISTING, 0, NULL); + + if (h =3D=3D INVALID_HANDLE_VALUE) + { + /* fallback to a "normal" device, this will fail if device is alre= ady in use */ + h =3D CreateFile("\\\\.\\ovpn-dco", GENERIC_READ, + 0, NULL, OPEN_EXISTING, 0, NULL); + } if (h =3D=3D INVALID_HANDLE_VALUE) { -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/723?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: Ieb6f3a9d14d76000c1caf8ee1e959c6d0de832bf Gerrit-Change-Number: 723 Gerrit-PatchSet: 2 Gerrit-Owner: stipa Gerrit-Reviewer: cron2 Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-MessageType: newpatchset --gIklQw6VHZk= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 uploaded patch set #2 to the change originally cr= eated by stipa.

View Change

The following approvals got outdated and= were removed: Code-Review+2 by cron2

Use a more robust way to get dco-win version

= The current way doesn't work if the device is already in use.

St= arting from 1.3.0, dco-win creates a non-exclusive
control device \\.\ov= pn-dco-ver which can be opened by
multiple apps and supports a single IO= CTL to get
a version number.

https://github.com/OpenVPN/ovpn-dco-= win/pull/76

This will be expecially handy later when checking which<= br>features driver supports.

Change-Id: Ieb6f3a9d14d76000c1caf8ee1e9= 59c6d0de832bf
Signed-off-by: Lev Stipakov <lev@...515...>
Acked= -by: Gert Doering <gert@...1296...>
Message-Id: <20240809192257= .24208-1-gert@...1296...>
URL: https://www.mail-archive.com/openvpn-d= evel@lists.sourceforge.net/msg29009.html
Signed-off-by: Gert Doering <= ;gert@...1296...>
---
M src/openvpn/dco_win.c
1 file changed, 1= 0 insertions(+), 3 deletions(-)

git pull ssh://gerrit.openvpn.net=
:29418/openvpn refs/changes/23/723/2
diff --git a/src/openvpn/dco_w=
in.c b/src/openvpn/dco_win.c
index e3ada76..3ec946f 100644<= /span>
--- a/src/openvpn/dco_win.c
+++ b/src/openv= pn/dco_win.c
@@ -389,9 +389,16 @@
OVPN= _VERSION version;
ZeroMemory(&version, sizeof(OVPN= _VERSION));

- /* try to open device by symbolic name */
- HANDLE h =3D CreateFile("\\\\.\\ov= pn-dco", GENERIC_READ | GENERIC_WRITE,
- 0, NULL, OPEN_EXISTING, FIL= E_ATTRIBUTE_SYSTEM | FILE_FLAG_OVERLAPPED, NULL);
+ /* first, try a non-exclusive control dev= ice, available from 1.3.0 */
+ HANDLE h =3D CreateFile("\\\\.\\ovpn-dco-ver", GENER= IC_READ,
+ = 0, NULL, OPEN_EXISTING, 0, NULL);
+
+ if (h =3D=3D INVALID_HANDLE_VALUE)
+ {
+ /* fallback to a "normal" device, this wil= l fail if device is already in use */
+ h =3D CreateFile("\\\\.\\ovpn-dco", GEN= ERIC_READ,
+ = 0, NULL, OPEN_EXISTING, 0, NULL);
+ }

if= (h =3D=3D INVALID_HANDLE_VALUE)
{

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

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ieb6f3a9d14d76000c1caf8ee1e9= 59c6d0de832bf
Gerrit-Change-Number: 723
Gerrit-PatchSet: 2
Gerrit-Owner: stipa <lstipakov@...277...>= ;
Gerrit-Reviewer: cron2 <gert@...1296...>=
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
--gIklQw6VHZk=--