Made the rmanager prompt configurable for each authentication level.
git-svn-id: http://yate.null.ro/svn/yate/trunk@6456 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
parent
f9309ac9ed
commit
79503829f9
|
@ -20,6 +20,14 @@
|
||||||
; Example: prompt="${configname}@${nodename}> "
|
; Example: prompt="${configname}@${nodename}> "
|
||||||
;prompt=
|
;prompt=
|
||||||
|
|
||||||
|
; prompt_user: string: Prompt to display when authenticated as observer user
|
||||||
|
; If not set it will take the same value as prompt above
|
||||||
|
;prompt_user=
|
||||||
|
|
||||||
|
; prompt_guest: string: Prompt to display when not yet authenticated
|
||||||
|
; If not set it will take the same value as prompt_user or prompt above
|
||||||
|
;prompt_guest=
|
||||||
|
|
||||||
; password: string: Password required to authenticate as admin, default empty!
|
; password: string: Password required to authenticate as admin, default empty!
|
||||||
;password=
|
;password=
|
||||||
|
|
||||||
|
|
|
@ -236,6 +236,7 @@ public:
|
||||||
void checkTimer(u_int64_t time);
|
void checkTimer(u_int64_t time);
|
||||||
private:
|
private:
|
||||||
void disconnect();
|
void disconnect();
|
||||||
|
void setPrompt(const char* prompt);
|
||||||
NamedList m_aliases;
|
NamedList m_aliases;
|
||||||
Level m_auth;
|
Level m_auth;
|
||||||
ObjList* m_userPrefix;
|
ObjList* m_userPrefix;
|
||||||
|
@ -440,10 +441,7 @@ Connection::Connection(Socket* sock, const char* addr, RManagerListener* listene
|
||||||
m_timeout(0), m_address(addr), m_listener(listener),
|
m_timeout(0), m_address(addr), m_listener(listener),
|
||||||
m_cursorPos(0), m_histLen(DEF_HISTORY), m_width(0), m_height(24)
|
m_cursorPos(0), m_histLen(DEF_HISTORY), m_width(0), m_height(24)
|
||||||
{
|
{
|
||||||
m_prompt = cfg().getValue("prompt");
|
setPrompt(cfg().getValue("prompt"));
|
||||||
if ((m_prompt.length() > 1) && (m_prompt.startsWith("\"")) && (m_prompt.endsWith("\"")))
|
|
||||||
m_prompt = m_prompt.substr(1,m_prompt.length() - 2);
|
|
||||||
Engine::runParams().replaceParams(m_prompt);
|
|
||||||
s_mutex.lock();
|
s_mutex.lock();
|
||||||
s_connList.append(this);
|
s_connList.append(this);
|
||||||
s_mutex.unlock();
|
s_mutex.unlock();
|
||||||
|
@ -471,6 +469,14 @@ void Connection::disconnect()
|
||||||
m_socket->terminate();
|
m_socket->terminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Connection::setPrompt(const char* prompt)
|
||||||
|
{
|
||||||
|
m_prompt = prompt;
|
||||||
|
if ((m_prompt.length() > 1) && (m_prompt.startsWith("\"")) && (m_prompt.endsWith("\"")))
|
||||||
|
m_prompt = m_prompt.substr(1,m_prompt.length() - 2);
|
||||||
|
Engine::runParams().replaceParams(m_prompt);
|
||||||
|
}
|
||||||
|
|
||||||
void Connection::run()
|
void Connection::run()
|
||||||
{
|
{
|
||||||
if (!m_socket)
|
if (!m_socket)
|
||||||
|
@ -489,6 +495,7 @@ void Connection::run()
|
||||||
tout = 5000;
|
tout = 5000;
|
||||||
m_timeout = Time::now() + 1000 * tout;
|
m_timeout = Time::now() + 1000 * tout;
|
||||||
}
|
}
|
||||||
|
setPrompt(cfg().getValue("prompt_guest",cfg().getValue("prompt_user",cfg().getValue("prompt"))));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_auth = cfg().getValue("password") ? User : Admin;
|
m_auth = cfg().getValue("password") ? User : Admin;
|
||||||
|
@ -497,6 +504,8 @@ void Connection::run()
|
||||||
if (m_debug)
|
if (m_debug)
|
||||||
Debugger::enableOutput(true);
|
Debugger::enableOutput(true);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
setPrompt(cfg().getValue("prompt_user",cfg().getValue("prompt")));
|
||||||
m_output = cfg().getBoolValue("output",m_debug);
|
m_output = cfg().getBoolValue("output",m_debug);
|
||||||
}
|
}
|
||||||
m_userPrefix = cfg()["user_prefix"].split(',',false);
|
m_userPrefix = cfg()["user_prefix"].split(',',false);
|
||||||
|
@ -1385,6 +1394,7 @@ bool Connection::processCommand(const char *line, bool saveLine)
|
||||||
Output("Authenticated admin connection %s",m_address.c_str());
|
Output("Authenticated admin connection %s",m_address.c_str());
|
||||||
m_auth = Admin;
|
m_auth = Admin;
|
||||||
m_timeout = 0;
|
m_timeout = 0;
|
||||||
|
setPrompt(cfg().getValue("prompt"));
|
||||||
writeStr(m_machine ? "%%=auth:success\r\n" : "Authenticated successfully as admin!\r\n");
|
writeStr(m_machine ? "%%=auth:success\r\n" : "Authenticated successfully as admin!\r\n");
|
||||||
}
|
}
|
||||||
else if ((pass = cfg().getValue("userpass")) && (str == pass)) {
|
else if ((pass = cfg().getValue("userpass")) && (str == pass)) {
|
||||||
|
@ -1392,6 +1402,7 @@ bool Connection::processCommand(const char *line, bool saveLine)
|
||||||
Output("Authenticated user connection %s",m_address.c_str());
|
Output("Authenticated user connection %s",m_address.c_str());
|
||||||
m_auth = User;
|
m_auth = User;
|
||||||
m_timeout = 0;
|
m_timeout = 0;
|
||||||
|
setPrompt(cfg().getValue("prompt_user",cfg().getValue("prompt")));
|
||||||
writeStr(m_machine ? "%%=auth:success\r\n" : "Authenticated successfully as user!\r\n");
|
writeStr(m_machine ? "%%=auth:success\r\n" : "Authenticated successfully as user!\r\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue