From patchwork Mon May 5 12:27:06 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 4235 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:e147:b0:656:592e:a137 with SMTP id nw7csp2237347mab; Mon, 5 May 2025 05:27:47 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWxHEozBLLJMT5XzO1FV3RC4hVKQRXQP/X9L+b11cxbWesWnUJ3t9hmzVLrXjB9D2Ci1OozvK0j12I=@openvpn.net X-Google-Smtp-Source: AGHT+IEN4A/nanfuidx1qF/13ARX2YwtmcVjR9OiNskFZKJMDMlgKcKdoFxePMWwxSV8owsMxgtV X-Received: by 2002:a05:6830:6f89:b0:72b:9d2d:804 with SMTP id 46e09a7af769-731e567bbeamr6096273a34.26.1746448067443; Mon, 05 May 2025 05:27:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1746448067; cv=none; d=google.com; s=arc-20240605; b=gqGEQ9ztwuhzYoBmlcAxHK76SK/gZn6YbBqDaSitrcOOyqWQ0GdaOhidEAN34xpIKM 0wMn7CFRzkpsnwkugeVTifAPjWLIY10NbXJImlATL9ZHcwoY8I9T1lEa5aBMpwFwDWIB dYRxqVxRlUd6KzO4PDUqM/vLq4bbHvlFPrUBLWijlnlFYcG2+tm4vqioeV41YkNUfTdo xdIGAHiNzN163R2m7il++dvitntSMQEv+NUtrXepns9Hl2oi0s8yocMonoUYISmu+4dx h4lAOgX6o0IADswVCmxqXx3Qy01OupPJ5kF1blkzNTTVFpTC6PuDqGh4bDybaepaNG9z vg5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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:dkim-signature; bh=SFEvreeyz35NZmwPlzBl65jPjG7IAw2D0+relFng84w=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=jL4cZ9k5/OfNIZ6vMNR2+P378PPEoz6tf8fNNXGXXvEAmGZgIMBeE0hAAGQszFYGef OlLkadt06yEAT2a5pi6VCfIhGeObFUydoTXP9lfFyW+vnJm1AsMpgWT1xnX5HgDSNt5P Th/CkMgT1/+ERODv2VdkN7/21QIw9eQerv8lay9lfNu5lNESQTRv/ef2WHDGdiaEfVw5 GxQtU6jkW26QU/AVZJjCdveLoj9ET5Uzvo58eIwzDLZpdnnkg0TVnXb+TN57ONOlVU8h 7w3dm7x+t9rWysh6ztveKLz9mU1TrRgiFHC0RmgvRIWiczWJAmKcmZrytXR1vG0ShNd9 zCvA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b="WLIr/vGo"; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=iA24mGFu; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=CVwTBznW; 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 46e09a7af769-731d34af827si4869361a34.145.2025.05.05.05.27.47 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 May 2025 05:27:47 -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=pass header.i=@lists.sourceforge.net header.s=beta header.b="WLIr/vGo"; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=iA24mGFu; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=CVwTBznW; 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 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.sourceforge.net; s=beta; h=Content-Transfer-Encoding:Content-Type: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Subject:MIME-Version:References:In-Reply-To:Message-ID:Date:To:From:Sender: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=SFEvreeyz35NZmwPlzBl65jPjG7IAw2D0+relFng84w=; b=WLIr/vGow+IzwxR5y8Lo51WKtc XQlFRpO+nENkgHoU3t5WS4VEHNvW47u4w5pvfnFVdXRb/B88RHaMTVv/rtAXYvl/5tDn7QKqtdG/B K00jMd6RjrImC8qdklYRD1bR3Z/vENnCC9s3HoYgHCoGRIsb5pWYDOdT6DYD8WJFhZuA=; Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1uBuv9-0007LS-DR; Mon, 05 May 2025 12:27:43 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1uBuv7-0007LK-Sx for openvpn-devel@lists.sourceforge.net; Mon, 05 May 2025 12:27:41 +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=1wSYIjJK+MQGZBwVH4waTmIW81DmE9AqArgamdU8XpM=; b=iA24mGFu6Gz9K44rGIoBCawgkS G8dI5xjuTT2MeZFHD9kf8ftX20g4JTh7PLHik/JoMa9U9kz68MWAgHq+0MyF1TAlIbEwH9gCxLXfV /3ajX3uksPCwSJEDB+BAqnK3ftNYz7yWN7YhyWRV2Vu4QKNyen902A/B+V4DUbYmRMcY=; 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=1wSYIjJK+MQGZBwVH4waTmIW81DmE9AqArgamdU8XpM=; b=CVwTBznWtcbsH/v0ia3ncKkBed a7MaOuqAdkwDiI0kkxNsXvWuA4uUr3YGoSfAnwG8q8BjyqHE+Dpqtgc5MrHgkXP4PXpbuY/7n4NZI HhjzYJuBQe4URcVpirUWLHtoJsSedzxrwWgf9qlU4a5cOjrXbbG8AOIQf7i+hPFGtT5I=; Received: from [193.149.48.143] (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 1uBuur-0001Ol-11 for openvpn-devel@lists.sourceforge.net; Mon, 05 May 2025 12:27:41 +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 545CRDhU005243 for ; Mon, 5 May 2025 14:27:13 +0200 Received: (from gert@localhost) by blue.greenie.muc.de (8.17.1.9/8.17.1.9/Submit) id 545CRD5a005242 for openvpn-devel@lists.sourceforge.net; Mon, 5 May 2025 14:27:13 +0200 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Mon, 5 May 2025 14:27:06 +0200 Message-ID: <20250505122712.5214-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.49.0 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Score: 1.3 (+) X-Spam-Report: Spam detection software, running on the system "6901ab67b84d", 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 It's 2025, and almost all clients now run on Windows 10 or newer. Instead of displaying: "Windows version 10.0 (Windows 10 or greater), amd64 executable" Content analysis details: (1.3 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 1.3 RDNS_NONE Delivered to internal network by a host with no rDNS X-Headers-End: 1uBuur-0001Ol-11 Subject: [Openvpn-devel] [PATCH v3] win: refactor get_windows_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?1831283528883494272?= X-GMAIL-MSGID: =?utf-8?q?1831283528883494272?= From: Lev Stipakov It's 2025, and almost all clients now run on Windows 10 or newer. Instead of displaying: "Windows version 10.0 (Windows 10 or greater), amd64 executable" we now show the exact build number, e.g.: "Windows version: 10.0.22631,amd64" Remove "pre-Win7" checks in a few places. Change-Id: I39d660ebeec76280e4d4357192b74bf2c0980615 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/+/944 This mail reflects revision 3 of this Change. Acked-by according to Gerrit (reflected above): Gert Doering diff --git a/src/openvpn/options.c b/src/openvpn/options.c index 96119c4..c523649 100644 --- a/src/openvpn/options.c +++ b/src/openvpn/options.c @@ -4846,7 +4846,7 @@ show_windows_version(const unsigned int flags) { struct gc_arena gc = gc_new(); - msg(flags, "Windows version %s", win32_version_string(&gc, true)); + msg(flags, "Windows version: %s", win32_version_string(&gc)); gc_free(&gc); } #endif diff --git a/src/openvpn/ssl.c b/src/openvpn/ssl.c index 23f6423..fd299ef 100644 --- a/src/openvpn/ssl.c +++ b/src/openvpn/ssl.c @@ -2060,7 +2060,7 @@ } buf_printf(&out, "IV_SSL=%s\n", get_ssl_library_version() ); #if defined(_WIN32) - buf_printf(&out, "IV_PLAT_VER=%s\n", win32_version_string(&gc, false)); + buf_printf(&out, "IV_PLAT_VER=%s\n", win32_version_string(&gc)); #else struct utsname u; uname(&u); diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c index 4f7de6c..5186afa 100644 --- a/src/openvpn/tun.c +++ b/src/openvpn/tun.c @@ -5428,11 +5428,8 @@ NETSH_PATH_SUFFIX, adapter_index, print_in6_addr(addr_list[i], 0, &gc)); - /* disable slow address validation on Windows 7 and higher */ - if (win32_version_info() >= WIN_7) - { - argv_printf_cat(&argv, "%s", "validate=no"); - } + /* disable slow address validation */ + argv_printf_cat(&argv, "%s", "validate=no"); /* Treat errors while adding as non-fatal as we do not check for duplicates */ netsh_command(&argv, 1, (i==0) ? M_FATAL : M_NONFATAL); @@ -5498,9 +5495,8 @@ adapter_index, print_in_addr_t(addr_list[i], 0, &gc)); - /* disable slow address validation on Windows 7 and higher */ - /* only for DNS */ - if (is_dns && win32_version_info() >= WIN_7) + /* disable slow address validation for DNS */ + if (is_dns) { argv_printf_cat(&argv, "%s", "validate=no"); } diff --git a/src/openvpn/win32.c b/src/openvpn/win32.c index edac71e..caa14d6 100644 --- a/src/openvpn/win32.c +++ b/src/openvpn/win32.c @@ -1283,42 +1283,6 @@ return true; } -int -win32_version_info(void) -{ - if (!IsWindowsXPOrGreater()) - { - msg(M_FATAL, "Error: Windows version must be XP or greater."); - } - - if (!IsWindowsVistaOrGreater()) - { - return WIN_XP; - } - - if (!IsWindows7OrGreater()) - { - return WIN_VISTA; - } - - if (!IsWindows8OrGreater()) - { - return WIN_7; - } - - if (!IsWindows8Point1OrGreater()) - { - return WIN_8; - } - - if (!IsWindows10OrGreater()) - { - return WIN_8_1; - } - - return WIN_10; -} - typedef enum { ARCH_X86, ARCH_AMD64, @@ -1420,52 +1384,40 @@ } } +typedef LONG (WINAPI *RtlGetVersionPtr)(PRTL_OSVERSIONINFOW); + const char * -win32_version_string(struct gc_arena *gc, bool add_name) +win32_version_string(struct gc_arena *gc) { - int version = win32_version_info(); - struct buffer out = alloc_buf_gc(256, gc); - - switch (version) + HMODULE hMod = GetModuleHandleW(L"ntdll.dll"); + if (!hMod) { - case WIN_XP: - buf_printf(&out, "5.1%s", add_name ? " (Windows XP)" : ""); - break; - - case WIN_VISTA: - buf_printf(&out, "6.0%s", add_name ? " (Windows Vista)" : ""); - break; - - case WIN_7: - buf_printf(&out, "6.1%s", add_name ? " (Windows 7)" : ""); - break; - - case WIN_8: - buf_printf(&out, "6.2%s", add_name ? " (Windows 8)" : ""); - break; - - case WIN_8_1: - buf_printf(&out, "6.3%s", add_name ? " (Windows 8.1)" : ""); - break; - - case WIN_10: - buf_printf(&out, "10.0%s", add_name ? " (Windows 10 or greater)" : ""); - break; - - default: - msg(M_NONFATAL, "Unknown Windows version: %d", version); - buf_printf(&out, "0.0%s", add_name ? " (unknown)" : ""); - break; + return "N/A"; } - buf_printf(&out, ", "); + RtlGetVersionPtr fn = (RtlGetVersionPtr)GetProcAddress(hMod, "RtlGetVersion"); + if (!fn) + { + return "N/A"; + } + + RTL_OSVERSIONINFOW rovi = { 0 }; + rovi.dwOSVersionInfoSize = sizeof(rovi); + if (fn(&rovi) != 0) + { + return "N/A"; + } + + struct buffer out = alloc_buf_gc(256, gc); + + buf_printf(&out, "%lu.%lu.%lu", rovi.dwMajorVersion, rovi.dwMinorVersion, rovi.dwBuildNumber); + + buf_printf(&out, ","); arch_t process_arch, host_arch; win32_get_arch(&process_arch, &host_arch); win32_print_arch(process_arch, &out); - buf_printf(&out, " executable"); - if (host_arch != ARCH_NATIVE) { buf_printf(&out, " running on "); diff --git a/src/openvpn/win32.h b/src/openvpn/win32.h index 081beeb..685898c 100644 --- a/src/openvpn/win32.h +++ b/src/openvpn/win32.h @@ -292,20 +292,13 @@ bool win_wfp_uninit(const NET_IFINDEX index, const HANDLE msg_channel); -#define WIN_XP 0 -#define WIN_VISTA 1 -#define WIN_7 2 -#define WIN_8 3 -#define WIN_8_1 4 -#define WIN_10 5 - -int win32_version_info(void); - -/* - * String representation of Windows version number and name, see - * https://msdn.microsoft.com/en-us/library/windows/desktop/ms724832(v=vs.85).aspx +/** + * @brief Get Windows version string with architecture info. + * + * @param gc gc arena to allocate string. + * @return Version string, or "N/A" on failure. */ -const char *win32_version_string(struct gc_arena *gc, bool add_name); +const char *win32_version_string(struct gc_arena *gc); /* * Send the |size| bytes in buffer |data| to the interactive service |pipe|