From owner-svn-src-all@FreeBSD.ORG Mon Mar 23 16:43:47 2015 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id D9DAEF9C; Mon, 23 Mar 2015 16:43:47 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BCD458F5; Mon, 23 Mar 2015 16:43:47 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t2NGhlcU074912; Mon, 23 Mar 2015 16:43:47 GMT (envelope-from dteske@FreeBSD.org) Received: (from dteske@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t2NGhlNh074911; Mon, 23 Mar 2015 16:43:47 GMT (envelope-from dteske@FreeBSD.org) Message-Id: <201503231643.t2NGhlNh074911@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: dteske set sender to dteske@FreeBSD.org using -f From: Devin Teske Date: Mon, 23 Mar 2015 16:43:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r280384 - head/sys/boot/forth X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Mar 2015 16:43:48 -0000 Author: dteske Date: Mon Mar 23 16:43:46 2015 New Revision: 280384 URL: https://svnweb.freebsd.org/changeset/base/280384 Log: Increase max input for password/bootlock_password from 16 to 255. When taking user input, don't show asterisks as the user types but instead spin a twiddle. Implement Ctrl-U to clear user input. If the buffer is empty, either because the user has yet to type anything, presses Ctrl-U at any time, or presses backspace enough to end in an empty buffer, the twiddle is erased to provide feed- back to the user. MFC after: 3 days X-MFC-to: stable/10 stable/9 Modified: head/sys/boot/forth/check-password.4th Modified: head/sys/boot/forth/check-password.4th ============================================================================== --- head/sys/boot/forth/check-password.4th Mon Mar 23 16:31:27 2015 (r280383) +++ head/sys/boot/forth/check-password.4th Mon Mar 23 16:43:46 2015 (r280384) @@ -28,11 +28,12 @@ marker task-check-password.4th include /boot/screen.4th -13 constant enter_key \ The decimal ASCII value for Enter key -8 constant bs_key \ The decimal ASCII value for Backspace key -16 constant readmax \ Maximum number of characters for the password +13 constant enter_key \ The decimal ASCII value for Enter key +8 constant bs_key \ The decimal ASCII value for Backspace key +21 constant ctrl_u \ The decimal ASCII value for Ctrl-U sequence +255 constant readmax \ Maximum number of characters for the password -variable readX \ Current X offset (column)(used by read) +variable read-tick \ Twiddle position (used by read) variable read-start \ Starting X offset (column)(used by read) create readval readmax allot \ input obtained (up to readmax characters) @@ -55,16 +56,23 @@ variable readlen \ input len \ Check key pressed (see loader(8)) and input limit dup 0<> if ( and ) readlen @ readmax < if - \ Echo an asterisk (unless Backspace/Enter) - dup bs_key <> if ( and ) dup enter_key <> if - ." *" \ Echo an asterisk - then then + \ Spin the twiddle and then exit this function + read-tick @ dup 1+ 4 mod read-tick ! + 2 spaces + dup 0 = if ( 1 ) ." /" else + dup 1 = if ( 2 ) ." -" else + dup 2 = if ( 3 ) ." \" else + dup 3 = if ( 4 ) ." |" else + 1 spaces + then then then then drop + read-start @ 25 at-xy exit then then - \ Always allow Backspace and Enter + \ Always allow Backspace, Enter, and Ctrl-U dup bs_key = if exit then dup enter_key = if exit then + dup ctrl_u = if exit then then 50 ms \ Sleep for 50 milliseconds (see loader(8)) again @@ -74,7 +82,6 @@ variable readlen \ input len 0 25 at-xy \ Move the cursor to the bottom-left dup 1+ read-start ! \ Store X offset after the prompt - read-start @ readX ! \ copy value to the current X offset 0 readlen ! \ Initialize the read length type \ Print the prompt @@ -86,42 +93,23 @@ variable readlen \ input len \ security reasons). If Enter is pressed, we process the \ password, otherwise augment the key to a string. - \ If the key that was entered was not Enter, advance - dup enter_key <> if - readX @ 1+ readX ! \ Advance the column - readlen @ 1+ readlen ! \ Increment input length - then - - \ Handle backspacing - dup bs_key = if - readX @ 2 - readX ! \ Set new cursor position - readlen @ 2 - readlen ! \ Decrement input length - - \ Don't move behind starting position - readX @ read-start @ < if - read-start @ readX ! - then - readlen @ 0< if - 0 readlen ! - then - - \ Reposition cursor and erase character - readX @ 25 at-xy 1 spaces readX @ 25 at-xy - then - dup enter_key = if - drop \ Clean up stack cruft - 10 emit \ Echo new line + drop \ Clean up stack cruft + 3 spaces \ Erase the twiddle + 10 emit \ Echo new line exit - then - - \ If not Backspace or Enter, store the character - dup bs_key <> if ( and ) dup enter_key <> if - - \ store the character in our buffer - dup readval readlen @ 1- + c! - - then then + else dup ctrl_u = if + 3 spaces read-start @ 25 at-xy \ Erase the twiddle + 0 readlen ! \ Reset input to NULL + else dup bs_key = if + readlen @ 1 - dup readlen ! \ Decrement input length + dup 0< if drop 0 dup readlen ! then \ Don't go negative + 0= if 3 spaces read-start @ 25 at-xy then \ Twiddle + else dup \ Store the character + \ NB: sgetkey prevents overflow by way of blocking + \ at readmax except for Backspace or Enter + readlen @ 1+ dup readlen ! 1- readval + c! + then then then drop \ last key pressed again \ Enter was not pressed; repeat