aboutsummaryrefslogtreecommitdiff
path: root/src/ca
diff options
context:
space:
mode:
Diffstat (limited to 'src/ca')
-rw-r--r--src/ca/firewall.cpp46
1 files changed, 32 insertions, 14 deletions
diff --git a/src/ca/firewall.cpp b/src/ca/firewall.cpp
index 62a5b454..bf40ce77 100644
--- a/src/ca/firewall.cpp
+++ b/src/ca/firewall.cpp
@@ -3,7 +3,7 @@
3#include "precomp.h" 3#include "precomp.h"
4 4
5LPCWSTR vcsFirewallExceptionQuery = 5LPCWSTR vcsFirewallExceptionQuery =
6 L"SELECT `Name`, `RemoteAddresses`, `Port`, `Protocol`, `Program`, `Attributes`, `Profile`, `Component_`, `Description` FROM `WixFirewallException`"; 6 L"SELECT `Name`, `RemoteAddresses`, `Port`, `Protocol`, `Program`, `Attributes`, `Profile`, `Component_`, `Description`, `Direction` FROM `WixFirewallException`";
7enum eFirewallExceptionQuery { feqName = 1, feqRemoteAddresses, feqPort, feqProtocol, feqProgram, feqAttributes, feqProfile, feqComponent, feqDescription }; 7enum eFirewallExceptionQuery { feqName = 1, feqRemoteAddresses, feqPort, feqProtocol, feqProgram, feqAttributes, feqProfile, feqComponent, feqDescription };
8enum eFirewallExceptionTarget { fetPort = 1, fetApplication, fetUnknown }; 8enum eFirewallExceptionTarget { fetPort = 1, fetApplication, fetUnknown };
9enum eFirewallExceptionAttributes { feaIgnoreFailures = 1 }; 9enum eFirewallExceptionAttributes { feaIgnoreFailures = 1 };
@@ -36,6 +36,7 @@ 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 40
40 // initialize 41 // initialize
41 hr = WcaInitialize(hInstall, "SchedFirewallExceptions"); 42 hr = WcaInitialize(hInstall, "SchedFirewallExceptions");
@@ -130,6 +131,9 @@ static UINT SchedFirewallExceptions(
130 131
131 hr = WcaWriteStringToCaData(pwzDescription, &pwzCustomActionData); 132 hr = WcaWriteStringToCaData(pwzDescription, &pwzCustomActionData);
132 ExitOnFailure(hr, "failed to write firewall rule description to custom action data"); 133 ExitOnFailure(hr, "failed to write firewall rule description to custom action data");
134
135 hr = WcaWriteIntegerToCaData(iDirection, &pwzCustomActionData);
136 ExitOnFailure(hr, "failed to write firewall rule direction to custom action data");
133 } 137 }
134 138
135 // reaching the end of the list is actually a good thing, not an error 139 // reaching the end of the list is actually a good thing, not an error
@@ -270,6 +274,7 @@ static HRESULT CreateFwRuleObject(
270 __in LPCWSTR wzPort, 274 __in LPCWSTR wzPort,
271 __in int iProtocol, 275 __in int iProtocol,
272 __in LPCWSTR wzDescription, 276 __in LPCWSTR wzDescription,
277 __in int iDirection,
273 __out INetFwRule** ppNetFwRule 278 __out INetFwRule** ppNetFwRule
274 ) 279 )
275{ 280{
@@ -321,6 +326,12 @@ static HRESULT CreateFwRuleObject(
321 ExitOnFailure(hr, "failed to set exception description '%ls'", bstrDescription); 326 ExitOnFailure(hr, "failed to set exception description '%ls'", bstrDescription);
322 } 327 }
323 328
329 if (MSI_NULL_INTEGER != iDirection)
330 {
331 hr = pNetFwRule->put_Direction(static_cast<NET_FW_RULE_DIRECTION> (iDirection));
332 ExitOnFailure(hr, "failed to set exception direction");
333 }
334
324 *ppNetFwRule = pNetFwRule; 335 *ppNetFwRule = pNetFwRule;
325 pNetFwRule = NULL; 336 pNetFwRule = NULL;
326 337
@@ -429,7 +440,8 @@ static HRESULT AddApplicationException(
429 __in BOOL fIgnoreFailures, 440 __in BOOL fIgnoreFailures,
430 __in LPCWSTR wzPort, 441 __in LPCWSTR wzPort,
431 __in int iProtocol, 442 __in int iProtocol,
432 __in LPCWSTR wzDescription 443 __in LPCWSTR wzDescription,
444 __in int iDirection
433 ) 445 )
434{ 446{
435 HRESULT hr = S_OK; 447 HRESULT hr = S_OK;
@@ -456,7 +468,7 @@ static HRESULT AddApplicationException(
456 hr = pNetFwRules->Item(bstrName, &pNetFwRule); 468 hr = pNetFwRules->Item(bstrName, &pNetFwRule);
457 if (HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) == hr) 469 if (HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) == hr)
458 { 470 {
459 hr = CreateFwRuleObject(bstrName, iProfile, wzRemoteAddresses, wzPort, iProtocol, wzDescription, &pNetFwRule); 471 hr = CreateFwRuleObject(bstrName, iProfile, wzRemoteAddresses, wzPort, iProtocol, wzDescription, iDirection, &pNetFwRule);
460 ExitOnFailure(hr, "failed to create FwRule object"); 472 ExitOnFailure(hr, "failed to create FwRule object");
461 473
462 // set edge traversal to true 474 // set edge traversal to true
@@ -590,8 +602,9 @@ static HRESULT AddPortException(
590 __in BOOL fIgnoreFailures, 602 __in BOOL fIgnoreFailures,
591 __in LPCWSTR wzPort, 603 __in LPCWSTR wzPort,
592 __in int iProtocol, 604 __in int iProtocol,
593 __in LPCWSTR wzDescription 605 __in LPCWSTR wzDescription,
594 ) 606 __in int iDirection
607)
595{ 608{
596 HRESULT hr = S_OK; 609 HRESULT hr = S_OK;
597 BSTR bstrName = NULL; 610 BSTR bstrName = NULL;
@@ -614,7 +627,7 @@ static HRESULT AddPortException(
614 hr = pNetFwRules->Item(bstrName, &pNetFwRule); 627 hr = pNetFwRules->Item(bstrName, &pNetFwRule);
615 if (HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) == hr) 628 if (HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) == hr)
616 { 629 {
617 hr = CreateFwRuleObject(bstrName, iProfile, wzRemoteAddresses, wzPort, iProtocol, wzDescription, &pNetFwRule); 630 hr = CreateFwRuleObject(bstrName, iProfile, wzRemoteAddresses, wzPort, iProtocol, wzDescription, iDirection, &pNetFwRule);
618 ExitOnFailure(hr, "failed to create FwRule object"); 631 ExitOnFailure(hr, "failed to create FwRule object");
619 632
620 // enable it 633 // enable it
@@ -825,14 +838,15 @@ static HRESULT AddApplicationException(
825 __in BOOL fIgnoreFailures, 838 __in BOOL fIgnoreFailures,
826 __in LPCWSTR wzPort, 839 __in LPCWSTR wzPort,
827 __in int iProtocol, 840 __in int iProtocol,
828 __in LPCWSTR wzDescription 841 __in LPCWSTR wzDescription,
829 ) 842 __in int iDirection
843)
830{ 844{
831 HRESULT hr = S_OK; 845 HRESULT hr = S_OK;
832 846
833 if (fSupportProfiles) 847 if (fSupportProfiles)
834 { 848 {
835 hr = AddApplicationException(wzFile, wzName, iProfile, wzRemoteAddresses, fIgnoreFailures, wzPort, iProtocol, wzDescription); 849 hr = AddApplicationException(wzFile, wzName, iProfile, wzRemoteAddresses, fIgnoreFailures, wzPort, iProtocol, wzDescription, iDirection);
836 } 850 }
837 else 851 else
838 { 852 {
@@ -860,14 +874,15 @@ static HRESULT AddPortException(
860 __in BOOL fIgnoreFailures, 874 __in BOOL fIgnoreFailures,
861 __in LPCWSTR wzPort, 875 __in LPCWSTR wzPort,
862 __in int iProtocol, 876 __in int iProtocol,
863 __in LPCWSTR wzDescription 877 __in LPCWSTR wzDescription,
864 ) 878 __in int iDirection
879)
865{ 880{
866 HRESULT hr = S_OK; 881 HRESULT hr = S_OK;
867 882
868 if (fSupportProfiles) 883 if (fSupportProfiles)
869 { 884 {
870 hr = AddPortException(wzName, iProfile, wzRemoteAddresses, fIgnoreFailures, wzPort, iProtocol, wzDescription); 885 hr = AddPortException(wzName, iProfile, wzRemoteAddresses, fIgnoreFailures, wzPort, iProtocol, wzDescription, iDirection);
871 } 886 }
872 else 887 else
873 { 888 {
@@ -951,6 +966,7 @@ extern "C" UINT __stdcall ExecFirewallExceptions(
951 LPWSTR pwzDescription = NULL; 966 LPWSTR pwzDescription = NULL;
952 int iProtocol = 0; 967 int iProtocol = 0;
953 int iProfile = 0; 968 int iProfile = 0;
969 int iDirection = 0;
954 970
955 // initialize 971 // initialize
956 hr = WcaInitialize(hInstall, "ExecFirewallExceptions"); 972 hr = WcaInitialize(hInstall, "ExecFirewallExceptions");
@@ -1013,6 +1029,8 @@ extern "C" UINT __stdcall ExecFirewallExceptions(
1013 ExitOnFailure(hr, "failed to read protocol from custom action data"); 1029 ExitOnFailure(hr, "failed to read protocol from custom action data");
1014 hr = WcaReadStringFromCaData(&pwz, &pwzDescription); 1030 hr = WcaReadStringFromCaData(&pwz, &pwzDescription);
1015 ExitOnFailure(hr, "failed to read protocol from custom action data"); 1031 ExitOnFailure(hr, "failed to read protocol from custom action data");
1032 hr = WcaReadIntegerFromCaData(&pwz, &iDirection);
1033 ExitOnFailure(hr, "failed to read direction from custom action data");
1016 1034
1017 switch (iTarget) 1035 switch (iTarget)
1018 { 1036 {
@@ -1022,7 +1040,7 @@ extern "C" UINT __stdcall ExecFirewallExceptions(
1022 case WCA_TODO_INSTALL: 1040 case WCA_TODO_INSTALL:
1023 case WCA_TODO_REINSTALL: 1041 case WCA_TODO_REINSTALL:
1024 WcaLog(LOGMSG_STANDARD, "Installing firewall exception2 %ls on port %ls, protocol %d", pwzName, pwzPort, iProtocol); 1042 WcaLog(LOGMSG_STANDARD, "Installing firewall exception2 %ls on port %ls, protocol %d", pwzName, pwzPort, iProtocol);
1025 hr = AddPortException(fSupportProfiles, pwzName, iProfile, pwzRemoteAddresses, fIgnoreFailures, pwzPort, iProtocol, pwzDescription); 1043 hr = AddPortException(fSupportProfiles, pwzName, iProfile, pwzRemoteAddresses, fIgnoreFailures, pwzPort, iProtocol, pwzDescription, iDirection);
1026 ExitOnFailure(hr, "failed to add/update port exception for name '%ls' on port %ls, protocol %d", pwzName, pwzPort, iProtocol); 1044 ExitOnFailure(hr, "failed to add/update port exception for name '%ls' on port %ls, protocol %d", pwzName, pwzPort, iProtocol);
1027 break; 1045 break;
1028 1046
@@ -1040,7 +1058,7 @@ extern "C" UINT __stdcall ExecFirewallExceptions(
1040 case WCA_TODO_INSTALL: 1058 case WCA_TODO_INSTALL:
1041 case WCA_TODO_REINSTALL: 1059 case WCA_TODO_REINSTALL:
1042 WcaLog(LOGMSG_STANDARD, "Installing firewall exception2 %ls (%ls)", pwzName, pwzFile); 1060 WcaLog(LOGMSG_STANDARD, "Installing firewall exception2 %ls (%ls)", pwzName, pwzFile);
1043 hr = AddApplicationException(fSupportProfiles, pwzFile, pwzName, iProfile, pwzRemoteAddresses, fIgnoreFailures, pwzPort, iProtocol, pwzDescription); 1061 hr = AddApplicationException(fSupportProfiles, pwzFile, pwzName, iProfile, pwzRemoteAddresses, fIgnoreFailures, pwzPort, iProtocol, pwzDescription, iDirection);
1044 ExitOnFailure(hr, "failed to add/update application exception for name '%ls', file '%ls'", pwzName, pwzFile); 1062 ExitOnFailure(hr, "failed to add/update application exception for name '%ls', file '%ls'", pwzName, pwzFile);
1045 break; 1063 break;
1046 1064