diff options
author | Bob Arnson <bob@firegiant.com> | 2022-12-18 20:14:50 -0500 |
---|---|---|
committer | Bob Arnson <github@bobs.org> | 2022-12-18 21:18:49 -0500 |
commit | 5e8f6c5cfc28c8c70ef0339d7e1bb73069642915 (patch) | |
tree | 9184ff3677e15623dc8d3646c9eba61816994246 | |
parent | 72a95fbbec5022220ee165f3acb4889b65155bc0 (diff) | |
download | wix-5e8f6c5cfc28c8c70ef0339d7e1bb73069642915.tar.gz wix-5e8f6c5cfc28c8c70ef0339d7e1bb73069642915.tar.bz2 wix-5e8f6c5cfc28c8c70ef0339d7e1bb73069642915.zip |
Fix broken firewall direction.
Fixes https://github.com/wixtoolset/issues/issues/7102.
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 @@ | |||
4 | 4 | ||
5 | LPCWSTR vcsFirewallExceptionQuery = | 5 | LPCWSTR vcsFirewallExceptionQuery = |
6 | L"SELECT `Name`, `RemoteAddresses`, `Port`, `Protocol`, `Program`, `Attributes`, `Profile`, `Component_`, `Description`, `Direction` FROM `Wix4FirewallException`"; | 6 | L"SELECT `Name`, `RemoteAddresses`, `Port`, `Protocol`, `Program`, `Attributes`, `Profile`, `Component_`, `Description`, `Direction` FROM `Wix4FirewallException`"; |
7 | enum eFirewallExceptionQuery { feqName = 1, feqRemoteAddresses, feqPort, feqProtocol, feqProgram, feqAttributes, feqProfile, feqComponent, feqDescription }; | 7 | enum eFirewallExceptionQuery { feqName = 1, feqRemoteAddresses, feqPort, feqProtocol, feqProgram, feqAttributes, feqProfile, feqComponent, feqDescription, feqDirection }; |
8 | enum eFirewallExceptionTarget { fetPort = 1, fetApplication, fetUnknown }; | 8 | enum eFirewallExceptionTarget { fetPort = 1, fetApplication, fetUnknown }; |
9 | enum eFirewallExceptionAttributes { feaIgnoreFailures = 1 }; | 9 | enum eFirewallExceptionAttributes { feaIgnoreFailures = 1 }; |
10 | 10 | ||
@@ -36,11 +36,11 @@ static UINT SchedFirewallExceptions( | |||
36 | LPWSTR pwzComponent = NULL; | 36 | LPWSTR pwzComponent = NULL; |
37 | LPWSTR pwzFormattedFile = NULL; | 37 | LPWSTR pwzFormattedFile = NULL; |
38 | LPWSTR pwzDescription = NULL; | 38 | LPWSTR pwzDescription = NULL; |
39 | int iDirection = 0; | 39 | int iDirection = MSI_NULL_INTEGER; |
40 | 40 | ||
41 | // initialize | 41 | // initialize |
42 | hr = WcaInitialize(hInstall, "SchedFirewallExceptions"); | 42 | hr = WcaInitialize(hInstall, "SchedFirewallExceptions"); |
43 | ExitOnFailure(hr, "failed to initialize"); | 43 | ExitOnFailure(hr, "Failed to initialize"); |
44 | 44 | ||
45 | // anything to do? | 45 | // anything to do? |
46 | if (S_OK != WcaTableExists(L"Wix4FirewallException")) | 46 | if (S_OK != WcaTableExists(L"Wix4FirewallException")) |
@@ -51,36 +51,39 @@ static UINT SchedFirewallExceptions( | |||
51 | 51 | ||
52 | // query and loop through all the firewall exceptions | 52 | // query and loop through all the firewall exceptions |
53 | hr = WcaOpenExecuteView(vcsFirewallExceptionQuery, &hView); | 53 | hr = WcaOpenExecuteView(vcsFirewallExceptionQuery, &hView); |
54 | ExitOnFailure(hr, "failed to open view on Wix4FirewallException table"); | 54 | ExitOnFailure(hr, "Failed to open view on Wix4FirewallException table"); |
55 | 55 | ||
56 | while (S_OK == (hr = WcaFetchRecord(hView, &hRec))) | 56 | while (S_OK == (hr = WcaFetchRecord(hView, &hRec))) |
57 | { | 57 | { |
58 | hr = WcaGetRecordFormattedString(hRec, feqName, &pwzName); | 58 | hr = WcaGetRecordFormattedString(hRec, feqName, &pwzName); |
59 | ExitOnFailure(hr, "failed to get firewall exception name"); | 59 | ExitOnFailure(hr, "Failed to get firewall exception name."); |
60 | 60 | ||
61 | hr = WcaGetRecordFormattedString(hRec, feqRemoteAddresses, &pwzRemoteAddresses); | 61 | hr = WcaGetRecordFormattedString(hRec, feqRemoteAddresses, &pwzRemoteAddresses); |
62 | ExitOnFailure(hr, "failed to get firewall exception remote addresses"); | 62 | ExitOnFailure(hr, "Failed to get firewall exception remote addresses."); |
63 | 63 | ||
64 | hr = WcaGetRecordFormattedString(hRec, feqPort, &pwzPort); | 64 | hr = WcaGetRecordFormattedString(hRec, feqPort, &pwzPort); |
65 | ExitOnFailure(hr, "failed to get firewall exception port"); | 65 | ExitOnFailure(hr, "Failed to get firewall exception port."); |
66 | 66 | ||
67 | hr = WcaGetRecordInteger(hRec, feqProtocol, &iProtocol); | 67 | hr = WcaGetRecordInteger(hRec, feqProtocol, &iProtocol); |
68 | ExitOnFailure(hr, "failed to get firewall exception protocol"); | 68 | ExitOnFailure(hr, "Failed to get firewall exception protocol."); |
69 | 69 | ||
70 | hr = WcaGetRecordFormattedString(hRec, feqProgram, &pwzProgram); | 70 | hr = WcaGetRecordFormattedString(hRec, feqProgram, &pwzProgram); |
71 | ExitOnFailure(hr, "failed to get firewall exception program"); | 71 | ExitOnFailure(hr, "Failed to get firewall exception program."); |
72 | 72 | ||
73 | hr = WcaGetRecordInteger(hRec, feqAttributes, &iAttributes); | 73 | hr = WcaGetRecordInteger(hRec, feqAttributes, &iAttributes); |
74 | ExitOnFailure(hr, "failed to get firewall exception attributes"); | 74 | ExitOnFailure(hr, "Failed to get firewall exception attributes."); |
75 | 75 | ||
76 | hr = WcaGetRecordInteger(hRec, feqProfile, &iProfile); | 76 | hr = WcaGetRecordInteger(hRec, feqProfile, &iProfile); |
77 | ExitOnFailure(hr, "failed to get firewall exception profile"); | 77 | ExitOnFailure(hr, "Failed to get firewall exception profile."); |
78 | 78 | ||
79 | hr = WcaGetRecordString(hRec, feqComponent, &pwzComponent); | 79 | hr = WcaGetRecordString(hRec, feqComponent, &pwzComponent); |
80 | ExitOnFailure(hr, "failed to get firewall exception component"); | 80 | ExitOnFailure(hr, "Failed to get firewall exception component."); |
81 | 81 | ||
82 | hr = WcaGetRecordString(hRec, feqDescription, &pwzDescription); | 82 | hr = WcaGetRecordString(hRec, feqDescription, &pwzDescription); |
83 | ExitOnFailure(hr, "failed to get firewall description"); | 83 | ExitOnFailure(hr, "Failed to get firewall exception description."); |
84 | |||
85 | hr = WcaGetRecordInteger(hRec, feqDirection, &iDirection); | ||
86 | ExitOnFailure(hr, "Failed to get firewall exception direction."); | ||
84 | 87 | ||
85 | // figure out what we're doing for this exception, treating reinstall the same as install | 88 | // figure out what we're doing for this exception, treating reinstall the same as install |
86 | WCA_TODO todoComponent = WcaGetComponentToDo(pwzComponent); | 89 | 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 | |||
25 | "CustomAction:Wix4RollbackFirewallExceptionsUninstall_X86\t3329\tWix4FWCA_X86\tExecFirewallExceptions\t", | 25 | "CustomAction:Wix4RollbackFirewallExceptionsUninstall_X86\t3329\tWix4FWCA_X86\tExecFirewallExceptions\t", |
26 | "CustomAction:Wix4SchedFirewallExceptionsInstall_X86\t1\tWix4FWCA_X86\tSchedFirewallExceptionsInstall\t", | 26 | "CustomAction:Wix4SchedFirewallExceptionsInstall_X86\t1\tWix4FWCA_X86\tSchedFirewallExceptionsInstall\t", |
27 | "CustomAction:Wix4SchedFirewallExceptionsUninstall_X86\t1\tWix4FWCA_X86\tSchedFirewallExceptionsUninstall\t", | 27 | "CustomAction:Wix4SchedFirewallExceptionsUninstall_X86\t1\tWix4FWCA_X86\tSchedFirewallExceptionsUninstall\t", |
28 | "Wix4FirewallException:ExampleFirewall\texample\t*\t42\t6\t[#filNdJBJmq3UCUIwmXS8x21aAsvqzk]\t0\t2147483647\tfilNdJBJmq3UCUIwmXS8x21aAsvqzk\tAn example firewall\t2", | 28 | "Wix4FirewallException:ExampleFirewall\tExampleApp\t*\t42\t6\t[#filNdJBJmq3UCUIwmXS8x21aAsvqzk]\t0\t2147483647\tfilNdJBJmq3UCUIwmXS8x21aAsvqzk\tAn app-based firewall exception\t1", |
29 | "Wix4FirewallException:fex70IVsYNnbwiHQrEepmdTPKH8XYs\tExamplePort\tLocalSubnet\t42\t6\t\t0\t2147483647\tfilNdJBJmq3UCUIwmXS8x21aAsvqzk\tA port-based firewall exception\t2", | ||
29 | }, results); | 30 | }, results); |
30 | } | 31 | } |
31 | 32 | ||
@@ -44,7 +45,8 @@ namespace WixToolsetTest.Firewall | |||
44 | "CustomAction:Wix4RollbackFirewallExceptionsUninstall_A64\t3329\tWix4FWCA_A64\tExecFirewallExceptions\t", | 45 | "CustomAction:Wix4RollbackFirewallExceptionsUninstall_A64\t3329\tWix4FWCA_A64\tExecFirewallExceptions\t", |
45 | "CustomAction:Wix4SchedFirewallExceptionsInstall_A64\t1\tWix4FWCA_A64\tSchedFirewallExceptionsInstall\t", | 46 | "CustomAction:Wix4SchedFirewallExceptionsInstall_A64\t1\tWix4FWCA_A64\tSchedFirewallExceptionsInstall\t", |
46 | "CustomAction:Wix4SchedFirewallExceptionsUninstall_A64\t1\tWix4FWCA_A64\tSchedFirewallExceptionsUninstall\t", | 47 | "CustomAction:Wix4SchedFirewallExceptionsUninstall_A64\t1\tWix4FWCA_A64\tSchedFirewallExceptionsUninstall\t", |
47 | "Wix4FirewallException:ExampleFirewall\texample\t*\t42\t6\t[#filNdJBJmq3UCUIwmXS8x21aAsvqzk]\t0\t2147483647\tfilNdJBJmq3UCUIwmXS8x21aAsvqzk\tAn example firewall\t2", | 48 | "Wix4FirewallException:ExampleFirewall\tExampleApp\t*\t42\t6\t[#filNdJBJmq3UCUIwmXS8x21aAsvqzk]\t0\t2147483647\tfilNdJBJmq3UCUIwmXS8x21aAsvqzk\tAn app-based firewall exception\t1", |
49 | "Wix4FirewallException:fex70IVsYNnbwiHQrEepmdTPKH8XYs\tExamplePort\tLocalSubnet\t42\t6\t\t0\t2147483647\tfilNdJBJmq3UCUIwmXS8x21aAsvqzk\tA port-based firewall exception\t2", | ||
48 | }, results); | 50 | }, results); |
49 | } | 51 | } |
50 | 52 | ||
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 @@ | |||
6 | <Component> | 6 | <Component> |
7 | <File Name="fw.exe" Source="example.txt"> | 7 | <File Name="fw.exe" Source="example.txt"> |
8 | <Shortcut Id="FwShortcut" Directory="INSTALLFOLDER" Name="Firewall" /> | 8 | <Shortcut Id="FwShortcut" Directory="INSTALLFOLDER" Name="Firewall" /> |
9 | <fw:FirewallException Id="ExampleFirewall" Description="An example firewall" Name="example" Port="42" Outbound="true"> | 9 | <fw:FirewallException Id="ExampleFirewall" Description="An app-based firewall exception" Name="ExampleApp" Port="42"> |
10 | <fw:RemoteAddress Value="*" /> | 10 | <fw:RemoteAddress Value="*" /> |
11 | </fw:FirewallException> | 11 | </fw:FirewallException> |
12 | </File> | 12 | </File> |
13 | |||
14 | <fw:FirewallException Description="A port-based firewall exception" Name="ExamplePort" Port="42" Outbound="yes" Scope="localSubnet" /> | ||
13 | </Component> | 15 | </Component> |
14 | </ComponentGroup> | 16 | </ComponentGroup> |
15 | </Fragment> | 17 | </Fragment> |