Added a warning if the webadmin is enabled without any users. (#5499)
This commit is contained in:
parent
a4668c000c
commit
17d5278d59
@ -190,6 +190,13 @@ void cWebAdmin::Reload(void)
|
|||||||
" This will not take effect until you restart the server."
|
" This will not take effect until you restart the server."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
else if (!HasUsers())
|
||||||
|
{
|
||||||
|
LOGWARNING(
|
||||||
|
"The webadmin is enabled but has no users configured."
|
||||||
|
" To add new users, edit webadmin.ini"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Initialize the WebAdmin template script and reload the file:
|
// Initialize the WebAdmin template script and reload the file:
|
||||||
if (m_TemplateScript.IsValid())
|
if (m_TemplateScript.IsValid())
|
||||||
@ -248,6 +255,23 @@ bool cWebAdmin::LoadIniFile(void)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool cWebAdmin::HasUsers()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < m_IniFile.GetNumKeys(); i++)
|
||||||
|
{
|
||||||
|
AString key = m_IniFile.GetKeyName(i);
|
||||||
|
if (key.rfind("User:", 0) == 0)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cWebAdmin::HandleWebadminRequest(cHTTPServerConnection & a_Connection, cHTTPIncomingRequest & a_Request)
|
void cWebAdmin::HandleWebadminRequest(cHTTPServerConnection & a_Connection, cHTTPIncomingRequest & a_Request)
|
||||||
{
|
{
|
||||||
if (!a_Request.HasAuth())
|
if (!a_Request.HasAuth())
|
||||||
|
@ -260,6 +260,9 @@ protected:
|
|||||||
Returns true if webadmin is enabled, false if disabled. */
|
Returns true if webadmin is enabled, false if disabled. */
|
||||||
bool LoadIniFile(void);
|
bool LoadIniFile(void);
|
||||||
|
|
||||||
|
/** Checks inside the webadmin.ini file if there are users configured. */
|
||||||
|
bool HasUsers();
|
||||||
|
|
||||||
/** Handles requests coming to the "/webadmin" or "/~webadmin" URLs */
|
/** Handles requests coming to the "/webadmin" or "/~webadmin" URLs */
|
||||||
void HandleWebadminRequest(cHTTPServerConnection & a_Connection, cHTTPIncomingRequest & a_Request);
|
void HandleWebadminRequest(cHTTPServerConnection & a_Connection, cHTTPIncomingRequest & a_Request);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user