Fix broken firewall direction.
Fixes https://github.com/wixtoolset/issues/issues/7102.
Bob Arnson committed
Dec 18, 2022 at 20:14 UTC
5e8f6c5cfc28c8c70ef0339d7e1bb73069642915
3 files changed
+23
-16
src/ext/Firewall/ca/firewall.cpp
+16
-13
@@ -4,7 +4,7 @@
4
5
LPCWSTR vcsFirewallExceptionQuery =
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 };
9
enum eFirewallExceptionAttributes { feaIgnoreFailures = 1 };
10
@@ -36,11 +36,11 @@ static UINT SchedFirewallExceptions(
36
LPWSTR pwzComponent = NULL;
37
LPWSTR pwzFormattedFile = NULL;
38
LPWSTR pwzDescription = NULL;
39
- int iDirection = 0;
39
+ int iDirection = MSI_NULL_INTEGER;
40
41
// initialize
42
hr = WcaInitialize(hInstall, "SchedFirewallExceptions");
43
- ExitOnFailure(hr, "failed to initialize");
43
+ ExitOnFailure(hr, "Failed to initialize");
44
45
// anything to do?
46
if (S_OK != WcaTableExists(L"Wix4FirewallException"))
@@ -51,36 +51,39 @@ static UINT SchedFirewallExceptions(
51
52
// query and loop through all the firewall exceptions
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
56
while (S_OK == (hr = WcaFetchRecord(hView, &hRec)))
57
{
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
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
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
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
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
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
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
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
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.");
87
88
// figure out what we're doing for this exception, treating reinstall the same as install
89
WCA_TODO todoComponent = WcaGetComponentToDo(pwzComponent);
src/ext/Firewall/test/WixToolsetTest.Firewall/FirewallExtensionFixture.cs
+4
-2
@@ -25,7 +25,8 @@ namespace WixToolsetTest.Firewall
25
"CustomAction:Wix4RollbackFirewallExceptionsUninstall_X86\t3329\tWix4FWCA_X86\tExecFirewallExceptions\t",
26
"CustomAction:Wix4SchedFirewallExceptionsInstall_X86\t1\tWix4FWCA_X86\tSchedFirewallExceptionsInstall\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",
30
}, results);
31
}
32
@@ -44,7 +45,8 @@ namespace WixToolsetTest.Firewall
45
"CustomAction:Wix4RollbackFirewallExceptionsUninstall_A64\t3329\tWix4FWCA_A64\tExecFirewallExceptions\t",
46
"CustomAction:Wix4SchedFirewallExceptionsInstall_A64\t1\tWix4FWCA_A64\tSchedFirewallExceptionsInstall\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",
50
}, results);
51
}
52
src/ext/Firewall/test/WixToolsetTest.Firewall/TestData/UsingFirewall/PackageComponents.wxs
+3
-1
@@ -6,10 +6,12 @@
6
<Component>
7
<File Name="fw.exe" Source="example.txt">
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="*" />
11
</fw:FirewallException>
12
</File>
13
+
14
+ <fw:FirewallException Description="A port-based firewall exception" Name="ExamplePort" Port="42" Outbound="yes" Scope="localSubnet" />
15
</Component>
16
</ComponentGroup>
17
</Fragment>