- added amb1332, new cvar protection mechanism for rcon_password
- removed FCVAR_PROTECTED from Core cvars --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401845
This commit is contained in:
parent
63592212d5
commit
42a313486a
@ -50,7 +50,7 @@ AdminCache g_Admins;
|
|||||||
AdminFlag g_FlagLetters[26];
|
AdminFlag g_FlagLetters[26];
|
||||||
bool g_FlagSet[26];
|
bool g_FlagSet[26];
|
||||||
|
|
||||||
ConVar sm_immunity_mode("sm_immunity_mode", "1", FCVAR_SPONLY|FCVAR_PROTECTED, "Mode for deciding immunity protection");
|
ConVar sm_immunity_mode("sm_immunity_mode", "1", FCVAR_SPONLY, "Mode for deciding immunity protection");
|
||||||
|
|
||||||
/* Default flags */
|
/* Default flags */
|
||||||
AdminFlag g_DefaultFlags[26] =
|
AdminFlag g_DefaultFlags[26] =
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
#include <inetchannel.h>
|
#include <inetchannel.h>
|
||||||
#include <iclient.h>
|
#include <iclient.h>
|
||||||
|
|
||||||
ConVar sm_show_activity("sm_show_activity", "13", FCVAR_SPONLY|FCVAR_PROTECTED, "Activity display setting (see sourcemod.cfg)");
|
ConVar sm_show_activity("sm_show_activity", "13", FCVAR_SPONLY, "Activity display setting (see sourcemod.cfg)");
|
||||||
|
|
||||||
static cell_t sm_GetClientCount(IPluginContext *pCtx, const cell_t *params)
|
static cell_t sm_GetClientCount(IPluginContext *pCtx, const cell_t *params)
|
||||||
{
|
{
|
||||||
|
@ -49,6 +49,7 @@ public Plugin:myinfo =
|
|||||||
new Handle:hTopMenu = INVALID_HANDLE;
|
new Handle:hTopMenu = INVALID_HANDLE;
|
||||||
|
|
||||||
new Handle:g_MapList;
|
new Handle:g_MapList;
|
||||||
|
new Handle:g_ProtectedVars;
|
||||||
|
|
||||||
#include "basecommands/kick.sp"
|
#include "basecommands/kick.sp"
|
||||||
#include "basecommands/reloadadmins.sp"
|
#include "basecommands/reloadadmins.sp"
|
||||||
@ -85,6 +86,11 @@ public OnPluginStart()
|
|||||||
decl String:mapListPath[PLATFORM_MAX_PATH];
|
decl String:mapListPath[PLATFORM_MAX_PATH];
|
||||||
BuildPath(Path_SM, mapListPath, sizeof(mapListPath), "configs/adminmenu_maplist.ini");
|
BuildPath(Path_SM, mapListPath, sizeof(mapListPath), "configs/adminmenu_maplist.ini");
|
||||||
SetMapListCompatBind("sm_map menu", mapListPath);
|
SetMapListCompatBind("sm_map menu", mapListPath);
|
||||||
|
|
||||||
|
g_ProtectedVars = CreateTrie();
|
||||||
|
ProtectVar("rcon_password");
|
||||||
|
ProtectVar("sm_show_activity");
|
||||||
|
ProtectVar("sm_immunity_mode");
|
||||||
}
|
}
|
||||||
|
|
||||||
public OnMapStart()
|
public OnMapStart()
|
||||||
@ -97,6 +103,17 @@ public OnConfigsExecuted()
|
|||||||
LoadMapList(g_MapList);
|
LoadMapList(g_MapList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ProtectVar(const String:cvar[])
|
||||||
|
{
|
||||||
|
SetTrieValue(g_ProtectedVars, cvar, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool:IsVarProtected(const String:cvar[])
|
||||||
|
{
|
||||||
|
decl dummy_value;
|
||||||
|
return GetTrieValue(g_ProtectedVars, cvar, dummy_value);
|
||||||
|
}
|
||||||
|
|
||||||
public OnAdminMenuReady(Handle:topmenu)
|
public OnAdminMenuReady(Handle:topmenu)
|
||||||
{
|
{
|
||||||
/* Block us from being called twice */
|
/* Block us from being called twice */
|
||||||
@ -244,12 +261,32 @@ public Action:Command_Cvar(client, args)
|
|||||||
{
|
{
|
||||||
if (args < 1)
|
if (args < 1)
|
||||||
{
|
{
|
||||||
ReplyToCommand(client, "[SM] Usage: sm_cvar <cvar> [value]");
|
if (client == 0)
|
||||||
|
{
|
||||||
|
ReplyToCommand(client, "[SM] Usage: sm_cvar <cvar|protect> [value]");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ReplyToCommand(client, "[SM] Usage: sm_cvar <cvar> [value]");
|
||||||
|
}
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
decl String:cvarname[64];
|
decl String:cvarname[64];
|
||||||
GetCmdArg(1, cvarname, sizeof(cvarname));
|
GetCmdArg(1, cvarname, sizeof(cvarname));
|
||||||
|
|
||||||
|
if (client == 0 && StrEqual(cvarname, "protect"))
|
||||||
|
{
|
||||||
|
if (args < 2)
|
||||||
|
{
|
||||||
|
ReplyToCommand(client, "[SM] Usage: sm_cvar <protect> <cvar>");
|
||||||
|
return Plugin_Handled;
|
||||||
|
}
|
||||||
|
GetCmdArg(2, cvarname, sizeof(cvarname));
|
||||||
|
ProtectVar(cvarname);
|
||||||
|
ReplyToCommand(client, "[SM] %t", "Cvar is now protected", cvarname);
|
||||||
|
return Plugin_Handled;
|
||||||
|
}
|
||||||
|
|
||||||
new Handle:hndl = FindConVar(cvarname);
|
new Handle:hndl = FindConVar(cvarname);
|
||||||
if (hndl == INVALID_HANDLE)
|
if (hndl == INVALID_HANDLE)
|
||||||
@ -257,36 +294,30 @@ public Action:Command_Cvar(client, args)
|
|||||||
ReplyToCommand(client, "[SM] %t", "Unable to find cvar", cvarname);
|
ReplyToCommand(client, "[SM] %t", "Unable to find cvar", cvarname);
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
new bool:allowed = false;
|
new bool:allowed = false;
|
||||||
if (GetConVarFlags(hndl) & FCVAR_PROTECTED)
|
new client_flags = GetUserFlagBits(client);
|
||||||
{
|
|
||||||
/* If they're root, allow anything */
|
if (client_flags & ADMFLAG_ROOT)
|
||||||
if ((GetUserFlagBits(client) & ADMFLAG_ROOT) == ADMFLAG_ROOT)
|
|
||||||
{
|
|
||||||
allowed = true;
|
|
||||||
}
|
|
||||||
/* If they're not root, and getting sv_password, see if they have ADMFLAG_PASSWORD */
|
|
||||||
else if (StrEqual(cvarname, "sv_password") && (GetUserFlagBits(client) & ADMFLAG_PASSWORD))
|
|
||||||
{
|
|
||||||
allowed = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* Do a check for the cheat cvar */
|
|
||||||
else if (StrEqual(cvarname, "sv_cheats"))
|
|
||||||
{
|
|
||||||
if (GetUserFlagBits(client) & ADMFLAG_CHEATS
|
|
||||||
|| GetUserFlagBits(client) & ADMFLAG_ROOT)
|
|
||||||
{
|
|
||||||
allowed = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* If we drop down to here, it was a normal cvar. */
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
allowed = true;
|
allowed = true;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (GetConVarFlags(hndl) & FCVAR_PROTECTED)
|
||||||
|
{
|
||||||
|
allowed = ((client_flags & ADMFLAG_PASSWORD) == ADMFLAG_PASSWORD);
|
||||||
|
}
|
||||||
|
else if (StrEqual(cvarname, "sv_cheats"))
|
||||||
|
{
|
||||||
|
allowed = ((client_flags & ADMFLAG_CHEATS) == ADMFLAG_CHEATS);
|
||||||
|
}
|
||||||
|
else if (!IsVarProtected(cvarname))
|
||||||
|
{
|
||||||
|
allowed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!allowed)
|
if (!allowed)
|
||||||
{
|
{
|
||||||
ReplyToCommand(client, "[SM] %t", "No access to cvar");
|
ReplyToCommand(client, "[SM] %t", "No access to cvar");
|
||||||
|
@ -129,4 +129,10 @@
|
|||||||
{
|
{
|
||||||
"en" "Admin access"
|
"en" "Admin access"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
"Cvar is now protected"
|
||||||
|
{
|
||||||
|
"#format" "{1:s}"
|
||||||
|
"en" "Cvar {1} is now protected."
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user