fixed race condition that would overwrite admin access when using the unloze clan tag

This commit is contained in:
jenz 2023-08-12 22:12:33 +02:00
parent f8a4043e5d
commit d2bb72bb88

View File

@ -13,6 +13,8 @@ public Plugin myinfo =
url = ""
};
bool post_filter_admin[MAXPLAYERS + 1];
public void OnPluginStart()
{
/* Handle late load */
@ -25,9 +27,15 @@ public void OnPluginStart()
}
}
public void OnClientDisconnect(int client)
{
post_filter_admin[client] = false;
}
public void OnClientPostAdminFilter(int client)
{
CheckClantag(client);
post_filter_admin[client] = true;
CheckClantag(client);
}
public void OnClientSettingsChanged(int client)
@ -37,33 +45,37 @@ public void OnClientSettingsChanged(int client)
void CheckClantag(int client)
{
if(!IsClientAuthorized(client))
return;
if(!IsClientAuthorized(client))
return;
if (!post_filter_admin[client])
{
return;
}
char sClanID[32];
GetClientInfo(client, "cl_clanid", sClanID, sizeof(sClanID));
char sClanID[32];
GetClientInfo(client, "cl_clanid", sClanID, sizeof(sClanID));
if(!StrEqual(sClanID, CLANID))
return;
if(!StrEqual(sClanID, CLANID))
return;
AdminId AdmID;
GroupId GrpID;
AdminId AdmID;
GroupId GrpID;
if ((AdmID = GetUserAdmin(client)) == INVALID_ADMIN_ID)
{
LogMessage("Creating new admin for %L", client);
if ((AdmID = GetUserAdmin(client)) == INVALID_ADMIN_ID)
{
LogMessage("Creating new admin for %L", client);
AdmID = CreateAdmin("");
SetUserAdmin(client, AdmID, true);
}
AdmID = CreateAdmin("");
SetUserAdmin(client, AdmID, true);
}
if ((GrpID = FindAdmGroup(GROUP)) != INVALID_GROUP_ID)
{
if (AdminInheritGroup(AdmID, GrpID))
LogMessage("%L added to group %s", client, GROUP);
}
else
{
LogMessage("%L group not found %s", client, GROUP);
}
if ((GrpID = FindAdmGroup(GROUP)) != INVALID_GROUP_ID)
{
if (AdminInheritGroup(AdmID, GrpID))
LogMessage("%L added to group %s", client, GROUP);
}
else
{
LogMessage("%L group not found %s", client, GROUP);
}
}