From c0f0ce386045ae952f8b75c345d2590c067278c0 Mon Sep 17 00:00:00 2001 From: Jesusaves Date: Sat, 1 Jun 2024 14:34:13 -0300 Subject: Improve @gm command security on forks --- npc/commands/super-menu.txt | 25 ++++++++++++------------- npc/functions/permissions.txt | 10 ++++++++++ npc/scripts.conf | 2 +- 3 files changed, 23 insertions(+), 14 deletions(-) (limited to 'npc') diff --git a/npc/commands/super-menu.txt b/npc/commands/super-menu.txt index 7ae8c206e..59598681b 100644 --- a/npc/commands/super-menu.txt +++ b/npc/commands/super-menu.txt @@ -82,35 +82,34 @@ OnGM: } .@auth=true; // NOTE: Pihro and Pyndragon do not have player chars - // FIXME: Use account ID over char name (multi-server stable) // Administration - if (strcharinfo(0) == "Jesusalva") { // 0005 + if (check_nickid("Jesusalva", "0005")) { setgroupid(99); - } else if (strcharinfo(0) == "Saulc") { // 0004 + } else if (check_nickid("Saulc", "0004")) { setgroupid(99); // Game Masters - } else if (strcharinfo(0) == "ThinkSome") { // 0817 + } else if (check_nickid("ThinkSome", "0817")) { setgroupid(80); - } else if (strcharinfo(0) == "demure") { // 0777 + } else if (check_nickid("demure", "0777")) { setgroupid(80); - } else if (strcharinfo(0) == "jak1") { // 0002 + } else if (check_nickid("jak1", "0002")) { setgroupid(80); // Game Officers - } else if (strcharinfo(0) == "seeds") { // 0409 + } else if (check_nickid("seeds", "0409")) { setgroupid(60); - } else if (strcharinfo(0) == "kytty") { // 0606 + } else if (check_nickid("kytty", "0606")) { setgroupid(60); - } else if (strcharinfo(0) == "cuoco") { // 0620 + } else if (check_nickid("cuoco", "0620")) { setgroupid(60); // Support Staff - } else if (strcharinfo(0) == "Ledmitz") { // 0585 + } else if (check_nickid("Ledmitz", "0585")) { setgroupid((debug ? 5 : 2)); - } else if (strcharinfo(0) == "Meway") { // 1078 + } else if (check_nickid("Meway", "1078")) { setgroupid((debug ? 5 : 2)); - } else if (strcharinfo(0) == "HoraK") { // 0008 + } else if (check_nickid("HoraK", "0008")) { setgroupid((debug ? 5 : 2)); - } else if (strcharinfo(0) == "Reid") { // 0741 + } else if (check_nickid("Reid", "0741")) { setgroupid((debug ? 5 : 2)); // Test Server grants } else if (debug && getgroupid() == 1) { diff --git a/npc/functions/permissions.txt b/npc/functions/permissions.txt index 2838f7a92..c9539aacb 100644 --- a/npc/functions/permissions.txt +++ b/npc/functions/permissions.txt @@ -23,3 +23,13 @@ function script is_staff { function script is_sponsor { return (getgmlevel()); } + +// Used internally by @gm +function script check_nickid { + .@n$ = getarg(0); + .@i$ = getarg(1); + if (strcharinfo(0) != .@n$) return false; + if (debug || $@GM_OVERRIDE) return true; + if (compare(str(getcharid(3)), .@i$)) return true; + return false; +} diff --git a/npc/scripts.conf b/npc/scripts.conf index ab2a6f850..79a81df81 100644 --- a/npc/scripts.conf +++ b/npc/scripts.conf @@ -1,8 +1,8 @@ // This is the main script import file // Critical functions -"npc/functions/permissions.txt", "npc/functions/string.txt", +"npc/functions/permissions.txt", "npc/functions/main.txt", "npc/functions/array.txt", "npc/functions/bitwise.txt", -- cgit v1.2.3-70-g09d2