Do like many other console programs (such as /bin/passwd) and avoid
printing any stars to not give away any information to potential
bystanders.

Signed-off-by: Jan Engelhardt <[email protected]>
---
 src/ask-password-api.c |   21 +++++++--------------
 1 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/src/ask-password-api.c b/src/ask-password-api.c
index 66bf480..332d616 100644
--- a/src/ask-password-api.c
+++ b/src/ask-password-api.c
@@ -78,6 +78,7 @@ int ask_password_tty(
                 loop_write(ttyfd, "\x1B[1m", 4, false);
                 loop_write(ttyfd, message, strlen(message), false);
                 loop_write(ttyfd, "\x1B[0m", 4, false);
+                loop_write(ttyfd, " (Answer will not be shown)", 27, false);
                 loop_write(ttyfd, " (Ctrl-U to clear) ", 19, false);
 
                 new_termios = old_termios;
@@ -157,25 +158,17 @@ int ask_password_tty(
                         break;
                 else if (c == 21) {
 
-                        while (p > 0) {
+                        while (p > 0)
                                 p--;
-
-                                if (ttyfd >= 0)
-                                        loop_write(ttyfd, "\b \b", 3, false);
-                        }
-
                 } else if (c == '\b' || c == 127) {
-                        if (p > 0) {
+                        if (p > 0)
                                 p--;
-
-                                if (ttyfd >= 0)
-                                        loop_write(ttyfd, "\b \b", 3, false);
-                        }
                 } else {
+                       /*
+                        * Not printing anything on purpose - like
+                        * passwd(8) does.
+                        */
                         passphrase[p++] = c;
-
-                        if (ttyfd >= 0)
-                                loop_write(ttyfd, "*", 1, false);
                 }
         }
 
-- 
1.7.1

_______________________________________________
systemd-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/systemd-devel

Reply via email to