1\ Copyright (c) 2006-2012 Devin Teske <dteske@FreeBSD.org> |
2\ All rights reserved. 3\ 4\ Redistribution and use in source and binary forms, with or without 5\ modification, are permitted provided that the following conditions 6\ are met: 7\ 1. Redistributions of source code must retain the above copyright 8\ notice, this list of conditions and the following disclaimer. 9\ 2. Redistributions in binary form must reproduce the above copyright --- 7 unchanged lines hidden (view full) --- 17\ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18\ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19\ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20\ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21\ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22\ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23\ SUCH DAMAGE. 24\ |
25\ $FreeBSD: head/sys/boot/forth/check-password.4th 244158 2012-12-12 17:49:01Z dteske $ |
26 27marker task-check-password.4th 28 29include /boot/screen.4th 30 3113 constant enter_key \ The decimal ASCII value for Enter key 328 constant bs_key \ The decimal ASCII value for Backspace key 3316 constant readmax \ Maximum number of characters for the password --- 35 unchanged lines hidden (view full) --- 69 dup bs_key = if exit then 70 dup enter_key = if exit then 71 72 then 73 50 ms \ Sleep for 50 milliseconds (see loader(8)) 74 again 75; 76 |
77: read ( String prompt -- ) |
78 79 0 25 at-xy \ Move the cursor to the bottom-left 80 dup 1+ read-start ! \ Store X offset after the prompt 81 read-start @ readX ! \ copy value to the current X offset 82 0 readlen ! \ Initialize the read length 83 type \ Print the prompt 84 85 begin \ Loop forever --- 43 unchanged lines hidden (view full) --- 129 130 drop \ drop the last key that was entered 131 132 again \ Enter was not pressed; repeat 133; 134 135: check-password ( -- ) 136 |
137 \ Do not allow the user to proceed beyond this point if a boot-lock 138 \ password has been set (preventing even boot from proceeding) 139 s" bootlock_password" getenv dup -1 <> if 140 begin 141 s" Boot Password: " read ( prompt -- ) 142 2dup readval readlen @ compare 0<> 143 while 144 3000 ms ." loader: incorrect password" 10 emit 145 repeat 146 2drop ( c-addr/u ) 147 else 148 drop ( -1 ) \ getenv cruft |
149 then 150 |
151 \ Exit if a password was not set 152 s" password" getenv -1 = if exit else drop then |
153 |
154 \ We should prevent the user from visiting the menu or dropping to the 155 \ interactive loader(8) prompt, but still allow the machine to boot... |
156 |
157 0 autoboot 158 159 \ Only reached if autoboot fails for any reason (including if/when 160 \ the user aborts/escapes the countdown sequence leading to boot). 161 162 s" password" getenv 163 begin 164 s" Password: " read ( prompt -- ) |
165 2dup readval readlen @ compare 0= if 166 2drop exit \ Correct password 167 then |
168 3000 ms ." loader: incorrect password" 10 emit 169 again |
170; |