Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
a6b6c12
[ADMIN] Chganges auth backend to use the forums instead of the DB
adamsong Aug 7, 2022
1d65d93
Remove dbranks flag
adamsong Aug 7, 2022
d85e1ef
I'm dumb
adamsong Aug 7, 2022
99acab3
re-promotes myself
adamsong Aug 7, 2022
c31656e
Re-use datums, rather than continually re-making them
adamsong Aug 7, 2022
4402c01
Delete the datum instead, easier to manage
adamsong Aug 7, 2022
4e347e2
Moved to an inhertiance based system for permissions management
adamsong Aug 9, 2022
30ea17f
Proccall protection and logging
adamsong Aug 9, 2022
6b5cabc
Linter
adamsong Aug 9, 2022
6e427c2
Update config
adamsong Aug 9, 2022
0f3796a
Fixes pp I hope
adamsong Aug 9, 2022
767a23b
Two letters made it do a bad, I am sad
adamsong Aug 9, 2022
eaf4e97
Clears forums admins when reloading
adamsong Aug 9, 2022
b2d6ecd
Adds db support
adamsong Aug 10, 2022
173114c
Update config
adamsong Aug 10, 2022
18a0620
Re-enables forum integration
adamsong Aug 10, 2022
ffd0d98
No editing the funny datum
adamsong Aug 11, 2022
454bfa4
Allow me to do the funny during the test merge
adamsong Aug 11, 2022
5341804
Didn't commit the changes
adamsong Aug 11, 2022
6c02250
Copying and pasting hard
adamsong Aug 11, 2022
4643d97
Sanitize ckey
adamsong Aug 11, 2022
badbe67
Var is unnecessary
adamsong Aug 11, 2022
9ab2b6c
Small debug log to debug dono chat
adamsong Aug 12, 2022
9b5e7ff
Fixes wrong proc call
adamsong Aug 12, 2022
51ae6a6
Move log, will be a bit much, but is fine because its temporary
adamsong Aug 12, 2022
5bced73
Made better log message
adamsong Aug 12, 2022
3ca838a
Fixed reload admins, added debug log to json_decode that was erroring
adamsong Aug 14, 2022
e0fa5f5
Expanded forums integration error handling
adamsong Aug 14, 2022
263ef45
Merge remote-tracking branch 'origin/master' into forum-integration
adamsong Aug 14, 2022
828f91a
Fully protects funny lists
adamsong Aug 16, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions code/__DEFINES/admin.dm
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
#define R_SOUNDS (1<<11)
#define R_SPAWN (1<<12)
#define R_AUTOLOGIN (1<<13)
#define R_DBRANKS (1<<14)
#define R_DEV (1<<15) // Stuff NOONE should be touching except for head-dev/maints, I guess council too..
#define R_DEV (1<<14) // Stuff NOONE should be touching except for head-dev/maints, I guess council too..
#define R_PERSIST_PERMS (1<<15) // Allow modification of persistent perms
#define R_EVERYTHING (1<<16)-1 //the sum of all other rank permissions, used for +EVERYTHING

#define R_DEFAULT R_AUTOLOGIN
Expand Down
2 changes: 1 addition & 1 deletion code/__DEFINES/misc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ GLOBAL_LIST_INIT(pda_styles, list(MONO, VT, ORBITRON, SHARE))
#define debug_usr(msg) if (GLOB.Debug2&&usr) to_chat(usr, \
type = MESSAGE_TYPE_DEBUG, \
text = "DEBUG: [msg]")
#define debug_admins(msg) if (GLOB.Debug2) to_chat(GLOB.admins, \
#define debug_admins(msg) if (GLOB.Debug2) to_chat(GLOB.permissions.admins, \
type = MESSAGE_TYPE_DEBUG, \
text = "DEBUG: [msg]")
#define debug_world_log(msg) if (GLOB.Debug2) log_world("DEBUG: [msg]")
Expand Down
70 changes: 0 additions & 70 deletions code/__HELPERS/roundend.dm
Original file line number Diff line number Diff line change
Expand Up @@ -622,76 +622,6 @@
count++
return objective_parts.Join("<br>")

