You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2023/03/03 17:44:47 UTC
[nuttx-apps] branch master updated (68fee5eff -> 9bb730fb6)
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git
from 68fee5eff apps/examples/ina226/Makefile: Fix mistake in comment
new 2e49d7840 nsh/login: FIx error prompt length
new 9bb730fb6 nsh: Don't echo password during login
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
nshlib/nsh_login.c | 38 +++++++++++++++++++++++++++++++++++---
1 file changed, 35 insertions(+), 3 deletions(-)
[nuttx-apps] 01/02: nsh/login: FIx error prompt length
Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git
commit 2e49d78400840770e896bf781b22913bd85257f1
Author: Huang Qi <hu...@xiaomi.com>
AuthorDate: Fri Mar 3 14:17:50 2023 +0800
nsh/login: FIx error prompt length
Signed-off-by: Huang Qi <hu...@xiaomi.com>
---
nshlib/nsh_login.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/nshlib/nsh_login.c b/nshlib/nsh_login.c
index 82857c406..7edb9676b 100644
--- a/nshlib/nsh_login.c
+++ b/nshlib/nsh_login.c
@@ -238,7 +238,7 @@ int nsh_login(FAR struct console_stdio_s *pstate)
/* Too many failed login attempts */
- write(OUTFD(pstate), g_loginfailure, strlen(g_loginsuccess));
+ write(OUTFD(pstate), g_loginfailure, strlen(g_loginfailure));
return -1;
}
[nuttx-apps] 02/02: nsh: Don't echo password during login
Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git
commit 9bb730fb6b75145d9748cfe3995a7904a4be2ae8
Author: Huang Qi <hu...@xiaomi.com>
AuthorDate: Fri Mar 3 14:19:24 2023 +0800
nsh: Don't echo password during login
Signed-off-by: Huang Qi <hu...@xiaomi.com>
---
nshlib/nsh_login.c | 36 ++++++++++++++++++++++++++++++++++--
1 file changed, 34 insertions(+), 2 deletions(-)
diff --git a/nshlib/nsh_login.c b/nshlib/nsh_login.c
index 7edb9676b..c1feb0d54 100644
--- a/nshlib/nsh_login.c
+++ b/nshlib/nsh_login.c
@@ -27,6 +27,7 @@
#include <string.h>
#include <ctype.h>
#include <unistd.h>
+#include <termios.h>
#include "fsutils/passwd.h"
#ifdef CONFIG_NSH_CLE
@@ -150,6 +151,9 @@ int nsh_login(FAR struct console_stdio_s *pstate)
#endif
int ret;
int i;
+#ifdef CONFIG_SERIAL_TERMIOS
+ struct termios cfg;
+#endif
#ifdef CONFIG_NSH_PLATFORM_SKIP_LOGIN
if (platform_skip_login() == OK)
@@ -193,9 +197,37 @@ int nsh_login(FAR struct console_stdio_s *pstate)
write(OUTFD(pstate), g_passwordprompt, strlen(g_passwordprompt));
+ /* Disable ECHO if its a tty device */
+
+#ifdef CONFIG_SERIAL_TERMIOS
+ if (isatty(INFD(pstate)))
+ {
+ if (tcgetattr(INFD(pstate), &cfg) == 0)
+ {
+ cfg.c_iflag &= ~ECHO;
+ tcsetattr(INFD(pstate), TCSANOW, &cfg);
+ }
+ }
+#endif
+
password[0] = '\0';
- if (readline_fd(pstate->cn_line, CONFIG_NSH_LINELEN,
- INFD(pstate), -1) > 0)
+ ret = readline_fd(pstate->cn_line, CONFIG_NSH_LINELEN,
+ INFD(pstate), -1);
+
+ /* Enable echo again after password */
+
+#ifdef CONFIG_SERIAL_TERMIOS
+ if (isatty(INFD(pstate)))
+ {
+ if (tcgetattr(INFD(pstate), &cfg) == 0)
+ {
+ cfg.c_iflag |= ECHO;
+ tcsetattr(INFD(pstate), TCSANOW, &cfg);
+ }
+ }
+#endif
+
+ if (ret > 0)
{
/* Parse out the password */