diff options
author | Rob Mensching <rob@firegiant.com> | 2024-12-24 18:11:55 -0800 |
---|---|---|
committer | Rob Mensching <rob@firegiant.com> | 2025-02-11 23:14:49 -0800 |
commit | eda11c7eb726da970de68c5b353f946d1da0a7a3 (patch) | |
tree | 65a1780392a7213ba12a1865dba51cedbcdc561c | |
parent | 5b4a6538ee06988c75b717bd905197fb670e6142 (diff) | |
download | wix-eda11c7eb726da970de68c5b353f946d1da0a7a3.tar.gz wix-eda11c7eb726da970de68c5b353f946d1da0a7a3.tar.bz2 wix-eda11c7eb726da970de68c5b353f946d1da0a7a3.zip |
Group creation and update PR nits and feedback fixes
-rw-r--r-- | src/ext/Util/ca/scaexec.cpp | 33 | ||||
-rw-r--r-- | src/ext/Util/ca/scasched.cpp | 2 | ||||
-rw-r--r-- | src/ext/Util/wixext/UtilCompiler.cs | 6 | ||||
-rw-r--r-- | src/test/burn/WixTestTools/RuntimeFactAttribute.cs | 9 | ||||
-rw-r--r-- | src/test/burn/WixTestTools/UserGroupVerifier.cs | 2 |
5 files changed, 26 insertions, 26 deletions
diff --git a/src/ext/Util/ca/scaexec.cpp b/src/ext/Util/ca/scaexec.cpp index fea60b01..a2ecdaab 100644 --- a/src/ext/Util/ca/scaexec.cpp +++ b/src/ext/Util/ca/scaexec.cpp | |||
@@ -720,8 +720,7 @@ static HRESULT RemoveGroupInternal( | |||
720 | 720 | ||
721 | NET_API_STATUS er = ::NetLocalGroupDel(pwzServerName, wzName); | 721 | NET_API_STATUS er = ::NetLocalGroupDel(pwzServerName, wzName); |
722 | hr = HRESULT_FROM_WIN32(er); | 722 | hr = HRESULT_FROM_WIN32(er); |
723 | if (HRESULT_FROM_WIN32(ERROR_NO_SUCH_ALIAS) == hr | 723 | if (HRESULT_FROM_WIN32(ERROR_NO_SUCH_ALIAS) == hr || HRESULT_FROM_WIN32(NERR_GroupNotFound) == hr) // we wanted to delete it.. and the group doesn't exist.. solved. |
724 | || HRESULT_FROM_WIN32(NERR_GroupNotFound) == hr) // we wanted to delete it.. and the group doesn't exist.. solved. | ||
725 | { | 724 | { |
726 | hr = S_OK; | 725 | hr = S_OK; |
727 | } | 726 | } |
@@ -1303,16 +1302,16 @@ extern "C" UINT __stdcall CreateGroup( | |||
1303 | er = ::NetLocalGroupAdd(pwzServerName, 1, reinterpret_cast<LPBYTE>(&groupInfo1), &dw); | 1302 | er = ::NetLocalGroupAdd(pwzServerName, 1, reinterpret_cast<LPBYTE>(&groupInfo1), &dw); |
1304 | hr = HRESULT_FROM_WIN32(er); | 1303 | hr = HRESULT_FROM_WIN32(er); |
1305 | 1304 | ||
1306 | if (HRESULT_FROM_WIN32(ERROR_ALIAS_EXISTS) == hr | 1305 | if (HRESULT_FROM_WIN32(ERROR_ALIAS_EXISTS) == hr || HRESULT_FROM_WIN32(NERR_GroupExists) == hr) |
1307 | || HRESULT_FROM_WIN32(NERR_GroupExists) == hr) | ||
1308 | { | 1306 | { |
1309 | if (SCAG_FAIL_IF_EXISTS & iAttributes) | 1307 | if (SCAG_FAIL_IF_EXISTS & iAttributes) |
1310 | { | 1308 | { |
1311 | MessageExitOnFailure(hr, msierrGRPFailedGroupCreateExists, "Group (%ls\\%ls) was not supposed to exist, but does", pwzDomain, pwzName); | 1309 | MessageExitOnFailure(hr, msierrGRPFailedGroupCreateExists, "Group (%ls\\%ls) was not supposed to exist, but does", pwzDomain, pwzName); |
1312 | } | 1310 | } |
1313 | 1311 | ||
1314 | hr = S_OK; // Make sure that we don't report this situation as an error | 1312 | // Make sure that we don't report this situation as an error |
1315 | // if we fall through the tests that follow. | 1313 | // if we fall through the tests that follow. |
1314 | hr = S_OK; | ||
1316 | 1315 | ||
1317 | if (SCAG_UPDATE_IF_EXISTS & iAttributes) | 1316 | if (SCAG_UPDATE_IF_EXISTS & iAttributes) |
1318 | { | 1317 | { |
@@ -1505,6 +1504,7 @@ extern "C" UINT __stdcall CreateGroupRollback( | |||
1505 | { | 1504 | { |
1506 | pwzComment = pwzOriginalComment; | 1505 | pwzComment = pwzOriginalComment; |
1507 | } | 1506 | } |
1507 | |||
1508 | hr = WcaReadIntegerFromCaData(&pwz, &iOriginalAttributes); | 1508 | hr = WcaReadIntegerFromCaData(&pwz, &iOriginalAttributes); |
1509 | if (FAILED(hr)) | 1509 | if (FAILED(hr)) |
1510 | { | 1510 | { |
@@ -1618,7 +1618,7 @@ LExit: | |||
1618 | return WcaFinalize(er); | 1618 | return WcaFinalize(er); |
1619 | } | 1619 | } |
1620 | 1620 | ||
1621 | HRESULT AlterGroupMembership(bool remove, bool isRollback) | 1621 | HRESULT AlterGroupMembership(BOOL fRemove, BOOL fIsRollback) |
1622 | { | 1622 | { |
1623 | HRESULT hr = S_OK; | 1623 | HRESULT hr = S_OK; |
1624 | NET_API_STATUS er = ERROR_SUCCESS; | 1624 | NET_API_STATUS er = ERROR_SUCCESS; |
@@ -1663,7 +1663,7 @@ HRESULT AlterGroupMembership(bool remove, bool isRollback) | |||
1663 | hr = WcaReadStringFromCaData(&pwz, &pwzScriptKey); | 1663 | hr = WcaReadStringFromCaData(&pwz, &pwzScriptKey); |
1664 | ExitOnFailure(hr, "failed to read scriptkey from custom action data"); | 1664 | ExitOnFailure(hr, "failed to read scriptkey from custom action data"); |
1665 | 1665 | ||
1666 | if (isRollback) | 1666 | if (fIsRollback) |
1667 | { | 1667 | { |
1668 | // if the script file doesn't exist, then we'll abandon this rollback | 1668 | // if the script file doesn't exist, then we'll abandon this rollback |
1669 | hr = WcaCaScriptOpen(WCA_ACTION_INSTALL, WCA_CASCRIPT_ROLLBACK, FALSE, pwzScriptKey, &hRollbackScript); | 1669 | hr = WcaCaScriptOpen(WCA_ACTION_INSTALL, WCA_CASCRIPT_ROLLBACK, FALSE, pwzScriptKey, &hRollbackScript); |
@@ -1693,7 +1693,7 @@ HRESULT AlterGroupMembership(bool remove, bool isRollback) | |||
1693 | } | 1693 | } |
1694 | memberInfo3.lgrmi3_domainandname = pwzChildFullName; | 1694 | memberInfo3.lgrmi3_domainandname = pwzChildFullName; |
1695 | 1695 | ||
1696 | if (remove) | 1696 | if (fRemove) |
1697 | { | 1697 | { |
1698 | er = ::NetLocalGroupDelMembers(pwzServerName, pwzParentName, 3, (LPBYTE)&memberInfo3, 1); | 1698 | er = ::NetLocalGroupDelMembers(pwzServerName, pwzParentName, 3, (LPBYTE)&memberInfo3, 1); |
1699 | } | 1699 | } |
@@ -1705,18 +1705,16 @@ HRESULT AlterGroupMembership(bool remove, bool isRollback) | |||
1705 | 1705 | ||
1706 | // if there was no error, the action succeeded, and we should flag that it's something which might need | 1706 | // if there was no error, the action succeeded, and we should flag that it's something which might need |
1707 | // to be rolled back | 1707 | // to be rolled back |
1708 | if (S_OK == hr && !isRollback) | 1708 | if (S_OK == hr && !fIsRollback) |
1709 | { | 1709 | { |
1710 | // we create a script file, the rollback matching this scriptkey will occur if the file exists | 1710 | // we create a script file, the rollback matching this scriptkey will occur if the file exists |
1711 | hr = WcaCaScriptCreate(WCA_ACTION_INSTALL, WCA_CASCRIPT_ROLLBACK, FALSE, pwzScriptKey, FALSE, &hRollbackScript); | 1711 | hr = WcaCaScriptCreate(WCA_ACTION_INSTALL, WCA_CASCRIPT_ROLLBACK, FALSE, pwzScriptKey, FALSE, &hRollbackScript); |
1712 | WcaCaScriptClose(hRollbackScript, WCA_CASCRIPT_CLOSE_PRESERVE); | 1712 | WcaCaScriptClose(hRollbackScript, WCA_CASCRIPT_CLOSE_PRESERVE); |
1713 | } | 1713 | } |
1714 | 1714 | ||
1715 | if (remove) | 1715 | if (fRemove) |
1716 | { | 1716 | { |
1717 | if (HRESULT_FROM_WIN32(NERR_GroupNotFound) == hr | 1717 | if (HRESULT_FROM_WIN32(NERR_GroupNotFound) == hr || HRESULT_FROM_WIN32(ERROR_NO_SUCH_MEMBER) == hr || HRESULT_FROM_WIN32(ERROR_MEMBER_NOT_IN_ALIAS) == hr) |
1718 | || HRESULT_FROM_WIN32(ERROR_NO_SUCH_MEMBER) == hr | ||
1719 | || HRESULT_FROM_WIN32(ERROR_MEMBER_NOT_IN_ALIAS) == hr) | ||
1720 | { | 1718 | { |
1721 | hr = S_OK; | 1719 | hr = S_OK; |
1722 | } | 1720 | } |
@@ -1771,7 +1769,7 @@ extern "C" UINT __stdcall AddGroupMembership( | |||
1771 | ExitOnFailure(hr, "failed to initialize COM"); | 1769 | ExitOnFailure(hr, "failed to initialize COM"); |
1772 | fInitializedCom = TRUE; | 1770 | fInitializedCom = TRUE; |
1773 | 1771 | ||
1774 | hr = AlterGroupMembership(false, false); | 1772 | hr = AlterGroupMembership(FALSE, FALSE); |
1775 | 1773 | ||
1776 | LExit: | 1774 | LExit: |
1777 | if (fInitializedCom) | 1775 | if (fInitializedCom) |
@@ -1807,7 +1805,7 @@ extern "C" UINT __stdcall AddGroupMembershipRollback( | |||
1807 | ExitOnFailure(hr, "failed to initialize COM"); | 1805 | ExitOnFailure(hr, "failed to initialize COM"); |
1808 | fInitializedCom = TRUE; | 1806 | fInitializedCom = TRUE; |
1809 | 1807 | ||
1810 | hr = AlterGroupMembership(true, true); | 1808 | hr = AlterGroupMembership(TRUE, TRUE); |
1811 | 1809 | ||
1812 | LExit: | 1810 | LExit: |
1813 | if (fInitializedCom) | 1811 | if (fInitializedCom) |
@@ -1842,13 +1840,14 @@ extern "C" UINT __stdcall RemoveGroupMembership( | |||
1842 | ExitOnFailure(hr, "failed to initialize COM"); | 1840 | ExitOnFailure(hr, "failed to initialize COM"); |
1843 | fInitializedCom = TRUE; | 1841 | fInitializedCom = TRUE; |
1844 | 1842 | ||
1845 | hr = AlterGroupMembership(true, false); | 1843 | hr = AlterGroupMembership(TRUE, FALSE); |
1846 | 1844 | ||
1847 | LExit: | 1845 | LExit: |
1848 | if (fInitializedCom) | 1846 | if (fInitializedCom) |
1849 | { | 1847 | { |
1850 | ::CoUninitialize(); | 1848 | ::CoUninitialize(); |
1851 | } | 1849 | } |
1850 | |||
1852 | return WcaFinalize(FAILED(hr) ? ERROR_INSTALL_FAILED : ERROR_SUCCESS); | 1851 | return WcaFinalize(FAILED(hr) ? ERROR_INSTALL_FAILED : ERROR_SUCCESS); |
1853 | } | 1852 | } |
1854 | 1853 | ||
@@ -1878,7 +1877,7 @@ extern "C" UINT __stdcall RemoveGroupMembershipRollback( | |||
1878 | ExitOnFailure(hr, "failed to initialize COM"); | 1877 | ExitOnFailure(hr, "failed to initialize COM"); |
1879 | fInitializedCom = TRUE; | 1878 | fInitializedCom = TRUE; |
1880 | 1879 | ||
1881 | hr = AlterGroupMembership(false, true); | 1880 | hr = AlterGroupMembership(FALSE, TRUE); |
1882 | 1881 | ||
1883 | LExit: | 1882 | LExit: |
1884 | if (fInitializedCom) | 1883 | if (fInitializedCom) |
diff --git a/src/ext/Util/ca/scasched.cpp b/src/ext/Util/ca/scasched.cpp index d7378b13..cef7fecb 100644 --- a/src/ext/Util/ca/scasched.cpp +++ b/src/ext/Util/ca/scasched.cpp | |||
@@ -134,7 +134,7 @@ extern "C" UINT __stdcall ConfigureGroups( | |||
134 | __in MSIHANDLE hInstall | 134 | __in MSIHANDLE hInstall |
135 | ) | 135 | ) |
136 | { | 136 | { |
137 | AssertSz(0, "Debug ConfigureGroups"); | 137 | //AssertSz(0, "Debug ConfigureGroups"); |
138 | 138 | ||
139 | HRESULT hr = S_OK; | 139 | HRESULT hr = S_OK; |
140 | UINT er = ERROR_SUCCESS; | 140 | UINT er = ERROR_SUCCESS; |
diff --git a/src/ext/Util/wixext/UtilCompiler.cs b/src/ext/Util/wixext/UtilCompiler.cs index 4b1e43b5..f59ffcd6 100644 --- a/src/ext/Util/wixext/UtilCompiler.cs +++ b/src/ext/Util/wixext/UtilCompiler.cs | |||
@@ -1485,7 +1485,7 @@ namespace WixToolset.Util | |||
1485 | switch (child.Name.LocalName) | 1485 | switch (child.Name.LocalName) |
1486 | { | 1486 | { |
1487 | case "GroupRef": | 1487 | case "GroupRef": |
1488 | this.ParseGroupRefElement(intermediate, section, child, id.Id, groupType:true); | 1488 | this.ParseGroupRefElement(intermediate, section, child, id.Id, groupType: true); |
1489 | break; | 1489 | break; |
1490 | default: | 1490 | default: |
1491 | this.ParseHelper.UnexpectedElement(element, child); | 1491 | this.ParseHelper.UnexpectedElement(element, child); |
@@ -1521,7 +1521,7 @@ namespace WixToolset.Util | |||
1521 | /// <param name="element">Element to parse.</param> | 1521 | /// <param name="element">Element to parse.</param> |
1522 | /// <param name="childId">Required child id to be joined to the group.</param> | 1522 | /// <param name="childId">Required child id to be joined to the group.</param> |
1523 | /// <param name="groupType">whether the child is a group (true) or a user (false)</param> | 1523 | /// <param name="groupType">whether the child is a group (true) or a user (false)</param> |
1524 | private void ParseGroupRefElement(Intermediate intermediate, IntermediateSection section, XElement element, string childId, bool groupType=false) | 1524 | private void ParseGroupRefElement(Intermediate intermediate, IntermediateSection section, XElement element, string childId, bool groupType) |
1525 | { | 1525 | { |
1526 | var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); | 1526 | var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); |
1527 | string groupId = null; | 1527 | string groupId = null; |
@@ -3588,7 +3588,7 @@ namespace WixToolset.Util | |||
3588 | this.Messaging.Write(UtilErrors.IllegalElementWithoutComponent(childSourceLineNumbers, child.Name.LocalName)); | 3588 | this.Messaging.Write(UtilErrors.IllegalElementWithoutComponent(childSourceLineNumbers, child.Name.LocalName)); |
3589 | } | 3589 | } |
3590 | 3590 | ||
3591 | this.ParseGroupRefElement(intermediate, section, child, id.Id, groupType:false); | 3591 | this.ParseGroupRefElement(intermediate, section, child, id.Id, groupType: false); |
3592 | break; | 3592 | break; |
3593 | default: | 3593 | default: |
3594 | this.ParseHelper.UnexpectedElement(element, child); | 3594 | this.ParseHelper.UnexpectedElement(element, child); |
diff --git a/src/test/burn/WixTestTools/RuntimeFactAttribute.cs b/src/test/burn/WixTestTools/RuntimeFactAttribute.cs index 76004f26..d7f56f70 100644 --- a/src/test/burn/WixTestTools/RuntimeFactAttribute.cs +++ b/src/test/burn/WixTestTools/RuntimeFactAttribute.cs | |||
@@ -10,6 +10,8 @@ namespace WixTestTools | |||
10 | 10 | ||
11 | public class RuntimeFactAttribute : SkippableFactAttribute | 11 | public class RuntimeFactAttribute : SkippableFactAttribute |
12 | { | 12 | { |
13 | private bool domainRequired; | ||
14 | |||
13 | const string RequiredEnvironmentVariableName = "RuntimeTestsEnabled"; | 15 | const string RequiredEnvironmentVariableName = "RuntimeTestsEnabled"; |
14 | const string RequiredDomainEnvironmentVariableName = "RuntimeDomainTestsEnabled"; | 16 | const string RequiredDomainEnvironmentVariableName = "RuntimeDomainTestsEnabled"; |
15 | 17 | ||
@@ -47,17 +49,16 @@ namespace WixTestTools | |||
47 | RuntimeDomainTestsEnabled = Boolean.TryParse(domainTestsEnabledString, out var domainTestsEnabled) && domainTestsEnabled; | 49 | RuntimeDomainTestsEnabled = Boolean.TryParse(domainTestsEnabledString, out var domainTestsEnabled) && domainTestsEnabled; |
48 | } | 50 | } |
49 | 51 | ||
50 | private bool _domainRequired; | ||
51 | public bool DomainRequired | 52 | public bool DomainRequired |
52 | { | 53 | { |
53 | get | 54 | get |
54 | { | 55 | { |
55 | return _domainRequired; | 56 | return this.domainRequired; |
56 | } | 57 | } |
57 | set | 58 | set |
58 | { | 59 | { |
59 | _domainRequired = value; | 60 | this.domainRequired = value; |
60 | if (_domainRequired && String.IsNullOrEmpty(this.Skip) && (!RunningInDomain || !RuntimeDomainTestsEnabled)) | 61 | if (this.domainRequired && String.IsNullOrEmpty(this.Skip) && (!RunningInDomain || !RuntimeDomainTestsEnabled)) |
61 | { | 62 | { |
62 | this.Skip = $"These tests require the test host to be running as a domain member ({(RunningInDomain ? "passed" : "failed")}). These tests affect both MACHINE AND DOMAIN state. To accept the consequences, set the {RequiredDomainEnvironmentVariableName} environment variable to true ({(RuntimeDomainTestsEnabled ? "passed" : "failed")})."; | 63 | this.Skip = $"These tests require the test host to be running as a domain member ({(RunningInDomain ? "passed" : "failed")}). These tests affect both MACHINE AND DOMAIN state. To accept the consequences, set the {RequiredDomainEnvironmentVariableName} environment variable to true ({(RuntimeDomainTestsEnabled ? "passed" : "failed")})."; |
63 | } | 64 | } |
diff --git a/src/test/burn/WixTestTools/UserGroupVerifier.cs b/src/test/burn/WixTestTools/UserGroupVerifier.cs index 52a1a6bf..8c2da46e 100644 --- a/src/test/burn/WixTestTools/UserGroupVerifier.cs +++ b/src/test/burn/WixTestTools/UserGroupVerifier.cs | |||
@@ -29,7 +29,7 @@ namespace WixTestTools | |||
29 | } | 29 | } |
30 | 30 | ||
31 | /// <summary> | 31 | /// <summary> |
32 | /// Deletes a local gorup from the machine | 32 | /// Deletes a local group from the machine |
33 | /// </summary> | 33 | /// </summary> |
34 | /// <param name="groupName">group name to delete</param> | 34 | /// <param name="groupName">group name to delete</param> |
35 | /// <remarks>Has to be run as an Admin</remarks> | 35 | /// <remarks>Has to be run as an Admin</remarks> |