Message ID | 20240809192257.24208-1-gert@greenie.muc.de |
---|---|
State | Accepted |
Headers | show |
Series | [Openvpn-devel,v1] Use a more robust way to get dco-win version | expand |
Stared at code here and on the driver side, looks very reasonable and also backward-compatible in both directions. Not actually tested, just test compiled via GHA. Your patch has been applied to the master and release/2.6 branch (long-term compat). commit e5a8ea36a0228c30cdbee8791d44a1f0fbaffa9f (master) commit 41fe48585ebd005e65d191452c2860ab9c089c55 (release/2.6) Author: Lev Stipakov Date: Fri Aug 9 21:22:56 2024 +0200 Use a more robust way to get dco-win version Signed-off-by: Lev Stipakov <lev@openvpn.net> Acked-by: Gert Doering <gert@greenie.muc.de> Message-Id: <20240809192257.24208-1-gert@greenie.muc.de> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29009.html Signed-off-by: Gert Doering <gert@greenie.muc.de> -- kind regards, Gert Doering
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 = CreateFile("\\\\.\\ovpn-dco", GENERIC_READ | GENERIC_WRITE, - 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 = CreateFile("\\\\.\\ovpn-dco-ver", GENERIC_READ, + 0, NULL, OPEN_EXISTING, 0, NULL); + + if (h == INVALID_HANDLE_VALUE) + { + /* fallback to a "normal" device, this will fail if device is already in use */ + h = CreateFile("\\\\.\\ovpn-dco", GENERIC_READ, + 0, NULL, OPEN_EXISTING, 0, NULL); + } if (h == INVALID_HANDLE_VALUE) {