[systemd-devel] crypto: to show stars or not to show them

Jan Engelhardt jengelh at medozas.de
Thu Mar 17 16:23:36 PDT 2011


On Friday 2011-03-18 00:18, Jan Engelhardt wrote:
>
>	\e[37;47m*
>	\e[7m\x20

---
 src/ask-password-api.c |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/src/ask-password-api.c b/src/ask-password-api.c
index 9c3dad9..fac2a2e 100644
--- a/src/ask-password-api.c
+++ b/src/ask-password-api.c
@@ -172,10 +172,20 @@ int ask_password_tty(
                                         loop_write(ttyfd, "\b \b", 3, false);
                         }
                 } else {
+#ifdef pick_one
+                        /* No \b trickery needed */
+                        static const char s[] = "\e[7m \e[0m";
+#else
+                        /*
+                         * Extra " \b" required so that the background color
+                         * does not spill into a new line when wrapping.
+                         */
+                        static const char s[] = " \b\e[37;47m*\e[0m";
+#endif
                         passphrase[p++] = c;
 
                         if (ttyfd >= 0)
-                                loop_write(ttyfd, "*", 1, false);
+                                loop_write(ttyfd, s, sizeof(s)-1, false);
                 }
         }
 
-- 
# Created with git-export-patch


More information about the systemd-devel mailing list