diff options
author | Kyle Evans <kevans@FreeBSD.org> | 2018-02-27 21:22:57 +0000 |
---|---|---|
committer | Kyle Evans <kevans@FreeBSD.org> | 2018-02-27 21:22:57 +0000 |
commit | a6f1506f1a4f9dd9bfa65f01e535afcf60ada183 (patch) | |
tree | 82c0f6733aa01d2c55c6dae46e88be1d0a921929 /stand/lua/password.lua | |
parent | 6b554d26ed112107c334b3add013f34347f9a36a (diff) | |
download | src-a6f1506f1a4f9dd9bfa65f01e535afcf60ada183.tar.gz src-a6f1506f1a4f9dd9bfa65f01e535afcf60ada183.zip |
lualoader: Add a twiddle at password prompt
This gives some form of feedback while typing, and matches-(ish*) Forth
behavior. The cursor generally rests two column after the password prompt,
then the twiddle is drawn three columns later and the cursor reset to
resting position after being drawn.
I've removed the note about re-evaluating it for security considerations and
instead set it up as a module-local variable that we can set later depending
on environment or something. It's set to false with no chance of changing at
the moment.
*As close as I can tell from reading check-password.4th, because I don't
have an easy test (or deployed) setup for forth loader to check how close
it is. Please do mention if it's not close enough.
Notes
Notes:
svn path=/head/; revision=330082
Diffstat (limited to 'stand/lua/password.lua')
-rw-r--r-- | stand/lua/password.lua | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/stand/lua/password.lua b/stand/lua/password.lua index 124ce5686349..633c32d2e6df 100644 --- a/stand/lua/password.lua +++ b/stand/lua/password.lua @@ -33,27 +33,46 @@ local core = require("core") local screen = require("screen") local password = {} +-- Asterisks as a password mask +local show_password_mask = false +local twiddle_chars = {"/", "-", "\\", "|"} +local twiddle_pos = 1 -- Module exports function password.read() local str = "" local n = 0 + twiddle_pos = 1 + local function draw_twiddle() + loader.printc(" " .. twiddle_chars[twiddle_pos]) + screen.movecursor(-3, -1) + twiddle_pos = (twiddle_pos % #twiddle_chars) + 1 + end + + -- Space between the prompt and any on-screen feedback + loader.printc(" ") while true do local ch = io.getchar() if ch == core.KEY_ENTER then break end - -- XXX TODO: Evaluate if we really want this or not, as a - -- security consideration of sorts if ch == core.KEY_BACKSPACE or ch == core.KEY_DELETE then if n > 0 then n = n - 1 - -- loader.printc("\008 \008") + if show_password_mask then + loader.printc("\008 \008") + else + draw_twiddle() + end str = str:sub(1, n) end else - -- loader.printc("*") + if show_password_mask then + loader.printc("*") + else + draw_twiddle() + end str = str .. string.char(ch) n = n + 1 end |