diff --git a/configs/core.cfg b/configs/core.cfg index c6507415..5e2091d3 100644 --- a/configs/core.cfg +++ b/configs/core.cfg @@ -46,4 +46,10 @@ * String to use as the silent chat trigger. Set an empty string to disable. */ "SilentChatTrigger" "/" + + /** + * Password setinfo key that clients must set. You must change this in order for + * passwords to work, for security reasons. + */ + "PassInfoVar" "_password" } diff --git a/core/PlayerManager.cpp b/core/PlayerManager.cpp index e41ebb05..2f7062df 100644 --- a/core/PlayerManager.cpp +++ b/core/PlayerManager.cpp @@ -98,6 +98,23 @@ void PlayerManager::OnSourceModShutdown() delete [] m_Players; } +ConfigResult PlayerManager::OnSourceModConfigChanged(const char *key, + const char *value, + ConfigSource source, + char *error, + size_t maxlength) +{ + if (strcmp(key, "PassInfoVar") == 0) + { + if (strcmp(value, "_password") != 0) + { + m_PassInfoVar.assign(value); + } + return ConfigResult_Accept; + } + return ConfigResult_Ignore; +} + void PlayerManager::OnServerActivate(edict_t *pEdictList, int edictCount, int clientMax) { if (m_FirstPass) @@ -119,13 +136,18 @@ void PlayerManager::OnServerActivate(edict_t *pEdictList, int edictCount, int cl SM_ExecuteAllConfigs(); } -bool CheckSetAdmin(int index, CPlayer *pPlayer, AdminId id) +bool PlayerManager::CheckSetAdmin(int index, CPlayer *pPlayer, AdminId id) { const char *password = g_Admins.GetAdminPassword(id); if (password != NULL) { + if (m_PassInfoVar.size() < 1) + { + return false; + } + /* Whoa... the user needs a password! */ - const char *given = engine->GetClientConVarValue(index, "_password"); + const char *given = engine->GetClientConVarValue(index, m_PassInfoVar.c_str()); if (!given || strcmp(given, password) != 0) { return false; diff --git a/core/PlayerManager.h b/core/PlayerManager.h index 912d23ad..2b5141fa 100644 --- a/core/PlayerManager.h +++ b/core/PlayerManager.h @@ -76,6 +76,7 @@ public: //SMGlobalClass void OnSourceModAllInitialized(); void OnSourceModShutdown(); void OnSourceModLevelEnd(); + ConfigResult OnSourceModConfigChanged(const char *key, const char *value, ConfigSource source, char *error, size_t maxlength); public: CPlayer *GetPlayerByIndex(int client) const; void RunAuthChecks(); @@ -108,6 +109,7 @@ public: } private: void OnServerActivate(edict_t *pEdictList, int edictCount, int clientMax); + bool CheckSetAdmin(int index, CPlayer *pPlayer, AdminId id); private: List m_hooks; IForward *m_clconnect; @@ -125,6 +127,7 @@ private: int m_PlayerCount; bool m_FirstPass; unsigned int *m_AuthQueue; + String m_PassInfoVar; }; extern PlayerManager g_Players;