From patchwork Mon Nov 12 01:22:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Rozman X-Patchwork-Id: 603 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director11.mail.ord1d.rsapps.net ([172.30.191.6]) by backend30.mail.ord1d.rsapps.net with LMTP id 4LlmOx1x6VsnXAAAIUCqbw for ; Mon, 12 Nov 2018 07:25:02 -0500 Received: from proxy17.mail.ord1d.rsapps.net ([172.30.191.6]) by director11.mail.ord1d.rsapps.net with LMTP id yLUUOx1x6VvzdQAAvGGmqA ; Mon, 12 Nov 2018 07:25:01 -0500 Received: from smtp6.gate.ord1d ([172.30.191.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy17.mail.ord1d.rsapps.net with LMTP id cAwCOx1x6VsCJAAAWC7mWg ; Mon, 12 Nov 2018 07:25:01 -0500 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: smtp6.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: f99111e0-e675-11e8-bebd-52540050e3e0-1-1 Received: from [216.105.38.7] ([216.105.38.7:30722] helo=lists.sourceforge.net) by smtp6.gate.ord1d.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id B7/26-19378-D1179EB5; Mon, 12 Nov 2018 07:25:01 -0500 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.90_1) (envelope-from ) id 1gMBFc-0005AJ-G5; Mon, 12 Nov 2018 12:23:32 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1gMBFZ-0005AA-Om for openvpn-devel@lists.sourceforge.net; Mon, 12 Nov 2018 12:23:29 +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=+5H9cVH37wglVz8X/b8ptsXm3hnsPSemGsOkyimuAz0=; b=ZZoPB2icCZNyyDR77skDKvZy9n Y2IIOP8GtgRsSgHGsBOo4vOE5/+uSsU7v7ZWwKVkP3RHN7UyYduA3zH9r/58Dweq2CBGtDfdGc8VY Zti+4JEyH1W3vSR7uxyvWPw16FyWbgVkLdk7Rvjpnm/GPHo9cK2BXJSvLXxrH4lXBRPk=; 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=+5H9cVH37wglVz8X/b8ptsXm3hnsPSemGsOkyimuAz0=; b=P 9ln0DFLbhUKfIe134FchCBxqEkfw51rpLW6PxcpBoTvKcsKHJZtyBmpKSuv4JDsCED83tvTKJOyP8 lz96ET9cR3ZFeyeeJlg4T53Zhg5vgcCFUUj1c5sGl4HeXTJ9nQ+x8zXf0XeqZgKcstOj46FiXfYDx TFwZSBIFplOEUxgA=; 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.90_1) id 1gMBFO-000kT8-As for openvpn-devel@lists.sourceforge.net; Mon, 12 Nov 2018 12:23:29 +0000 Received: from SR6.amebis.doma (unknown [IPv6:2a00:ee2:209:164:8cd9:ee93:28f1:f852]) by pub5.amebis.si (Postfix) with ESMTP id E03DF20107; Mon, 12 Nov 2018 13:23:04 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=rozman.si; s=default; t=1542025384; bh=2kf8tYdlo08O+f49NcMi1O4nJluPyTCi9PCzmHhP3ag=; h=From:To:Cc:Subject:Date:From; b=APrAavEYZhZiCsjxW2KGmRJm6Uoyw1IqtyD5YJP/m3iywO3NOW1yWxWwLqEB1lzSB EyX1HxOmHQZEOyKv1wHsuk8OOk3BsKwr4189uqGTP8FVzcOz+xRvJotFM/QMncTJ5U EFq2n7q9xnRcZHeT3h591GS2fV31+27agBUvgZyg= From: Simon Rozman To: openvpn-devel@lists.sourceforge.net Date: Mon, 12 Nov 2018 13:22:44 +0100 Message-Id: <20181112122246.13556-1-simon@rozman.si> X-Mailer: git-send-email 2.19.1.windows.1 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.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.2 AWL AWL: Adjusted score from AWL reputation of From: address X-Headers-End: 1gMBFO-000kT8-As Subject: [Openvpn-devel] [PATCH 1/3] Delete TAP interface before the TAP driver is uninstalled 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 previous version of MSI installer did: - Execution Pass: rename the TAP interface to some temporary name - Commit/Rollback Pass: delete the TAP interface / rename the interface back to original name However, the WiX Toolset's Diffx extension to install and remove drivers removed the TAP driver between the execution and commit passes. The TAP driver removal makes all TAP interfaces unavailable and our custom action couldn't find the interface to delete any more. While the system where OpenVPN was uninstalled didn't have any TAP interfaces any more as expected behaviour, the problem appears after reinstalling the OpenVPN. Some residue TAP interface registry keys remain on the system, causing the TAP interface to reappear as "Ethernet NN" interface next time the TAP driver is installed. This causes TAP interfaces to accumulate when cycling install-uninstall-install... Therefore, it is better to remove the TAP interfaces before the TAP driver is removed, and reinstall the TAP interface back should the rollback be required. Though it won't be exactly the same interface again. I wonder if the WiX Diffx extension supports execute/commit/rollback feature of MSI in the first place. Acked-by: Gert Doering --- src/openvpnmsica/msica_op.c | 87 ++++++++++++++----------------------- 1 file changed, 33 insertions(+), 54 deletions(-) diff --git a/src/openvpnmsica/msica_op.c b/src/openvpnmsica/msica_op.c index 8e9a3832..2ce69444 100644 --- a/src/openvpnmsica/msica_op.c +++ b/src/openvpnmsica/msica_op.c @@ -454,62 +454,41 @@ msica_op_tap_interface_delete( DWORD dwResult; - if (session->rollback_enabled) - { - int count = 0; - - do { - /* Rename the interface to keep it as a backup. */ - TCHAR szNameBackup[10/*"Interface "*/ + 10/*maximum int*/ + 1/*terminator*/]; - _stprintf_s( - szNameBackup, _countof(szNameBackup), - TEXT("Interface %i"), - ++count); - for (struct tap_interface_node *pInterfaceOther = pInterfaceList; ; pInterfaceOther = pInterfaceOther->pNext) - { - if (pInterfaceOther == NULL) - { - /* No interface with a same name found. All clear to rename the interface. */ - dwResult = tap_set_interface_name(&pInterface->guid, szNameBackup); - break; - } - else if (_tcsicmp(szNameBackup, pInterfaceOther->szName) == 0) - { - /* Interface with a same name found. Duplicate interface names are not allowed. */ - dwResult = ERROR_ALREADY_EXISTS; - break; - } - } - } while (dwResult == ERROR_ALREADY_EXISTS); + /* Delete the interface. */ + BOOL bRebootRequired = FALSE; + dwResult = tap_delete_interface(NULL, &pInterface->guid, &bRebootRequired); + if (bRebootRequired) + MsiSetMode(session->hInstall, MSIRUNMODE_REBOOTATEND, TRUE); - if (dwResult == ERROR_SUCCESS) { - /* Schedule rollback action to rename the interface back. */ - msica_op_seq_add_head( - &session->seq_cleanup[MSICA_CLEANUP_ACTION_ROLLBACK], - msica_op_create_guid_string( - msica_op_tap_interface_set_name, - 0, - NULL, - &pInterface->guid, - pInterface->szName)); - - /* Schedule commit action to delete the interface. */ - msica_op_seq_add_tail( - &session->seq_cleanup[MSICA_CLEANUP_ACTION_COMMIT], - msica_op_create_guid( - msica_op_tap_interface_delete_by_guid, - 0, - NULL, - &pInterface->guid)); - } - } - else + if (session->rollback_enabled) { - /* Delete the interface. */ - BOOL bRebootRequired = FALSE; - dwResult = tap_delete_interface(NULL, &pInterface->guid, &bRebootRequired); - if (bRebootRequired) - MsiSetMode(session->hInstall, MSIRUNMODE_REBOOTATEND, TRUE); + /* + Schedule rollback action to create the interface back. Though it won't be exactly the same interface again. + + The previous version of this function did: + - Execution Pass: rename the interface to some temporary name + - Commit/Rollback Pass: delete the interface / rename the interface back to original name + + However, the WiX Toolset's Diffx extension to install and remove drivers removed the TAP driver between the + execution and commit passes. TAP driver removal makes all TAP interfaces unavailable and our CA couldn't find + the interface to delete any more. + + While the system where OpenVPN was uninstalled didn't have any TAP interfaces any more as expected behaviour, + the problem appears after reinstalling the OpenVPN. Some residue TAP interface registry keys remain on the + system, causing the TAP interface to reappear as "Ethernet NN" interface next time the TAP driver is + installed. This causes TAP interfaces to accumulate over cyclic install-uninstall-install... + + Therefore, it is better to remove the TAP interfaces before the TAP driver is removed, and reinstall the TAP + interface back should the rollback be required. I wonder if the WiX Diffx extension supports execute/commit/ + rollback feature of MSI in the first place. + */ + msica_op_seq_add_head( + &session->seq_cleanup[MSICA_CLEANUP_ACTION_ROLLBACK], + msica_op_create_string( + msica_op_tap_interface_create, + 0, + NULL, + pInterface->szName)); } return dwResult;