From 5e8f6c5cfc28c8c70ef0339d7e1bb73069642915 Mon Sep 17 00:00:00 2001 From: Bob Arnson Date: Sun, 18 Dec 2022 20:14:50 -0500 Subject: Fix broken firewall direction. Fixes https://github.com/wixtoolset/issues/issues/7102. --- src/ext/Firewall/ca/firewall.cpp | 29 ++++++++++++---------- .../FirewallExtensionFixture.cs | 6 +++-- .../TestData/UsingFirewall/PackageComponents.wxs | 4 ++- 3 files changed, 23 insertions(+), 16 deletions(-) diff --git a/src/ext/Firewall/ca/firewall.cpp b/src/ext/Firewall/ca/firewall.cpp index caae21a1..b45cbcdd 100644 --- a/src/ext/Firewall/ca/firewall.cpp +++ b/src/ext/Firewall/ca/firewall.cpp @@ -4,7 +4,7 @@ LPCWSTR vcsFirewallExceptionQuery = L"SELECT `Name`, `RemoteAddresses`, `Port`, `Protocol`, `Program`, `Attributes`, `Profile`, `Component_`, `Description`, `Direction` FROM `Wix4FirewallException`"; -enum eFirewallExceptionQuery { feqName = 1, feqRemoteAddresses, feqPort, feqProtocol, feqProgram, feqAttributes, feqProfile, feqComponent, feqDescription }; +enum eFirewallExceptionQuery { feqName = 1, feqRemoteAddresses, feqPort, feqProtocol, feqProgram, feqAttributes, feqProfile, feqComponent, feqDescription, feqDirection }; enum eFirewallExceptionTarget { fetPort = 1, fetApplication, fetUnknown }; enum eFirewallExceptionAttributes { feaIgnoreFailures = 1 }; @@ -36,11 +36,11 @@ static UINT SchedFirewallExceptions( LPWSTR pwzComponent = NULL; LPWSTR pwzFormattedFile = NULL; LPWSTR pwzDescription = NULL; - int iDirection = 0; + int iDirection = MSI_NULL_INTEGER; // initialize hr = WcaInitialize(hInstall, "SchedFirewallExceptions"); - ExitOnFailure(hr, "failed to initialize"); + ExitOnFailure(hr, "Failed to initialize"); // anything to do? if (S_OK != WcaTableExists(L"Wix4FirewallException")) @@ -51,36 +51,39 @@ static UINT SchedFirewallExceptions( // query and loop through all the firewall exceptions hr = WcaOpenExecuteView(vcsFirewallExceptionQuery, &hView); - ExitOnFailure(hr, "failed to open view on Wix4FirewallException table"); + ExitOnFailure(hr, "Failed to open view on Wix4FirewallException table"); while (S_OK == (hr = WcaFetchRecord(hView, &hRec))) { hr = WcaGetRecordFormattedString(hRec, feqName, &pwzName); - ExitOnFailure(hr, "failed to get firewall exception name"); + ExitOnFailure(hr, "Failed to get firewall exception name."); hr = WcaGetRecordFormattedString(hRec, feqRemoteAddresses, &pwzRemoteAddresses); - ExitOnFailure(hr, "failed to get firewall exception remote addresses"); + ExitOnFailure(hr, "Failed to get firewall exception remote addresses."); hr = WcaGetRecordFormattedString(hRec, feqPort, &pwzPort); - ExitOnFailure(hr, "failed to get firewall exception port"); + ExitOnFailure(hr, "Failed to get firewall exception port."); hr = WcaGetRecordInteger(hRec, feqProtocol, &iProtocol); - ExitOnFailure(hr, "failed to get firewall exception protocol"); + ExitOnFailure(hr, "Failed to get firewall exception protocol."); hr = WcaGetRecordFormattedString(hRec, feqProgram, &pwzProgram); - ExitOnFailure(hr, "failed to get firewall exception program"); + ExitOnFailure(hr, "Failed to get firewall exception program."); hr = WcaGetRecordInteger(hRec, feqAttributes, &iAttributes); - ExitOnFailure(hr, "failed to get firewall exception attributes"); + ExitOnFailure(hr, "Failed to get firewall exception attributes."); hr = WcaGetRecordInteger(hRec, feqProfile, &iProfile); - ExitOnFailure(hr, "failed to get firewall exception profile"); + ExitOnFailure(hr, "Failed to get firewall exception profile."); hr = WcaGetRecordString(hRec, feqComponent, &pwzComponent); - ExitOnFailure(hr, "failed to get firewall exception component"); + ExitOnFailure(hr, "Failed to get firewall exception component."); hr = WcaGetRecordString(hRec, feqDescription, &pwzDescription); - ExitOnFailure(hr, "failed to get firewall description"); + ExitOnFailure(hr, "Failed to get firewall exception description."); + + hr = WcaGetRecordInteger(hRec, feqDirection, &iDirection); + ExitOnFailure(hr, "Failed to get firewall exception direction."); // figure out what we're doing for this exception, treating reinstall the same as install WCA_TODO todoComponent = WcaGetComponentToDo(pwzComponent); diff --git a/src/ext/Firewall/test/WixToolsetTest.Firewall/FirewallExtensionFixture.cs b/src/ext/Firewall/test/WixToolsetTest.Firewall/FirewallExtensionFixture.cs index c2c2bbc3..b89afaf7 100644 --- a/src/ext/Firewall/test/WixToolsetTest.Firewall/FirewallExtensionFixture.cs +++ b/src/ext/Firewall/test/WixToolsetTest.Firewall/FirewallExtensionFixture.cs @@ -25,7 +25,8 @@ namespace WixToolsetTest.Firewall "CustomAction:Wix4RollbackFirewallExceptionsUninstall_X86\t3329\tWix4FWCA_X86\tExecFirewallExceptions\t", "CustomAction:Wix4SchedFirewallExceptionsInstall_X86\t1\tWix4FWCA_X86\tSchedFirewallExceptionsInstall\t", "CustomAction:Wix4SchedFirewallExceptionsUninstall_X86\t1\tWix4FWCA_X86\tSchedFirewallExceptionsUninstall\t", - "Wix4FirewallException:ExampleFirewall\texample\t*\t42\t6\t[#filNdJBJmq3UCUIwmXS8x21aAsvqzk]\t0\t2147483647\tfilNdJBJmq3UCUIwmXS8x21aAsvqzk\tAn example firewall\t2", + "Wix4FirewallException:ExampleFirewall\tExampleApp\t*\t42\t6\t[#filNdJBJmq3UCUIwmXS8x21aAsvqzk]\t0\t2147483647\tfilNdJBJmq3UCUIwmXS8x21aAsvqzk\tAn app-based firewall exception\t1", + "Wix4FirewallException:fex70IVsYNnbwiHQrEepmdTPKH8XYs\tExamplePort\tLocalSubnet\t42\t6\t\t0\t2147483647\tfilNdJBJmq3UCUIwmXS8x21aAsvqzk\tA port-based firewall exception\t2", }, results); } @@ -44,7 +45,8 @@ namespace WixToolsetTest.Firewall "CustomAction:Wix4RollbackFirewallExceptionsUninstall_A64\t3329\tWix4FWCA_A64\tExecFirewallExceptions\t", "CustomAction:Wix4SchedFirewallExceptionsInstall_A64\t1\tWix4FWCA_A64\tSchedFirewallExceptionsInstall\t", "CustomAction:Wix4SchedFirewallExceptionsUninstall_A64\t1\tWix4FWCA_A64\tSchedFirewallExceptionsUninstall\t", - "Wix4FirewallException:ExampleFirewall\texample\t*\t42\t6\t[#filNdJBJmq3UCUIwmXS8x21aAsvqzk]\t0\t2147483647\tfilNdJBJmq3UCUIwmXS8x21aAsvqzk\tAn example firewall\t2", + "Wix4FirewallException:ExampleFirewall\tExampleApp\t*\t42\t6\t[#filNdJBJmq3UCUIwmXS8x21aAsvqzk]\t0\t2147483647\tfilNdJBJmq3UCUIwmXS8x21aAsvqzk\tAn app-based firewall exception\t1", + "Wix4FirewallException:fex70IVsYNnbwiHQrEepmdTPKH8XYs\tExamplePort\tLocalSubnet\t42\t6\t\t0\t2147483647\tfilNdJBJmq3UCUIwmXS8x21aAsvqzk\tA port-based firewall exception\t2", }, results); } diff --git a/src/ext/Firewall/test/WixToolsetTest.Firewall/TestData/UsingFirewall/PackageComponents.wxs b/src/ext/Firewall/test/WixToolsetTest.Firewall/TestData/UsingFirewall/PackageComponents.wxs index 6e8e4ebf..c712d895 100644 --- a/src/ext/Firewall/test/WixToolsetTest.Firewall/TestData/UsingFirewall/PackageComponents.wxs +++ b/src/ext/Firewall/test/WixToolsetTest.Firewall/TestData/UsingFirewall/PackageComponents.wxs @@ -6,10 +6,12 @@ - + + + -- cgit v1.2.3-55-g6feb