[Toybox] [PATCH] Add fflush to lib/password; remove print from stty

Chris Sarra chrissarra at google.com
Tue Sep 15 09:39:28 PDT 2020


toybox logins were displaying the "password:" prompt after
the user entered a password. This patch fixes the issue so the
password prompt shows *before* password is entered.
---
 lib/password.c      | 1 +
 toys/pending/stty.c | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/password.c b/lib/password.c
index 432905cc..2f5997ff 100644
--- a/lib/password.c
+++ b/lib/password.c
@@ -63,6 +63,7 @@ int read_password(char *buf, int buflen, char *mesg)
   xset_terminal(0, 1, 0, &oldtermio);
 
   xprintf("%s", mesg);
+  fflush(NULL);
 
   for (i=0; i < buflen-1; i++) {
     if ((ret = read(0, buf+i, 1)) < 0 || (!ret && !i)) {
diff --git a/toys/pending/stty.c b/toys/pending/stty.c
index 8c937696..fe8f5c8d 100644
--- a/toys/pending/stty.c
+++ b/toys/pending/stty.c
@@ -271,7 +271,7 @@ static int set_special_character(struct termios *new, int *i, char *char_name)
       else if (arg[0] == '^' && arg[2] == 0) ch = (toupper(arg[1])-'@');
       else if (!arg[1]) ch = arg[0];
       else error_exit("invalid arg: %s", arg);
-      xprintf("setting %s to %s (%02x)\n", char_name, arg, ch);
+      //xprintf("setting %s to %s (%02x)\n", char_name, arg, ch);
       new->c_cc[chars[j].value] = ch;
       return 1;
     }
-- 
2.28.0.618.gf4bc123cb7-goog




More information about the Toybox mailing list