Commit 441dfe09 authored by Lennart Poettering's avatar Lennart Poettering

ask-password: also accept Backspace as first keypress as silent mode switch

parent e6402d10
...@@ -61,6 +61,7 @@ int ask_password_tty( ...@@ -61,6 +61,7 @@ int ask_password_tty(
struct pollfd pollfd[2]; struct pollfd pollfd[2];
bool reset_tty = false; bool reset_tty = false;
bool silent_mode = false; bool silent_mode = false;
bool dirty = false;
enum { enum {
POLL_TTY, POLL_TTY,
POLL_INOTIFY POLL_INOTIFY
...@@ -182,6 +183,17 @@ int ask_password_tty( ...@@ -182,6 +183,17 @@ int ask_password_tty(
backspace_chars(ttyfd, 1); backspace_chars(ttyfd, 1);
p--; p--;
} else if (!dirty && !silent_mode) {
silent_mode = true;
/* There are two ways to enter silent
* mode. Either by pressing backspace
* as first key (and only as first key),
* or ... */
if (ttyfd >= 0)
loop_write(ttyfd, "(no echo) ", 10, false);
} else if (ttyfd >= 0) } else if (ttyfd >= 0)
loop_write(ttyfd, "\a", 1, false); loop_write(ttyfd, "\a", 1, false);
...@@ -190,6 +202,8 @@ int ask_password_tty( ...@@ -190,6 +202,8 @@ int ask_password_tty(
backspace_chars(ttyfd, p); backspace_chars(ttyfd, p);
silent_mode = true; silent_mode = true;
/* ... or by pressing TAB at any time. */
if (ttyfd >= 0) if (ttyfd >= 0)
loop_write(ttyfd, "(no echo) ", 10, false); loop_write(ttyfd, "(no echo) ", 10, false);
} else { } else {
...@@ -197,6 +211,8 @@ int ask_password_tty( ...@@ -197,6 +211,8 @@ int ask_password_tty(
if (!silent_mode && ttyfd >= 0) if (!silent_mode && ttyfd >= 0)
loop_write(ttyfd, "*", 1, false); loop_write(ttyfd, "*", 1, false);
dirty = true;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment