Skip to content

Commit

Permalink
Group creation and update PR nits and feedback fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
robmen committed Dec 25, 2024
1 parent f10f119 commit d20becc
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 26 deletions.
33 changes: 16 additions & 17 deletions src/ext/Util/ca/scaexec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -720,8 +720,7 @@ static HRESULT RemoveGroupInternal(

NET_API_STATUS er = ::NetLocalGroupDel(pwzServerName, wzName);
hr = HRESULT_FROM_WIN32(er);
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.
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.
{
hr = S_OK;
}
Expand Down Expand Up @@ -1303,16 +1302,16 @@ extern "C" UINT __stdcall CreateGroup(
er = ::NetLocalGroupAdd(pwzServerName, 1, reinterpret_cast<LPBYTE>(&groupInfo1), &dw);
hr = HRESULT_FROM_WIN32(er);

if (HRESULT_FROM_WIN32(ERROR_ALIAS_EXISTS) == hr
|| HRESULT_FROM_WIN32(NERR_GroupExists) == hr)
if (HRESULT_FROM_WIN32(ERROR_ALIAS_EXISTS) == hr || HRESULT_FROM_WIN32(NERR_GroupExists) == hr)
{
if (SCAG_FAIL_IF_EXISTS & iAttributes)
{
MessageExitOnFailure(hr, msierrGRPFailedGroupCreateExists, "Group (%ls\\%ls) was not supposed to exist, but does", pwzDomain, pwzName);
}

hr = S_OK; // Make sure that we don't report this situation as an error
// Make sure that we don't report this situation as an error
// if we fall through the tests that follow.
hr = S_OK;

if (SCAG_UPDATE_IF_EXISTS & iAttributes)
{
Expand Down Expand Up @@ -1505,6 +1504,7 @@ extern "C" UINT __stdcall CreateGroupRollback(
{
pwzComment = pwzOriginalComment;
}

hr = WcaReadIntegerFromCaData(&pwz, &iOriginalAttributes);
if (FAILED(hr))
{
Expand Down Expand Up @@ -1618,7 +1618,7 @@ extern "C" UINT __stdcall RemoveGroup(
return WcaFinalize(er);
}

HRESULT AlterGroupMembership(bool remove, bool isRollback)
HRESULT AlterGroupMembership(BOOL fRemove, BOOL fIsRollback)
{
HRESULT hr = S_OK;
NET_API_STATUS er = ERROR_SUCCESS;
Expand Down Expand Up @@ -1663,7 +1663,7 @@ HRESULT AlterGroupMembership(bool remove, bool isRollback)
hr = WcaReadStringFromCaData(&pwz, &pwzScriptKey);
ExitOnFailure(hr, "failed to read scriptkey from custom action data");

if (isRollback)
if (fIsRollback)
{
// if the script file doesn't exist, then we'll abandon this rollback
hr = WcaCaScriptOpen(WCA_ACTION_INSTALL, WCA_CASCRIPT_ROLLBACK, FALSE, pwzScriptKey, &hRollbackScript);
Expand Down Expand Up @@ -1693,7 +1693,7 @@ HRESULT AlterGroupMembership(bool remove, bool isRollback)
}
memberInfo3.lgrmi3_domainandname = pwzChildFullName;

if (remove)
if (fRemove)
{
er = ::NetLocalGroupDelMembers(pwzServerName, pwzParentName, 3, (LPBYTE)&memberInfo3, 1);
}
Expand All @@ -1705,18 +1705,16 @@ HRESULT AlterGroupMembership(bool remove, bool isRollback)

// if there was no error, the action succeeded, and we should flag that it's something which might need
// to be rolled back
if (S_OK == hr && !isRollback)
if (S_OK == hr && !fIsRollback)
{
// we create a script file, the rollback matching this scriptkey will occur if the file exists
hr = WcaCaScriptCreate(WCA_ACTION_INSTALL, WCA_CASCRIPT_ROLLBACK, FALSE, pwzScriptKey, FALSE, &hRollbackScript);
WcaCaScriptClose(hRollbackScript, WCA_CASCRIPT_CLOSE_PRESERVE);
}

if (remove)
if (fRemove)
{
if (HRESULT_FROM_WIN32(NERR_GroupNotFound) == hr
|| HRESULT_FROM_WIN32(ERROR_NO_SUCH_MEMBER) == hr
|| HRESULT_FROM_WIN32(ERROR_MEMBER_NOT_IN_ALIAS) == hr)
if (HRESULT_FROM_WIN32(NERR_GroupNotFound) == hr || HRESULT_FROM_WIN32(ERROR_NO_SUCH_MEMBER) == hr || HRESULT_FROM_WIN32(ERROR_MEMBER_NOT_IN_ALIAS) == hr)
{
hr = S_OK;
}
Expand Down Expand Up @@ -1771,7 +1769,7 @@ extern "C" UINT __stdcall AddGroupMembership(
ExitOnFailure(hr, "failed to initialize COM");
fInitializedCom = TRUE;

hr = AlterGroupMembership(false, false);
hr = AlterGroupMembership(FALSE, FALSE);

LExit:
if (fInitializedCom)
Expand Down Expand Up @@ -1807,7 +1805,7 @@ extern "C" UINT __stdcall AddGroupMembershipRollback(
ExitOnFailure(hr, "failed to initialize COM");
fInitializedCom = TRUE;

hr = AlterGroupMembership(true, true);
hr = AlterGroupMembership(TRUE, TRUE);

LExit:
if (fInitializedCom)
Expand Down Expand Up @@ -1842,13 +1840,14 @@ extern "C" UINT __stdcall RemoveGroupMembership(
ExitOnFailure(hr, "failed to initialize COM");
fInitializedCom = TRUE;

hr = AlterGroupMembership(true, false);
hr = AlterGroupMembership(TRUE, FALSE);

LExit:
if (fInitializedCom)
{
::CoUninitialize();
}

return WcaFinalize(FAILED(hr) ? ERROR_INSTALL_FAILED : ERROR_SUCCESS);
}

Expand Down Expand Up @@ -1878,7 +1877,7 @@ extern "C" UINT __stdcall RemoveGroupMembershipRollback(
ExitOnFailure(hr, "failed to initialize COM");
fInitializedCom = TRUE;

hr = AlterGroupMembership(false, true);
hr = AlterGroupMembership(FALSE, TRUE);

LExit:
if (fInitializedCom)
Expand Down
2 changes: 1 addition & 1 deletion src/ext/Util/ca/scasched.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ extern "C" UINT __stdcall ConfigureGroups(
__in MSIHANDLE hInstall
)
{
AssertSz(0, "Debug ConfigureGroups");
//AssertSz(0, "Debug ConfigureGroups");

HRESULT hr = S_OK;
UINT er = ERROR_SUCCESS;
Expand Down
6 changes: 3 additions & 3 deletions src/ext/Util/wixext/UtilCompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1485,7 +1485,7 @@ private void ParseGroupElement(Intermediate intermediate, IntermediateSection se
switch (child.Name.LocalName)
{
case "GroupRef":
this.ParseGroupRefElement(intermediate, section, child, id.Id, groupType:true);
this.ParseGroupRefElement(intermediate, section, child, id.Id, groupType: true);
break;
default:
this.ParseHelper.UnexpectedElement(element, child);
Expand Down Expand Up @@ -1521,7 +1521,7 @@ private void ParseGroupElement(Intermediate intermediate, IntermediateSection se
/// <param name="element">Element to parse.</param>
/// <param name="childId">Required child id to be joined to the group.</param>
/// <param name="groupType">whether the child is a group (true) or a user (false)</param>
private void ParseGroupRefElement(Intermediate intermediate, IntermediateSection section, XElement element, string childId, bool groupType=false)
private void ParseGroupRefElement(Intermediate intermediate, IntermediateSection section, XElement element, string childId, bool groupType)
{
var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element);
string groupId = null;
Expand Down Expand Up @@ -3588,7 +3588,7 @@ private void ParseUserElement(Intermediate intermediate, IntermediateSection sec
this.Messaging.Write(UtilErrors.IllegalElementWithoutComponent(childSourceLineNumbers, child.Name.LocalName));
}

this.ParseGroupRefElement(intermediate, section, child, id.Id, groupType:false);
this.ParseGroupRefElement(intermediate, section, child, id.Id, groupType: false);
break;
default:
this.ParseHelper.UnexpectedElement(element, child);
Expand Down
9 changes: 5 additions & 4 deletions src/test/burn/WixTestTools/RuntimeFactAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ namespace WixTestTools

public class RuntimeFactAttribute : SkippableFactAttribute
{
private bool domainRequired;

const string RequiredEnvironmentVariableName = "RuntimeTestsEnabled";
const string RequiredDomainEnvironmentVariableName = "RuntimeDomainTestsEnabled";

Expand Down Expand Up @@ -38,17 +40,16 @@ static RuntimeFactAttribute()
RuntimeDomainTestsEnabled = Boolean.TryParse(domainTestsEnabledString, out var domainTestsEnabled) && domainTestsEnabled;
}

private bool _domainRequired;
public bool DomainRequired
{
get
{
return _domainRequired;
return this.domainRequired;
}
set
{
_domainRequired = value;
if (_domainRequired && String.IsNullOrEmpty(this.Skip) && (!RunningInDomain || !RuntimeDomainTestsEnabled))
this.domainRequired = value;
if (this.domainRequired && String.IsNullOrEmpty(this.Skip) && (!RunningInDomain || !RuntimeDomainTestsEnabled))
{
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")}).";
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/burn/WixTestTools/UserGroupVerifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static void CreateLocalGroup(string groupName)
}

/// <summary>
/// Deletes a local gorup from the machine
/// Deletes a local group from the machine
/// </summary>
/// <param name="groupName">group name to delete</param>
/// <remarks>Has to be run as an Admin</remarks>
Expand Down

0 comments on commit d20becc

Please sign in to comment.