config: harden admin page password handling
This commit is contained in:
@@ -75,7 +75,7 @@ string g_stDefaultQuestObjectDir = "./quest/object";
|
|||||||
std::set<string> g_setQuestObjectDir;
|
std::set<string> g_setQuestObjectDir;
|
||||||
|
|
||||||
std::vector<std::string> g_stAdminPageIP;
|
std::vector<std::string> g_stAdminPageIP;
|
||||||
std::string g_stAdminPagePassword = "SHOWMETHEMONEY";
|
std::string g_stAdminPagePassword;
|
||||||
|
|
||||||
string g_stBlockDate = "30000705";
|
string g_stBlockDate = "30000705";
|
||||||
|
|
||||||
@@ -195,7 +195,17 @@ static void FN_log_adminpage()
|
|||||||
++iter;
|
++iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
sys_log(1, "ADMIN_PAGE_PASSWORD = %s", g_stAdminPagePassword.c_str());
|
sys_log(1, "ADMIN_PAGE_PASSWORD = %s", g_stAdminPagePassword.empty() ? "[disabled]" : "[configured]");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void FN_apply_adminpage_password_env()
|
||||||
|
{
|
||||||
|
const char* env_password = std::getenv("METIN2_ADMINPAGE_PASSWORD");
|
||||||
|
|
||||||
|
if (!env_password)
|
||||||
|
return;
|
||||||
|
|
||||||
|
g_stAdminPagePassword = env_password;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1128,6 +1138,7 @@ void config_init(const string& st_localeServiceName)
|
|||||||
LoadStateUserCount();
|
LoadStateUserCount();
|
||||||
|
|
||||||
CWarMapManager::instance().LoadWarMapInfo(NULL);
|
CWarMapManager::instance().LoadWarMapInfo(NULL);
|
||||||
|
FN_apply_adminpage_password_env();
|
||||||
|
|
||||||
FN_log_adminpage();
|
FN_log_adminpage();
|
||||||
}
|
}
|
||||||
@@ -1238,4 +1249,3 @@ bool IsValidFileCRC(DWORD dwCRC)
|
|||||||
return s_set_dwFileCRC.find(dwCRC) != s_set_dwFileCRC.end();
|
return s_set_dwFileCRC.find(dwCRC) != s_set_dwFileCRC.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -245,7 +245,7 @@ int CInputHandshake::HandleText(LPDESC d, const char * c_pData)
|
|||||||
stResult = "YES";
|
stResult = "YES";
|
||||||
}
|
}
|
||||||
//else if (!stBuf.compare("SHOWMETHEMONEY"))
|
//else if (!stBuf.compare("SHOWMETHEMONEY"))
|
||||||
else if (stBuf == g_stAdminPagePassword)
|
else if (!g_stAdminPagePassword.empty() && stBuf == g_stAdminPagePassword)
|
||||||
{
|
{
|
||||||
if (!IsEmptyAdminPage())
|
if (!IsEmptyAdminPage())
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user