/datum/controller/subsystem/ticker/proc/save_admin_data()
if(IsAdminAdvancedProcCall())
to_chat(usr, "<span class='admin prefix'>Admin rank DB Sync blocked: Advanced ProcCall detected.</span>")
return
if(CONFIG_GET(flag/admin_legacy_system)) //we're already using legacy system so there's nothing to save
return
else if(load_admins(TRUE)) //returns true if there was a database failure and the backup was loaded from
return
sync_ranks_with_db()
var/list/sql_admins = list()
for(var/i in GLOB.protected_admins)
var/datum/admins/A = GLOB.protected_admins[i]
sql_admins += list(list("ckey" = A.target, "rank" = A.rank.name))
SSdbcore.MassInsert(format_table_name("admin"), sql_admins, duplicate_key = TRUE)
var/datum/DBQuery/query_admin_rank_update = SSdbcore.NewQuery("UPDATE [format_table_name("player")] p INNER JOIN [format_table_name("admin")] a ON p.ckey = a.ckey SET p.lastadminrank = a.rank")
query_admin_rank_update.Execute()
qdel(query_admin_rank_update)

//json format backup file generation stored per server
var/json_file = file("data/admins_backup.json")
var/list/file_data = list("ranks" = list(), "admins" = list())
for(var/datum/admin_rank/R in GLOB.admin_ranks)
file_data["ranks"]["[R.name]"] = list()
file_data["ranks"]["[R.name]"]["include rights"] = R.include_rights
file_data["ranks"]["[R.name]"]["exclude rights"] = R.exclude_rights
file_data["ranks"]["[R.name]"]["can edit rights"] = R.can_edit_rights
for(var/i in GLOB.admin_datums+GLOB.deadmins)
var/datum/admins/A = GLOB.admin_datums[i]
if(!A)
A = GLOB.deadmins[i]
if (!A)
continue
file_data["admins"]["[i]"] = list()
file_data["admins"]["[i]"]["rank"] = A.rank.name
file_data["admins"]["[i]"]["ip_cache"] = A.ip_cache
file_data["admins"]["[i]"]["cid_cache"] = A.cid_cache
fdel(json_file)
WRITE_FILE(json_file, json_encode(file_data))

/datum/controller/subsystem/ticker/proc/update_everything_flag_in_db()
for(var/datum/admin_rank/R in GLOB.admin_ranks)
var/list/flags = list()
if(R.include_rights == R_EVERYTHING)
flags += "flags"
if(R.exclude_rights == R_EVERYTHING)
flags += "exclude_flags"
if(R.can_edit_rights == R_EVERYTHING)
flags += "can_edit_flags"
if(!flags.len)
continue
var/flags_to_check = flags.Join(" != [R_EVERYTHING] AND ") + " != [R_EVERYTHING]"
var/datum/DBQuery/query_check_everything_ranks = SSdbcore.NewQuery(
"SELECT flags, exclude_flags, can_edit_flags FROM [format_table_name("admin_ranks")] WHERE rank = :rank AND ([flags_to_check])",
list("rank" = R.name)
)
if(!query_check_everything_ranks.Execute())
qdel(query_check_everything_ranks)
return
if(query_check_everything_ranks.NextRow()) //no row is returned if the rank already has the correct flag value
var/flags_to_update = flags.Join(" = [R_EVERYTHING], ") + " = [R_EVERYTHING]"
var/datum/DBQuery/query_update_everything_ranks = SSdbcore.NewQuery(
"UPDATE [format_table_name("admin_ranks")] SET [flags_to_update] WHERE rank = :rank",
list("rank" = R.name)
)
if(!query_update_everything_ranks.Execute())
qdel(query_update_everything_ranks)
return
qdel(query_update_everything_ranks)
qdel(query_check_everything_ranks)

