From 48f37a3a5c5339df393be7042626366fcd81b2cd Mon Sep 17 00:00:00 2001 From: Ryll Ryll <3589655+Ryll-Ryll@users.noreply.github.com> Date: Thu, 3 Feb 2022 14:44:47 -0500 Subject: [PATCH] Adds a config toggle for granting admin server profile access (#64408) * adds allow_admin_profiling config entry * Update config/config.txt Co-authored-by: Mothblocks <35135081+Mothblocks@users.noreply.github.com> * per mso request, add the second define * actually adds the second define * allows through Profile requests if the config isn't init'd yet * makes sure we're loaded * Update code/game/world.dm Co-authored-by: Kyle Spier-Swenson Co-authored-by: Mothblocks <35135081+Mothblocks@users.noreply.github.com> Co-authored-by: Kyle Spier-Swenson --- code/controllers/configuration/entries/general.dm | 4 ++++ code/game/world.dm | 4 ++++ code/modules/admin/holder2.dm | 5 +++-- config/config.txt | 6 ++++++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/code/controllers/configuration/entries/general.dm b/code/controllers/configuration/entries/general.dm index 4c2b28f4a7c..ba5b42123e4 100644 --- a/code/controllers/configuration/entries/general.dm +++ b/code/controllers/configuration/entries/general.dm @@ -615,3 +615,7 @@ default = 5 min_val = 0 integer = TRUE + +/datum/config_entry/flag/forbid_all_profiling + +/datum/config_entry/flag/forbid_admin_profiling diff --git a/code/game/world.dm b/code/game/world.dm index 2216a23d675..815d5cf48be 100644 --- a/code/game/world.dm +++ b/code/game/world.dm @@ -379,5 +379,9 @@ GLOBAL_VAR(restart_counter) /world/proc/on_tickrate_change() SStimer?.reset_buckets() +/world/Profile(command, type, format) + if((command & PROFILE_STOP) || !global.config?.loaded || !CONFIG_GET(flag/forbid_all_profiling)) + . = ..() + #undef OVERRIDE_LOG_DIRECTORY_PARAMETER #undef NO_INIT_PARAMETER diff --git a/code/modules/admin/holder2.dm b/code/modules/admin/holder2.dm index a8172670a0a..d4ed28bda79 100644 --- a/code/modules/admin/holder2.dm +++ b/code/modules/admin/holder2.dm @@ -62,8 +62,9 @@ GLOBAL_PROTECT(href_token) rank = R admin_signature = "Nanotrasen Officer #[rand(0,9)][rand(0,9)][rand(0,9)]" href_token = GenerateToken() - if(R.rights & R_DEBUG) //grant profile access - world.SetConfig("APP/admin", ckey, "role=admin") + if(!CONFIG_GET(flag/forbid_admin_profiling)) + if(R.rights & R_DEBUG) //grant profile access, assuming admin profile access is enabled + world.SetConfig("APP/admin", ckey, "role=admin") //only admins with +ADMIN start admined if(protected) GLOB.protected_admins[target] = src diff --git a/config/config.txt b/config/config.txt index 0a3bd24a56f..bc010e3a77e 100644 --- a/config/config.txt +++ b/config/config.txt @@ -602,3 +602,9 @@ CACHE_ASSETS 0 ## The number of PR announcements allowed for the same pull request per round ## This makes sure that somebody can only spam a few reopens and closes before being ignored PR_ANNOUNCEMENTS_PER_ROUND 5 + +## Uncomment to block all attempts to profile, for performance reasons +#FORBID_ALL_PROFILING + +## Uncomment to block granting profiling privileges to users with R_DEBUG, for performance purposes +#FORBID_ADMIN_PROFILING