From owner-svn-src-head@freebsd.org Tue Feb 27 21:22:58 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6C7CBF2A51D; Tue, 27 Feb 2018 21:22:58 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 227EC70EEC; Tue, 27 Feb 2018 21:22:58 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1C1B510354; Tue, 27 Feb 2018 21:22:58 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w1RLMvOM018414; Tue, 27 Feb 2018 21:22:57 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w1RLMvpV018412; Tue, 27 Feb 2018 21:22:57 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201802272122.w1RLMvpV018412@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Tue, 27 Feb 2018 21:22:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r330082 - head/stand/lua X-SVN-Group: head X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: head/stand/lua X-SVN-Commit-Revision: 330082 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Feb 2018 21:22:58 -0000 Author: kevans Date: Tue Feb 27 21:22:57 2018 New Revision: 330082 URL: https://svnweb.freebsd.org/changeset/base/330082 Log: 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. Modified: head/stand/lua/password.lua head/stand/lua/screen.lua Modified: head/stand/lua/password.lua ============================================================================== --- head/stand/lua/password.lua Tue Feb 27 19:24:06 2018 (r330081) +++ head/stand/lua/password.lua Tue Feb 27 21:22:57 2018 (r330082) @@ -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 Modified: head/stand/lua/screen.lua ============================================================================== --- head/stand/lua/screen.lua Tue Feb 27 19:24:06 2018 (r330081) +++ head/stand/lua/screen.lua Tue Feb 27 21:22:57 2018 (r330082) @@ -49,6 +49,24 @@ function screen.setcursor(x, y) loader.printc("\027[" .. y .. ";" .. x .. "H") end +function screen.movecursor(dx, dy) + if core.isSerialBoot() then + return + end + + if dx < 0 then + loader.printc("\027[" .. -dx .. "D") + elseif dx > 0 then + loader.printc("\027[" .. dx .. "C") + end + + if dy < 0 then + loader.printc("\027[" .. -dy .. "A") + elseif dy > 0 then + loader.printc("\027[" .. dy .. "B") + end +end + function screen.setforeground(color_value) if color.disabled then return color_value