This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git


The following commit(s) were added to refs/heads/master by this push:
     new 2ca518bad nshlib: apply privilege prompt markers only after real login
2ca518bad is described below

commit 2ca518bad7b5ce732005a1074acd70783ab577a9
Author: Abhishek Mishra <[email protected]>
AuthorDate: Fri Aug 14 16:46:16 2026 +0000

    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 <[email protected]>
---
 nshlib/nsh_prompt.c  |  7 +++++--
 nshlib/nsh_session.c | 16 +++++++++++-----
 2 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/nshlib/nsh_prompt.c b/nshlib/nsh_prompt.c
index 48566eea0..b8a671c54 100644
--- a/nshlib/nsh_prompt.c
+++ b/nshlib/nsh_prompt.c
@@ -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> ").
  *
  ****************************************************************************/
 
diff --git a/nshlib/nsh_session.c b/nshlib/nsh_session.c
index cf71a7419..8d9d7a9f4 100644
--- a/nshlib/nsh_session.c
+++ b/nshlib/nsh_session.c
@@ -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)
     {

Reply via email to