nshlib: Add login skip, invalid name ignore and password challenge to telnet login
forget in the follow patches: commit6aef469c19
Author: huangjian <huangjian@xiaomi.com> Date: Fri Nov 4 20:37:04 2022 +0800 nshlib:judge whether nsh login username is a valid input Signed-off-by: huangjian <huangjian@xiaomi.com> commit88fff23d34
Author: huangjian <huangjian@xiaomi.com> Date: Fri Nov 4 20:39:26 2022 +0800 nshlib:add platform skip login function Signed-off-by: huangjian <huangjian@xiaomi.com> commit5a623cc9e3
Author: huangjian <huangjian@xiaomi.com> Date: Fri Nov 4 20:35:07 2022 +0800 nshlib:add platform challenge function for nsh login Signed-off-by: huangjian <huangjian@xiaomi.com> Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
595adbcca6
commit
9884159346
@ -32,6 +32,7 @@
|
|||||||
|
|
||||||
#include "nsh.h"
|
#include "nsh.h"
|
||||||
#include "nsh_console.h"
|
#include "nsh_console.h"
|
||||||
|
#include "nshlib/nshlib.h"
|
||||||
|
|
||||||
#ifdef CONFIG_NSH_TELNET_LOGIN
|
#ifdef CONFIG_NSH_TELNET_LOGIN
|
||||||
|
|
||||||
@ -161,9 +162,19 @@ static void nsh_telnettoken(FAR struct console_stdio_s *pstate,
|
|||||||
int nsh_telnetlogin(FAR struct console_stdio_s *pstate)
|
int nsh_telnetlogin(FAR struct console_stdio_s *pstate)
|
||||||
{
|
{
|
||||||
char username[16];
|
char username[16];
|
||||||
char password[16];
|
char password[128];
|
||||||
|
#ifdef CONFIG_NSH_PLATFORM_CHALLENGE
|
||||||
|
char challenge[128];
|
||||||
|
#endif
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
#ifdef CONFIG_NSH_PLATFORM_SKIP_LOGIN
|
||||||
|
if (platform_skip_login() == OK)
|
||||||
|
{
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Present the NSH Telnet greeting */
|
/* Present the NSH Telnet greeting */
|
||||||
|
|
||||||
fputs(g_telnetgreeting, pstate->cn_outstream);
|
fputs(g_telnetgreeting, pstate->cn_outstream);
|
||||||
@ -187,6 +198,17 @@ int nsh_telnetlogin(FAR struct console_stdio_s *pstate)
|
|||||||
nsh_telnettoken(pstate, username, sizeof(username));
|
nsh_telnettoken(pstate, username, sizeof(username));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (username[0] == '\0')
|
||||||
|
{
|
||||||
|
i--;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_NSH_PLATFORM_CHALLENGE
|
||||||
|
platform_challenge(challenge, sizeof(challenge));
|
||||||
|
fputs(challenge, pstate->cn_outstream);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Ask for the login password */
|
/* Ask for the login password */
|
||||||
|
|
||||||
fputs(g_passwordprompt, pstate->cn_outstream);
|
fputs(g_passwordprompt, pstate->cn_outstream);
|
||||||
@ -206,8 +228,14 @@ int nsh_telnetlogin(FAR struct console_stdio_s *pstate)
|
|||||||
#if defined(CONFIG_NSH_LOGIN_PASSWD)
|
#if defined(CONFIG_NSH_LOGIN_PASSWD)
|
||||||
if (PASSWORD_VERIFY_MATCH(passwd_verify(username, password)))
|
if (PASSWORD_VERIFY_MATCH(passwd_verify(username, password)))
|
||||||
#elif defined(CONFIG_NSH_LOGIN_PLATFORM)
|
#elif defined(CONFIG_NSH_LOGIN_PLATFORM)
|
||||||
|
# ifdef CONFIG_NSH_PLATFORM_CHALLENGE
|
||||||
|
if (PASSWORD_VERIFY_MATCH(platform_user_verify(username,
|
||||||
|
challenge,
|
||||||
|
password)))
|
||||||
|
# else
|
||||||
if (PASSWORD_VERIFY_MATCH(platform_user_verify(username,
|
if (PASSWORD_VERIFY_MATCH(platform_user_verify(username,
|
||||||
password)))
|
password)))
|
||||||
|
# endif
|
||||||
#elif defined(CONFIG_NSH_LOGIN_FIXED)
|
#elif defined(CONFIG_NSH_LOGIN_FIXED)
|
||||||
if (strcmp(password, CONFIG_NSH_LOGIN_PASSWORD) == 0 &&
|
if (strcmp(password, CONFIG_NSH_LOGIN_PASSWORD) == 0 &&
|
||||||
strcmp(username, CONFIG_NSH_LOGIN_USERNAME) == 0)
|
strcmp(username, CONFIG_NSH_LOGIN_USERNAME) == 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user