From patchwork Fri Aug 9 19:22:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 3783 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:1d89:b0:5a1:d4fc:4ac6 with SMTP id hp9csp1695348mab; Fri, 9 Aug 2024 12:23:25 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUoDtfg84RtdcRnhU7Z6XujMlosJxUgZmqFrPELYJRSTLJUC7ZqwhPzdBuXPcpX4HoB7DW+Zs6tJD3ZliiWpMgUY4OBst8= X-Google-Smtp-Source: AGHT+IEUryePO9IUhNq5uZqN1EsMC80IJjiujykYKU9SXb36QRngmzFeShb+Mn1bo2lRjMo9eQb+ X-Received: by 2002:a17:90a:d149:b0:2cd:8fcd:8474 with SMTP id 98e67ed59e1d1-2d1e81098b6mr1593372a91.5.1723231404911; Fri, 09 Aug 2024 12:23:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1723231404; cv=none; d=google.com; s=arc-20160816; b=brVeLxGh1lMWYjLCanYuVoBQDBrAhzk6dGlsUOzwqqIVgI5PlImHhiCCX3QvYQYnHx qXAsU8JW2Q7wrVN5lu2MP19ctmjSmoRfDIq13bNmstPEPQpY/wPtf++tM1ChFyiLAG1u MYRJLBeNo+yinNHyvJj99zsOGXpZXPQ+iCvOOsB0JUTFhdL1fIDLpMq3kcFQYKTD3eKV JULhDuLHWMmvl9VupzW9ziknhqNDCFEGIHDi3FPORbgqDL88XV4uClkhgwOw6YgKzUS3 wS91W4iMJQp39Nj4P47QOJ2IVzclgomwn5u61EgegK91kKWbQew0W9YfQmybFdAOxRhO VHRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:dkim-signature; bh=iezBGGqFdcUBjJ+vH742CNmoXoY50EN9/6oYFIRlEA8=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=T+WpXabw9wAxn9T5oOYc2xek3bjEMOj9k6Gtg8ddvTQRfEI91cFNjZbHzDQ5Y4gVj4 VQkeyhsUgWV9RDMypuvzL4+wKb3QNiKB3d6BI1PlDkb+2AMQuO7jD+7y6STb0sOsatTL +m18iu56zFfpQLmTkND0HVKLwqSlinxaQ/8AdcL740TO33pnoL/7F0PONI5F0VaeWqrA 8r09jTA2ttH09k8Cusch9HRMjHYJBZOQ8E7qCc7EBCtCLaegNg/D5f3ODEJ820gU6SA7 XXp55CQVdYratJ8y9RaIe5LJPRFdLXCwKLwDE7DFhhNb4D0aW4QnWHmJX79gOLUPsF9u kbKw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=i3iBvJVJ; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=hILvHY6X; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=muc.de Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2d1c9dba962si1142055a91.126.2024.08.09.12.23.24 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Aug 2024 12:23:24 -0700 (PDT) Received-SPF: pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) client-ip=216.105.38.7; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=i3iBvJVJ; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=hILvHY6X; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=muc.de Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1scVCe-0004T5-LH; Fri, 09 Aug 2024 19:23:08 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1scVCc-0004Sl-Q6 for openvpn-devel@lists.sourceforge.net; Fri, 09 Aug 2024 19:23:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=rKhBPo8B94PcupfNZQtt2RwVy/0m1m/gS3qU2v2AZiY=; b=i3iBvJVJ++IGFVxuvSJGimC9hS MPPkI2oBGdjaDfsD+gsEp327cwswuGQlzQ+kqqosvUGdX/3n5pBOZ4fEK1B84Yu592K/2LHMysy2/ GzGcAgwihKJrRTkYeNkdF6wxgPOD5qqbv7k04Zn6QjxJIxIXWthiqaO0o18ClRidraNI=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID: Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=rKhBPo8B94PcupfNZQtt2RwVy/0m1m/gS3qU2v2AZiY=; b=hILvHY6XbuP25juQq5AXTb5FUh r1Rcjp+j20SGcf89ypcdz2hKE/+ONhjnrLpaGYc3nM5G929/spToOtBfkGVUucICm8HH2ujf3RePQ l+lbP825MyHLHux7ddcKYhKn93t24nBrhINw0GGNbvDxGEO9QPPCIV+o3/pLXqiS7XYE=; Received: from dhcp-174.greenie.muc.de ([193.149.48.174] helo=blue.greenie.muc.de) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1scVCb-0001cJ-04 for openvpn-devel@lists.sourceforge.net; Fri, 09 Aug 2024 19:23:06 +0000 Received: from blue.greenie.muc.de (localhost [127.0.0.1]) by blue.greenie.muc.de (8.17.1.9/8.17.1.9) with ESMTP id 479JMvpt024218 for ; Fri, 9 Aug 2024 21:22:57 +0200 Received: (from gert@localhost) by blue.greenie.muc.de (8.17.1.9/8.17.1.9/Submit) id 479JMvSS024217 for openvpn-devel@lists.sourceforge.net; Fri, 9 Aug 2024 21:22:57 +0200 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Fri, 9 Aug 2024 21:22:56 +0200 Message-ID: <20240809192257.24208-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.44.2 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Score: -0.0 (/) X-Spam-Report: Spam detection software, running on the system "util-spamd-1.v13.lw.sourceforge.com", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Lev Stipakov 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. Content analysis details: (-0.0 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record X-Headers-End: 1scVCb-0001cJ-04 Subject: [Openvpn-devel] [PATCH v1] Use a more robust way to get dco-win version X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: =?utf-8?q?1806939093263103277?= X-GMAIL-MSGID: =?utf-8?q?1806939093263103277?= From: Lev Stipakov 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 --- This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master. Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/723 This mail reflects revision 1 of this Change. Acked-by according to Gerrit (reflected above): 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) {