Non temp workaround for admins matching stickybans because of… (#46462)

* temp workaround for admins matching stickybans because of a byond bug.

* Globalify the lists used for stickyban exemptions
This commit is contained in:
oranges
2019-09-26 13:45:19 +12:00
committed by Rob Bailey
parent 22564a3eaf
commit 9d91853f78
5 changed files with 38 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
GLOBAL_LIST_EMPTY(stickybanadminexemptions) //stores a list of ckeys exempted from a stickyban (workaround for a bug)
GLOBAL_LIST_EMPTY(stickybanadmintexts) //stores the entire stickyban list temporarily
GLOBAL_VAR(stickbanadminexemptiontimerid) //stores the timerid of the callback that restores all stickybans after an admin joins

View File

@@ -10,11 +10,15 @@ SUBSYSTEM_DEF(stickyban)
/datum/controller/subsystem/stickyban/Initialize(timeofday)
if (length(GLOB.stickybanadminexemptions))
restore_stickybans()
var/list/bannedkeys = sticky_banned_ckeys()
//sanitize the sticky ban list
//delete db bans that no longer exist in the database and add new legacy bans to the database
if (SSdbcore.Connect() || length(SSstickyban.dbcache))
if (length(GLOB.stickybanadminexemptions))
restore_stickybans()
for (var/oldban in (world.GetConfig("ban") - bannedkeys))
var/ckey = ckey(oldban)
if (ckey != oldban && (ckey in bannedkeys))
@@ -29,6 +33,8 @@ SUBSYSTEM_DEF(stickyban)
bannedkeys += ckey
world.SetConfig("ban", oldban, null)
if (length(GLOB.stickybanadminexemptions)) //the previous loop can sleep
restore_stickybans()
for (var/bannedkey in bannedkeys)
var/ckey = ckey(bannedkey)

View File

@@ -89,7 +89,23 @@
[expires]"}
log_access("Failed Login: [key] [computer_id] [address] - Banned (#[i["id"]])")
return list("reason"="Banned","desc"="[desc]")
if (admin)
if (GLOB.directory[ckey])
return
//oh boy, so basically, because of a bug in byond, sometimes stickyban matches don't trigger here, so we can't exempt admins.
// Whitelisting the ckey with the byond whitelist field doesn't work.
// So we instead have to remove every stickyban than later re-add them.
if (!length(GLOB.stickybanadminexemptions))
for (var/banned_ckey in world.GetConfig("ban"))
GLOB.stickybanadmintexts[banned_ckey] = world.GetConfig("ban", banned_ckey)
world.SetConfig("ban", banned_ckey, null)
if (!SSstickyban.initialized)
return
GLOB.stickybanadminexemptions[ckey] = world.time
stoplag() // sleep a byond tick
GLOB.stickbanadminexemptiontimerid = addtimer(CALLBACK(GLOBAL_PROC, /proc/restore_stickybans), 5 SECONDS, TIMER_STOPPABLE|TIMER_UNIQUE|TIMER_OVERRIDE)
return
var/list/ban = ..() //default pager ban stuff
if (ban)
@@ -199,6 +215,14 @@
return .
/proc/restore_stickybans()
for (var/banned_ckey in GLOB.stickybanadmintexts)
world.SetConfig("ban", banned_ckey, GLOB.stickybanadmintexts[banned_ckey])
GLOB.stickybanadminexemptions = list()
GLOB.stickybanadmintexts = list()
if (GLOB.stickbanadminexemptiontimerid)
deltimer(GLOB.stickbanadminexemptiontimerid)
GLOB.stickbanadminexemptiontimerid = null
#undef STICKYBAN_MAX_MATCHES
#undef STICKYBAN_MAX_EXISTING_USER_MATCHES

View File

@@ -278,6 +278,10 @@ GLOBAL_LIST_EMPTY(external_rsc_urls)
. = ..() //calls mob.Login()
if (length(GLOB.stickybanadminexemptions))
GLOB.stickybanadminexemptions -= ckey
if (!length(GLOB.stickybanadminexemptions))
restore_stickybans()
if (byond_version >= 512)
if (!byond_build || byond_build < 1386)

View File

@@ -162,6 +162,7 @@
#include "code\_globalvars\misc.dm"
#include "code\_globalvars\regexes.dm"
#include "code\_globalvars\traits.dm"
#include "code\_globalvars\lists\admin.dm"
#include "code\_globalvars\lists\flavor_misc.dm"
#include "code\_globalvars\lists\maintenance_loot.dm"
#include "code\_globalvars\lists\mapping.dm"