mirror of
https://github.com/apache/nuttx-apps.git
synced 2025-10-18 08:52:01 +08:00
nshlib: Add login argument to nsh_session for controling the login process
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
@@ -79,7 +79,7 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int nsh_session(FAR struct console_stdio_s *pstate)
|
||||
int nsh_session(FAR struct console_stdio_s *pstate, bool login)
|
||||
{
|
||||
FAR struct nsh_vtbl_s *vtbl;
|
||||
int ret;
|
||||
@@ -87,41 +87,44 @@ int nsh_session(FAR struct console_stdio_s *pstate)
|
||||
DEBUGASSERT(pstate);
|
||||
vtbl = &pstate->cn_vtbl;
|
||||
|
||||
#ifdef CONFIG_NSH_CONSOLE_LOGIN
|
||||
/* Login User and Password Check */
|
||||
|
||||
if (nsh_login(pstate) != OK)
|
||||
if (login)
|
||||
{
|
||||
nsh_exit(vtbl, 1);
|
||||
return -1; /* nsh_exit does not return */
|
||||
}
|
||||
#ifdef CONFIG_NSH_CONSOLE_LOGIN
|
||||
/* Login User and Password Check */
|
||||
|
||||
if (nsh_login(pstate) != OK)
|
||||
{
|
||||
nsh_exit(vtbl, 1);
|
||||
return -1; /* nsh_exit does not return */
|
||||
}
|
||||
#endif /* CONFIG_NSH_CONSOLE_LOGIN */
|
||||
|
||||
/* Present a greeting and possibly a Message of the Day (MOTD) */
|
||||
/* Present a greeting and possibly a Message of the Day (MOTD) */
|
||||
|
||||
fputs(g_nshgreeting, pstate->cn_outstream);
|
||||
fputs(g_nshgreeting, pstate->cn_outstream);
|
||||
|
||||
#ifdef CONFIG_NSH_MOTD
|
||||
#ifdef CONFIG_NSH_PLATFORM_MOTD
|
||||
/* Output the platform message of the day */
|
||||
/* Output the platform message of the day */
|
||||
|
||||
platform_motd(vtbl->iobuffer, IOBUFFERSIZE);
|
||||
fprintf(pstate->cn_outstream, "%s\n", vtbl->iobuffer);
|
||||
platform_motd(vtbl->iobuffer, IOBUFFERSIZE);
|
||||
fprintf(pstate->cn_outstream, "%s\n", vtbl->iobuffer);
|
||||
|
||||
#else
|
||||
/* Output the fixed message of the day */
|
||||
/* Output the fixed message of the day */
|
||||
|
||||
fprintf(pstate->cn_outstream, "%s\n", g_nshmotd);
|
||||
fprintf(pstate->cn_outstream, "%s\n", g_nshmotd);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
fflush(pstate->cn_outstream);
|
||||
fflush(pstate->cn_outstream);
|
||||
|
||||
/* Execute the login script */
|
||||
/* Execute the login script */
|
||||
|
||||
#ifdef CONFIG_NSH_ROMFSRC
|
||||
nsh_loginscript(vtbl);
|
||||
nsh_loginscript(vtbl);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Then enter the command line parsing loop */
|
||||
|
||||
|
Reference in New Issue
Block a user