nshlib: apply privilege prompt markers only after real login

nsh_consolemain always passes NSH_LOGIN_LOCAL, so treating any
non-NONE session as a login rewrote nsh> to nsh# whenever
SCHED_USER_IDENTITY was enabled.  NTFC boot detection then timed
out on sim/citest and qemu-rv/citest.

Keep CONFIG_NSH_PROMPT_STRING until a successful console or telnet
login (or su).

Signed-off-by: Abhishek Mishra <mishra.abhishek2808@gmail.com>
This commit is contained in:
Abhishek Mishra 2026-08-14 16:46:16 +00:00 committed by Xiang Xiao
parent 0faa02f29f
commit 2ca518bad7
2 changed files with 16 additions and 7 deletions

View file

@ -218,8 +218,11 @@ void nsh_update_prompt(void)
* Name: nsh_update_prompt_after_login
*
* Description:
* Enable privilege markers in the prompt and refresh it. Boot and
* no-login sessions keep NSH_PROMPT_STRING (for example, "nsh> ").
* Enable privilege markers in the prompt and refresh it. Call this
* after a successful console/telnet login or su. nsh_consolemain
* always passes NSH_LOGIN_LOCAL, so this must not run merely because
* the session type is local. Boot and no-login sessions keep
* NSH_PROMPT_STRING (for example, "nsh> ").
*
****************************************************************************/

View file

@ -87,6 +87,15 @@ int nsh_session(FAR struct console_stdio_s *pstate,
nsh_exit(vtbl, 1);
return -1; /* nsh_exit does not return */
}
#ifdef CONFIG_SCHED_USER_IDENTITY
/* nsh_consolemain always passes NSH_LOGIN_LOCAL, even when console
* login is disabled. Apply #/$ markers only after a real login
* so CI/NTFC still sees CONFIG_NSH_PROMPT_STRING at boot.
*/
nsh_update_prompt_after_login();
#endif
}
else
#endif /* CONFIG_NSH_CONSOLE_LOGIN */
@ -100,15 +109,12 @@ int nsh_session(FAR struct console_stdio_s *pstate,
nsh_exit(vtbl, 1);
return -1; /* nsh_exit does not return */
}
}
#endif /* CONFIG_NSH_TELNET_LOGIN */
#ifdef CONFIG_SCHED_USER_IDENTITY
if (login != NSH_LOGIN_NONE)
{
nsh_update_prompt_after_login();
}
#endif
}
#endif /* CONFIG_NSH_TELNET_LOGIN */
if (login != NSH_LOGIN_NONE)
{