Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 03 Sep 2019 14:06:12 -0000
From:      Kyle Evans <kevans@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r345882 - in stable: 11/stand/lua 12/stand/lua
Message-ID:  <201904041729.x34HTi11034698@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kevans
Date: Thu Apr  4 17:29:43 2019
New Revision: 345882
URL: https://svnweb.freebsd.org/changeset/base/345882

Log:
  MFC r344243, r345517-r345518: lualoader: More intelligent screen clearing
  
  r344243:
  lualoader: only clear the screen before first password prompt
  
  This was previously an unconditional screen clear, regardless of whether or
  not we would be prompting for any passwords. This is pointless, given that
  the screen clear is only there to put our screen into a consistent state
  before we draw the prompts and do cursor manipulation.
  
  This is also the only screen clear besides that to draw the menu.  One can
  now see early pre-loader and loader output with the menu disabled, which may
  be useful for diagnostics.
  
  r345517:
  lualoader: Clear the screen before prompting for password
  
  Assuming that the autoboot sequence was interrupted, we've done enough
  cursor manipulation that the prompt for the password will be sufficiently
  obscured a couple of lines up. Clear the screen and reset the cursor
  position here, too.
  
  r345518:
  lualoader: Fix up some luacheck concerns
  
  - Garbage collect an unused (removed because it was useless) constant
  - Don't bother with vararg notation if args will not be used

Modified:
  stable/11/stand/lua/config.lua
  stable/11/stand/lua/menu.lua
  stable/11/stand/lua/password.lua
Directory Properties:
  stable/11/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/12/stand/lua/config.lua
  stable/12/stand/lua/menu.lua
  stable/12/stand/lua/password.lua
Directory Properties:
  stable/12/   (props changed)

Modified: stable/11/stand/lua/config.lua
==============================================================================
--- stable/11/stand/lua/config.lua	Thu Apr  4 17:27:01 2019	(r345881)
+++ stable/11/stand/lua/config.lua	Thu Apr  4 17:29:43 2019	(r345882)
@@ -45,7 +45,6 @@ local MSG_FAILOPENCFG = "Failed to open config: '%s'"
 local MSG_FAILREADCFG = "Failed to read config: '%s'"
 local MSG_FAILPARSECFG = "Failed to parse config: '%s'"
 local MSG_FAILEXBEF = "Failed to execute '%s' before loading '%s'"
-local MSG_FAILEXMOD = "Failed to execute '%s'"
 local MSG_FAILEXAF = "Failed to execute '%s' after loading '%s'"
 local MSG_MALFORMED = "Malformed line (%d):\n\t'%s'"
 local MSG_DEFAULTKERNFAIL = "No kernel set, failed to load from module_path"

Modified: stable/11/stand/lua/menu.lua
==============================================================================
--- stable/11/stand/lua/menu.lua	Thu Apr  4 17:27:01 2019	(r345881)
+++ stable/11/stand/lua/menu.lua	Thu Apr  4 17:29:43 2019	(r345882)
@@ -494,7 +494,7 @@ function menu.autoboot(delay)
 end
 
 -- CLI commands
-function cli.menu(...)
+function cli.menu()
 	menu.run()
 end
 

Modified: stable/11/stand/lua/password.lua
==============================================================================
--- stable/11/stand/lua/password.lua	Thu Apr  4 17:27:01 2019	(r345881)
+++ stable/11/stand/lua/password.lua	Thu Apr  4 17:29:43 2019	(r345882)
@@ -38,7 +38,14 @@ local INCORRECT_PASSWORD = "loader: incorrect password
 -- Asterisks as a password mask
 local show_password_mask = false
 local twiddle_chars = {"/", "-", "\\", "|"}
+local screen_setup = false
 
+local function setup_screen()
+	screen.clear()
+	screen.defcursor()
+	screen_setup = true
+end
+
 -- Module exports
 function password.read(prompt_length)
 	local str = ""
@@ -80,8 +87,6 @@ function password.read(prompt_length)
 end
 
 function password.check()
-	screen.clear()
-	screen.defcursor()
 	-- pwd is optionally supplied if we want to check it
 	local function doPrompt(prompt, pwd)
 		local attempts = 1
@@ -90,6 +95,10 @@ function password.check()
 			printc("\r" .. string.rep(" ", #INCORRECT_PASSWORD))
 		end
 
+		if not screen_setup then
+			setup_screen()
+		end
+
 		while true do
 			if attempts > 1 then
 				clear_incorrect_text_prompt()
@@ -126,6 +135,11 @@ function password.check()
 	local pwd = loader.getenv("password")
 	if pwd ~= nil then
 		core.autoboot()
+		-- The autoboot sequence was interrupted, so we'll need to
+		-- prompt for a password.  Put the screen back into a known
+		-- good state, otherwise we're drawing back a couple lines
+		-- in the middle of other text.
+		setup_screen()
 	end
 	compare("Loader password:", pwd)
 end





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201904041729.x34HTi11034698>