Added a more intuitive method for rcon-protecting cvars.

Added SQL cvars to the protected list
This commit is contained in:
Steve Dudenhoeffer 2007-04-17 19:03:25 +00:00
parent 1ec4d9cc7d
commit 51f8d7f84e

View File

@ -35,10 +35,6 @@
#include <amxmodx> #include <amxmodx>
#include <amxmisc> #include <amxmisc>
#define MAXRCONCVARS 16
new g_cvarRcon[MAXRCONCVARS][32]
new g_cvarRconNum
new g_pauseCon new g_pauseCon
new Float:g_pausAble new Float:g_pausAble
new bool:g_Paused new bool:g_Paused
@ -99,6 +95,13 @@ public plugin_cfg()
server_cmd(g_addCvar, "amx_reserved_slots") server_cmd(g_addCvar, "amx_reserved_slots")
server_cmd(g_addCvar, "amx_reservation") server_cmd(g_addCvar, "amx_reservation")
server_cmd(g_addCvar, "amx_conmotd_file") server_cmd(g_addCvar, "amx_conmotd_file")
server_cmd(g_addCvar, "amx_sql_table");
server_cmd(g_addCvar, "amx_sql_host");
server_cmd(g_addCvar, "amx_sql_user");
server_cmd(g_addCvar, "amx_sql_pass");
server_cmd(g_addCvar, "amx_sql_db");
server_cmd(g_addCvar, "amx_sql_type");
} }
public cmdKick(id, level, cid) public cmdKick(id, level, cid)
@ -473,12 +476,14 @@ public cmdMap(id, level, cid)
return PLUGIN_HANDLED return PLUGIN_HANDLED
} }
onlyRcon(name[]) stock bool:onlyRcon(const name[])
{ {
for (new a = 0; a < g_cvarRconNum; ++a) new ptr=get_cvar_pointer(name);
if (equali(g_cvarRcon[a], name)) if (ptr && get_pcvar_flags(ptr) & FCVAR_PROTECTED)
return 1 {
return 0 return true;
}
return false;
} }
public cmdCvar(id, level, cid) public cmdCvar(id, level, cid)
@ -495,12 +500,14 @@ public cmdCvar(id, level, cid)
if (equal(arg, "add") && (get_user_flags(id) & ADMIN_RCON)) if (equal(arg, "add") && (get_user_flags(id) & ADMIN_RCON))
{ {
if (cvar_exists(arg2)) if ((pointer=get_cvar_pointer(arg2))!=0)
{ {
if (g_cvarRconNum < MAXRCONCVARS) new flags=get_pcvar_flags(pointer);
copy(g_cvarRcon[g_cvarRconNum++], 31, arg2)
else if (!(flags & FCVAR_PROTECTED))
console_print(id, "[AMXX] %L", id, "NO_MORE_CVARS") {
set_pcvar_flags(pointer,flags | FCVAR_PROTECTED);
}
} }
return PLUGIN_HANDLED return PLUGIN_HANDLED
} }
@ -513,14 +520,14 @@ public cmdCvar(id, level, cid)
if (onlyRcon(arg) && !(get_user_flags(id) & ADMIN_RCON)) if (onlyRcon(arg) && !(get_user_flags(id) & ADMIN_RCON))
{ {
console_print(id, "[AMXX] %L", id, "CVAR_NO_ACC") // Exception for the new onlyRcon rules:
return PLUGIN_HANDLED // sv_password is allowed to be modified by ADMIN_PASSWORD
} if (!(equali(arg,"sv_password") && (get_user_flags(id) & ADMIN_PASSWORD)))
else if (equali(arg, "sv_password") && !(get_user_flags(id) & ADMIN_PASSWORD))
{ {
console_print(id, "[AMXX] %L", id, "CVAR_NO_ACC") console_print(id, "[AMXX] %L", id, "CVAR_NO_ACC")
return PLUGIN_HANDLED return PLUGIN_HANDLED
} }
}
if (read_argc() < 3) if (read_argc() < 3)
{ {
@ -962,3 +969,4 @@ public cmdNick(id, level, cid)
return PLUGIN_HANDLED return PLUGIN_HANDLED
} }