/datum/controller/subsystem/ticker/proc/cargoking()
var/datum/achievement/cargoking/CK = SSachievements.get_achievement(/datum/achievement/cargoking)
var/cargoking = FALSE
Expand Down
36 changes: 18 additions & 18 deletions code/__HELPERS/type2type.dm
Original file line number Diff line number Diff line change
Expand Up @@ -195,38 +195,38 @@
//Converts a rights bitfield into a string
/proc/rights2text(rights, seperator="", prefix = "+")
seperator += prefix
if(rights & R_BUILDMODE)
. += "[seperator]BUILDMODE"
if(rights & R_ADMIN)
. += "[seperator]ADMIN"
if(rights & R_AUTOLOGIN)
. += "[seperator]AUTOLOGIN"
if(rights & R_BAN)
. += "[seperator]BAN"
if(rights & R_FUN)
. += "[seperator]FUN"
if(rights & R_SERVER)
. += "[seperator]SERVER"
if(rights & R_BUILDMODE)
. += "[seperator]BUILDMODE"
if(rights & R_DEBUG)
. += "[seperator]DEBUG"
if(rights & R_POSSESS)
. += "[seperator]POSSESS"
if(rights & R_DEV)
. += "[seperator]DEV"
if(rights & R_FUN)
. += "[seperator]FUN"
if(rights & R_PERMISSIONS)
. += "[seperator]PERMISSIONS"
if(rights & R_STEALTH)
. += "[seperator]STEALTH"
if(rights & R_PERSIST_PERMS)
. += "[seperator]PERSISTPERMS"
if(rights & R_POLL)
. += "[seperator]POLL"
if(rights & R_VAREDIT)
. += "[seperator]VAREDIT"
if(rights & R_POSSESS)
. += "[seperator]POSSESS"
if(rights & R_SERVER)
. += "[seperator]SERVER"
if(rights & R_SOUNDS)
. += "[seperator]SOUND"
if(rights & R_SPAWN)
. += "[seperator]SPAWN"
if(rights & R_AUTOLOGIN)
. += "[seperator]AUTOLOGIN"
if(rights & R_DBRANKS)
. += "[seperator]DBRANKS"
if(rights & R_DEV)
. += "[seperator]DEV"
if(rights & R_STEALTH)
. += "[seperator]STEALTH"
if(rights & R_VAREDIT)
. += "[seperator]VAREDIT"
if(!.)
. = "NONE"
return .
Expand Down
4 changes: 2 additions & 2 deletions code/_globalvars/bitfields.dm
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ GLOBAL_LIST_INIT(bitfields, list(
"SOUNDS" = R_SOUNDS,
"SPAWN" = R_SPAWN,
"AUTOLOGIN" = R_AUTOLOGIN,
"DBRANKS" = R_DBRANKS,
"DEV" = R_DEV
"DEV" = R_DEV,
"PERSISTPERMS" = R_PERSIST_PERMS
),
"interaction_flags_atom" = list(
"INTERACT_ATOM_REQUIRES_ANCHORED" = INTERACT_ATOM_REQUIRES_ANCHORED,
Expand Down
3 changes: 0 additions & 3 deletions code/_globalvars/lists/mobs.dm
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
GLOBAL_LIST_EMPTY(clients) //all clients
GLOBAL_LIST_EMPTY(admins) //all clients whom are admins
GLOBAL_PROTECT(admins)
GLOBAL_LIST_EMPTY(deadmins) //all ckeys who have used the de-admin verb.

GLOBAL_LIST_EMPTY(directory) //all ckeys with associated client
GLOBAL_LIST_EMPTY(stealthminID) //reference list with IDs that store ckeys, for stealthmins
Expand Down
5 changes: 1 addition & 4 deletions code/controllers/configuration/entries/general.dm
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,6 @@
min_val = 0 //oranges warned us
integer = FALSE

/datum/config_entry/flag/admin_legacy_system //Defines whether the server uses the legacy admin system with admins.txt or the SQL system
protection = CONFIG_ENTRY_LOCKED

/datum/config_entry/flag/protect_legacy_admins //Stops any admins loaded by the legacy system from having their rank edited by the permissions panel
protection = CONFIG_ENTRY_LOCKED

Expand All @@ -173,7 +170,7 @@
/datum/config_entry/flag/enable_localhost_rank //Gives the !localhost! rank to any client connecting from 127.0.0.1 or ::1
protection = CONFIG_ENTRY_LOCKED

/datum/config_entry/flag/load_legacy_ranks_only //Loads admin ranks only from legacy admin_ranks.txt, while enabled ranks are mirrored to the database
/datum/config_entry/string/permissions_backend // Sets the permissions backend to use
protection = CONFIG_ENTRY_LOCKED

/datum/config_entry/string/hostedby
Expand Down
10 changes: 5 additions & 5 deletions code/controllers/failsafe.dm
Original file line number Diff line number Diff line change
Expand Up @@ -59,28 +59,28 @@ GLOBAL_REAL(Failsafe, /datum/controller/failsafe)
message_admins(span_adminnotice("Notice: DEFCON [defcon_pretty()]. The Master Controller has not fired in the last [(5-defcon) * processing_interval] ticks."))
--defcon
if(2)
to_chat(GLOB.admins, span_boldannounce("Warning: DEFCON [defcon_pretty()]. The Master Controller has not fired in the last [(5-defcon) * processing_interval] ticks. Automatic restart in [processing_interval] ticks."))
to_chat(GLOB.permissions.admins, span_boldannounce("Warning: DEFCON [defcon_pretty()]. The Master Controller has not fired in the last [(5-defcon) * processing_interval] ticks. Automatic restart in [processing_interval] ticks."))
--defcon
if(1)

to_chat(GLOB.admins, span_boldannounce("Warning: DEFCON [defcon_pretty()]. The Master Controller has still not fired within the last [(5-defcon) * processing_interval] ticks. Killing and restarting..."))
to_chat(GLOB.permissions.admins, span_boldannounce("Warning: DEFCON [defcon_pretty()]. The Master Controller has still not fired within the last [(5-defcon) * processing_interval] ticks. Killing and restarting..."))
--defcon
var/rtn = Recreate_MC()
if(rtn > 0)
defcon = 4
master_iteration = 0
to_chat(GLOB.admins, span_adminnotice("MC restarted successfully"))
to_chat(GLOB.permissions.admins, span_adminnotice("MC restarted successfully"))
else if(rtn < 0)
log_game("FailSafe: Could not restart MC, runtime encountered. Entering defcon 0")
to_chat(GLOB.admins, span_boldannounce("ERROR: DEFCON [defcon_pretty()]. Could not restart MC, runtime encountered. I will silently keep retrying."))
to_chat(GLOB.permissions.admins, span_boldannounce("ERROR: DEFCON [defcon_pretty()]. Could not restart MC, runtime encountered. I will silently keep retrying."))
//if the return number was 0, it just means the mc was restarted too recently, and it just needs some time before we try again
//no need to handle that specially when defcon 0 can handle it
if(0) //DEFCON 0! (mc failed to restart)
var/rtn = Recreate_MC()
if(rtn > 0)
defcon = 4
master_iteration = 0
to_chat(GLOB.admins, span_adminnotice("MC restarted successfully"))
to_chat(GLOB.permissions.admins, span_adminnotice("MC restarted successfully"))
else
defcon = min(defcon + 1,5)
master_iteration = Master.iteration
Expand Down
2 changes: 1 addition & 1 deletion code/controllers/master.dm
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ GLOBAL_REAL(Master, /datum/controller/master) = new
msg = "The [BadBoy.name] subsystem seems to be destabilizing the MC and will be offlined."
BadBoy.flags |= SS_NO_FIRE
if(msg)
to_chat(GLOB.admins, span_boldannounce("[msg]"))
to_chat(GLOB.permissions.admins, span_boldannounce("[msg]"))
log_world(msg)

if (istype(Master.subsystems))
Expand Down
2 changes: 1 addition & 1 deletion code/controllers/subsystem.dm
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@
SEND_SIGNAL(src, COMSIG_SUBSYSTEM_POST_INITIALIZE, start_timeofday)
var/time = (REALTIMEOFDAY - start_timeofday)/10
var/msg = "Initialized [name] subsystem within [time] second[time == 1 ? "" : "s"]!" // Yogs -- quieter subsystem initialization
to_chat(GLOB.admins,
to_chat(GLOB.permissions.admins,
type = MESSAGE_TYPE_DEBUG,
html = span_notice(msg),
confidential = FALSE)
Expand Down
2 changes: 1 addition & 1 deletion code/controllers/subsystem/air.dm
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ SUBSYSTEM_DEF(air)

//Yogs start -- prettier atmos notices
var/msg = "HEY! LISTEN! [(world.timeofday - timer)/10] seconds were wasted processing [starting_ats] turf(s) (connected to [ending_ats] other turfs) with atmos differences at round start."
to_chat(GLOB.admins,
to_chat(GLOB.permissions.admins,
type = MESSAGE_TYPE_DEBUG,
html = span_notice(msg),
confidential = FALSE)
Expand Down
2 changes: 0 additions & 2 deletions code/controllers/subsystem/ticker.dm
Original file line number Diff line number Diff line change
Expand Up @@ -738,5 +738,3 @@ SUBSYSTEM_DEF(ticker)

/datum/controller/subsystem/ticker/Shutdown()
gather_newscaster() //called here so we ensure the log is created even upon admin reboot
save_admin_data()
update_everything_flag_in_db()
4 changes: 2 additions & 2 deletions code/controllers/subsystem/vote.dm
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ SUBSYSTEM_DEF(vote)
SSmapping.map_voted = TRUE
if(restart)
var/active_admins = FALSE
for(var/client/C in GLOB.admins + GLOB.deadmins)
for(var/client/C in GLOB.permissions.admins + GLOB.permissions.deadmins)
if(!C.is_afk() && check_rights_for(C, R_SERVER))
active_admins = TRUE
break
Expand Down Expand Up @@ -170,7 +170,7 @@ SUBSYSTEM_DEF(vote)
return FALSE
var/lower_admin = FALSE
var/ckey = ckey(initiator_key)
if(GLOB.admin_datums[ckey])
if(GLOB.permissions.admin_datums[ckey])
lower_admin = TRUE

if(!mode)
Expand Down
2 changes: 1 addition & 1 deletion code/game/gamemodes/game_mode.dm
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@
continue //Ghosted while alive


for (var/C in GLOB.admins)
for (var/C in GLOB.permissions.admins)
to_chat(C, msg.Join())
log_admin(msg.Join())

Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/charter.dm
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
// Autoapproves after a certain time
rename_callback = CALLBACK(src, .proc/rename_station, new_name, user.name, user.real_name, key_name(user))
response_timer_id = addtimer(rename_callback, approval_time, TIMER_STOPPABLE)
to_chat(GLOB.admins,
to_chat(GLOB.permissions.admins,
span_adminnotice("<b><font color=orange>CUSTOM STATION RENAME:</font></b>[ADMIN_LOOKUPFLW(user)] proposes to rename the [name_type] to [new_name] (will auto-approve in [DisplayTimeText(approval_time)]).\
(<a HREF='?_src_=holder;[HrefToken(TRUE)];accept_custom_name=[REF(src)]'>ACCEPT</a> or <a HREF='?_src_=holder;[HrefToken(TRUE)];reject_custom_name=[REF(src)]'>REJECT</a>) [ADMIN_SMITE(user)] [ADMIN_CENTCOM_REPLY(user)]"))

Expand Down
4 changes: 3 additions & 1 deletion code/game/world.dm
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ GLOBAL_VAR(restart_counter)

config.Load(params[OVERRIDE_CONFIG_DIRECTORY_PARAMETER])

load_admins()
init_permissions()

GLOB.permissions.start()

//SetupLogs depends on the RoundID, so lets check
//DB schema and set RoundID if we can
Expand Down
2 changes: 1 addition & 1 deletion code/modules/admin/IsBanned.dm
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
//magic voodo to check for a key in a list while also adding that key to the list without having to do two associated lookups
var/message = !checkedckeys[ckey]++

if(GLOB.admin_datums[ckey] || GLOB.deadmins[ckey])
if(GLOB.permissions.admin_datums[ckey] || GLOB.permissions.deadmins[ckey])
admin = TRUE

var/client/C = GLOB.directory[ckey]
Expand Down
6 changes: 3 additions & 3 deletions code/modules/admin/admin.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
////////////////////////////////
/proc/message_admins(msg)
msg = span_admin("<span class=\"prefix\">ADMIN LOG:</span> <span class=\"message\">[msg]</span>")
to_chat(GLOB.admins,
to_chat(GLOB.permissions.admins,
type = MESSAGE_TYPE_ADMINLOG,
html = msg,
confidential = TRUE)

/proc/relay_msg_admins(msg)
msg = span_admin("<span class=\"prefix\">RELAY:</span> <span class=\"message\">[msg]</span>")
to_chat(GLOB.admins,
to_chat(GLOB.permissions.admins,
type = MESSAGE_TYPE_ADMINLOG,
html = msg,
confidential = TRUE)
Expand Down Expand Up @@ -42,7 +42,7 @@
body += "<body>Options panel for <b>[M]</b>"
if(M.client)
body += " played by <b>[M.client]</b> "
body += "\[<A href='?_src_=holder;[HrefToken()];editrights=[(GLOB.admin_datums[M.client.ckey] || GLOB.deadmins[M.client.ckey]) ? "rank" : "add"];key=[M.key]'>[M.client.holder ? M.client.holder.rank : "Player"]</A>\]"
body += "\[<A href='?_src_=holder;[HrefToken()];editrights=[(GLOB.permissions.admin_datums[M.client.ckey] || GLOB.permissions.deadmins[M.client.ckey]) ? "rank" : "add"];key=[M.key]'>[M.client.holder ? M.client.holder.rank_name() : "Player"]</A>\]"
if(CONFIG_GET(flag/use_exp_tracking))
body += "\[<A href='?_src_=holder;[HrefToken()];getplaytimewindow=[REF(M)]'>" + M.client.get_exp_living() + "</a> | "
body += " <A href='?_src_=holder;[HrefToken()];toggleexempt=[REF(M)]'>Toggle Exempt</a>\]"
Expand Down
Loading