From patchwork Mon Mar 9 02:17:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Rozman X-Patchwork-Id: 1028 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director12.mail.ord1d.rsapps.net ([172.30.191.6]) by backend30.mail.ord1d.rsapps.net with LMTP id eJP3KVVCZl5PJgAAIUCqbw for ; Mon, 09 Mar 2020 09:19:17 -0400 Received: from proxy5.mail.ord1d.rsapps.net ([172.30.191.6]) by director12.mail.ord1d.rsapps.net with LMTP id AOrXKVVCZl6oTAAAIasKDg ; Mon, 09 Mar 2020 09:19:17 -0400 Received: from smtp19.gate.ord1d ([172.30.191.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy5.mail.ord1d.rsapps.net with LMTP id 6MlgKVVCZl4TNgAA8Zzt7w ; Mon, 09 Mar 2020 09:19:17 -0400 X-Spam-Threshold: 95 X-Spam-Score: 0 X-Spam-Flag: NO X-Virus-Scanned: OK X-Orig-To: openvpnslackdevel@openvpn.net X-Originating-Ip: [216.105.38.7] Authentication-Results: smtp19.gate.ord1d.rsapps.net; iprev=pass policy.iprev="216.105.38.7"; spf=pass smtp.mailfrom="openvpn-devel-bounces@lists.sourceforge.net" smtp.helo="lists.sourceforge.net"; dkim=fail (signature verification failed) header.d=sourceforge.net; dkim=fail (signature verification failed) header.d=sf.net; dkim=fail (signature verification failed) header.d=rozman.si; dmarc=fail (p=none; dis=none) header.from=rozman.si X-Suspicious-Flag: YES X-Classification-ID: 93a7e0e2-6208-11ea-ac83-525400d67fa8-1-1 Received: from [216.105.38.7] ([216.105.38.7:49346] helo=lists.sourceforge.net) by smtp19.gate.ord1d.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id CE/2F-26733-452466E5; Mon, 09 Mar 2020 09:19:17 -0400 Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1jBIIS-00028p-Lr; Mon, 09 Mar 2020 13:18:16 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jBIIP-00027t-LC for openvpn-devel@lists.sourceforge.net; Mon, 09 Mar 2020 13:18:13 +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:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=5YTm2ijJlSE2wKxjBCIzwuLK2IPT4RAPTxWlLX3jmm4=; b=fS6vKmFUaAg4eTaGsJRx6gEoQL Ez4IL+/B7MkG9vZI503KrpFCQNfg/tWALOCW/fk74md7XwrLhodwlkPikQKdJep78PSrOzKiRq3DS 9JuGGuLek7IeCitVhXui6xBe3499IstQSuZLgnZmia3skmY/1QUW1yXlpXL9F4Bnvl2M=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject:Cc:To:From :Sender:Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=5YTm2ijJlSE2wKxjBCIzwuLK2IPT4RAPTxWlLX3jmm4=; b=b 2xuSNAt/PCUsPthCUOrh9jtOcXLu4S09qbMdRogowjoqXtD3fwpRQBgX9SMgfkK8vEwR84c2MXJJT uEErsUeoVjkbb/1srFHCtNTBhobroL/JTQtmmlUpv4K24T0sGunTeGpdXfrLbO2vKYlllDboMBg5D OOjwgm0ueAXzEGQE=; Received: from pub5.amebis.si ([213.250.55.21]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.2) id 1jBIIL-00DVna-5U for openvpn-devel@lists.sourceforge.net; Mon, 09 Mar 2020 13:18:13 +0000 Received: by pub5.amebis.si (Postfix, from userid 1000) id 981F41002FEE; Mon, 9 Mar 2020 14:17:51 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rozman.si; s=default; t=1583759871; bh=5YTm2ijJlSE2wKxjBCIzwuLK2IPT4RAPTxWlLX3jmm4=; h=From:To:Cc:Subject:Date:From; b=b6AtvPDLcXrFJQyAiOFvfOtH+TdAG8M4Q2xKGMtS9SoIVK9RPQYwSjgwiAiVmlEn7 EeXh+wiU9JPMZWc1tNNnZY51hck7RYAm5sOhBTb7FY2ASQvwg2ExHA2ZjXSQ8qYiSe /9vHoknk0abMbrjsRU4ggBtytDwp0jMYkLZkLZaM= X-Spam-Checker-Version: SpamAssassin 3.4.3 (2019-12-06) on brana.amebis.doma X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_20 autolearn=ham autolearn_force=no version=3.4.3 Received: from SR6.amebis.doma (unknown [IPv6:2a00:ee2:209:164:a5ae:e83c:b7b:725]) by pub5.amebis.si (Postfix) with ESMTP id CDFA71002F87; Mon, 9 Mar 2020 14:17:48 +0100 (CET) From: Simon Rozman To: openvpn-devel@lists.sourceforge.net Date: Mon, 9 Mar 2020 14:17:17 +0100 Message-Id: <20200309131728.380-1-simon@rozman.si> X-Mailer: git-send-email 2.24.1.windows.2 MIME-Version: 1.0 X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 0.0 AWL AWL: Adjusted score from AWL reputation of From: address X-Headers-End: 1jBIIL-00DVna-5U Subject: [Openvpn-devel] [PATCH 01/12] openvpnmsica: Remove required Windows driver certification detection 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 The MSI packages are switching to TAP-Windows6 and Wintun MSM modules to install the TAP/TUN driver. The MSM modules have built-in Windows version detection already. This commit is now-dead-code clean up with uncrustification. Signed-off-by: Simon Rozman Acked-by: Gert Doering --- src/openvpnmsica/openvpnmsica.c | 129 +------------------------------- 1 file changed, 3 insertions(+), 126 deletions(-) diff --git a/src/openvpnmsica/openvpnmsica.c b/src/openvpnmsica/openvpnmsica.c index 16381ea1..4236330a 100644 --- a/src/openvpnmsica/openvpnmsica.c +++ b/src/openvpnmsica/openvpnmsica.c @@ -203,128 +203,6 @@ _openvpnmsica_debug_popup(_In_z_ LPCTSTR szFunctionName) #endif /* ifdef _DEBUG */ -/** - * Detects Windows version and sets DRIVERCERTIFICATION property to "", "whql", or "attsgn" - * accordingly. - * - * @param hInstall Handle to the installation provided to the DLL custom action - * - * @return ERROR_SUCCESS on success; An error code otherwise - * See: https://msdn.microsoft.com/en-us/library/windows/desktop/aa368072.aspx - */ -static UINT -openvpnmsica_set_driver_certification(_In_ MSIHANDLE hInstall) -{ - UINT uiResult; - - /* Get Windows version. */ -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable: 4996) /* 'GetVersionExW': was declared deprecated. */ -#endif - OSVERSIONINFOEX ver_info = { .dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX) }; - if (!GetVersionEx((LPOSVERSIONINFO)&ver_info)) - { - uiResult = GetLastError(); - msg(M_NONFATAL | M_ERRNO, "%s: GetVersionEx() failed", __FUNCTION__); - return uiResult; - } -#ifdef _MSC_VER -#pragma warning(pop) -#endif - - /* The Windows version is usually spoofed, check using RtlGetVersion(). */ - TCHAR szDllPath[0x1000]; - ExpandEnvironmentStrings(TEXT("%SystemRoot%\\System32\\ntdll.dll"), szDllPath, -#ifdef UNICODE - _countof(szDllPath) -#else - _countof(szDllPath) - 1 -#endif - ); - HMODULE hNtDllModule = LoadLibrary(szDllPath); - if (hNtDllModule) - { - typedef NTSTATUS (WINAPI* fnRtlGetVersion)(PRTL_OSVERSIONINFOW); - fnRtlGetVersion RtlGetVersion = (fnRtlGetVersion)GetProcAddress(hNtDllModule, "RtlGetVersion"); - if (RtlGetVersion) - { - RTL_OSVERSIONINFOW rtl_ver_info = { .dwOSVersionInfoSize = sizeof(RTL_OSVERSIONINFOW) }; - if (RtlGetVersion(&rtl_ver_info) == 0) - { - if ( - rtl_ver_info.dwMajorVersion > ver_info.dwMajorVersion - || rtl_ver_info.dwMajorVersion == ver_info.dwMajorVersion && rtl_ver_info.dwMinorVersion > ver_info.dwMinorVersion - || rtl_ver_info.dwMajorVersion == ver_info.dwMajorVersion && rtl_ver_info.dwMinorVersion == ver_info.dwMinorVersion && rtl_ver_info.dwBuildNumber > ver_info.dwBuildNumber) - { - /* We got RtlGetVersion() and it reported newer version than GetVersionEx(). */ - ver_info.dwMajorVersion = rtl_ver_info.dwMajorVersion; - ver_info.dwMinorVersion = rtl_ver_info.dwMinorVersion; - ver_info.dwBuildNumber = rtl_ver_info.dwBuildNumber; - ver_info.dwPlatformId = rtl_ver_info.dwPlatformId; - } - } - } - - FreeLibrary(hNtDllModule); - } - - /* We don't trust RtlGetVersion() either. Check the version resource of kernel32.dll. */ - ExpandEnvironmentStrings(TEXT("%SystemRoot%\\System32\\kernel32.dll"), szDllPath, -#ifdef UNICODE - _countof(szDllPath) -#else - _countof(szDllPath) - 1 -#endif - ); - - DWORD dwHandle; - DWORD dwVerInfoSize = GetFileVersionInfoSize(szDllPath, &dwHandle); - if (dwVerInfoSize) - { - LPVOID pVersionInfo = malloc(dwVerInfoSize); - if (pVersionInfo) - { - /* Read version info. */ - if (GetFileVersionInfo(szDllPath, dwHandle, dwVerInfoSize, pVersionInfo)) - { - /* Get the value for the root block. */ - UINT uiSize = 0; - VS_FIXEDFILEINFO *pVSFixedFileInfo = NULL; - if (VerQueryValue(pVersionInfo, TEXT("\\"), &pVSFixedFileInfo, &uiSize) && uiSize && pVSFixedFileInfo) - { - if (HIWORD(pVSFixedFileInfo->dwProductVersionMS) > ver_info.dwMajorVersion - || HIWORD(pVSFixedFileInfo->dwProductVersionMS) == ver_info.dwMajorVersion && LOWORD(pVSFixedFileInfo->dwProductVersionMS) > ver_info.dwMinorVersion - || HIWORD(pVSFixedFileInfo->dwProductVersionMS) == ver_info.dwMajorVersion && LOWORD(pVSFixedFileInfo->dwProductVersionMS) == ver_info.dwMinorVersion && HIWORD(pVSFixedFileInfo->dwProductVersionLS) > ver_info.dwBuildNumber) - { - /* We got kernel32.dll version and it is newer. */ - ver_info.dwMajorVersion = HIWORD(pVSFixedFileInfo->dwProductVersionMS); - ver_info.dwMinorVersion = LOWORD(pVSFixedFileInfo->dwProductVersionMS); - ver_info.dwBuildNumber = HIWORD(pVSFixedFileInfo->dwProductVersionLS); - } - } - } - - free(pVersionInfo); - } - else - { - msg(M_NONFATAL, "%s: malloc(%u) failed", __FUNCTION__, dwVerInfoSize); - } - } - - uiResult = MsiSetProperty(hInstall, TEXT("DRIVERCERTIFICATION"), ver_info.dwMajorVersion >= 10 ? ver_info.wProductType > VER_NT_WORKSTATION ? TEXT("whql") : TEXT("attsgn") : TEXT("")); - if (uiResult != ERROR_SUCCESS) - { - SetLastError(uiResult); /* MSDN does not mention MsiSetProperty() to set GetLastError(). But we do have an error code. Set last error manually. */ - msg(M_NONFATAL | M_ERRNO, "%s: MsiSetProperty(\"DRIVERCERTIFICATION\") failed", __FUNCTION__); - return uiResult; - } - - return ERROR_SUCCESS; -} - - /** * Detects if the OpenVPNService service is in use (running or paused) and sets * OPENVPNSERVICE to the service process PID, or its path if it is set to @@ -451,7 +329,6 @@ FindSystemInfo(_In_ MSIHANDLE hInstall) OPENVPNMSICA_SAVE_MSI_SESSION(hInstall); - openvpnmsica_set_driver_certification(hInstall); openvpnmsica_set_openvpnserv_state(hInstall); if (bIsCoInitialized) @@ -829,7 +706,7 @@ EvaluateTAPInterfaces(_In_ MSIHANDLE hInstall) goto cleanup_hViewST_close; } - for (;;) + for (;; ) { /* Fetch one record from the view. */ MSIHANDLE hRecord = 0; @@ -998,7 +875,7 @@ cleanup_szSeqFilename: if (uiResult != ERROR_SUCCESS) { /* Clean-up sequence files. */ - for (size_t i = _countof(szActionNames); i--;) + for (size_t i = _countof(szActionNames); i--; ) { if (szSeqFilename[i][0]) { @@ -1186,7 +1063,7 @@ cleanup_session: uiResult = ERROR_SUCCESS; } - for (size_t i = MSICA_CLEANUP_ACTION_COUNT; i--;) + for (size_t i = MSICA_CLEANUP_ACTION_COUNT; i--; ) { msica_op_seq_free(&session.seq_cleanup[i]); }