From owner-svn-src-stable@freebsd.org  Tue Sep  3 14:06:13 2019
Return-Path: <owner-svn-src-stable@freebsd.org>
Delivered-To: svn-src-stable@mailman.nyi.freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1])
 by mailman.nyi.freebsd.org (Postfix) with ESMTP id 610A5DC527;
 Tue,  3 Sep 2019 14:06:12 +0000 (UTC)
 (envelope-from yuripv@freebsd.org)
Received: from freefall.freebsd.org (freefall.freebsd.org
 [IPv6:2610:1c1:1:6074::16:84])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 server-signature RSA-PSS (4096 bits)
 client-signature RSA-PSS (4096 bits) client-digest SHA256)
 (Client CN "freefall.freebsd.org",
 Issuer "Let's Encrypt Authority X3" (verified OK))
 by mx1.freebsd.org (Postfix) with ESMTPS id 46N7z8053Jz4PJc;
 Tue,  3 Sep 2019 14:06:12 +0000 (UTC)
 (envelope-from yuripv@freebsd.org)
Received: by freefall.freebsd.org (Postfix, from userid 1452)
 id 687161A2E4; Tue,  3 Sep 2019 14:06:01 +0000 (UTC)
X-Original-To: yuripv@localmail.freebsd.org
Delivered-To: yuripv@localmail.freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [96.47.72.80])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
 (Client CN "mx1.freebsd.org",
 Issuer "Let's Encrypt Authority X3" (verified OK))
 by freefall.freebsd.org (Postfix) with ESMTPS id E4CFD18199;
 Thu,  4 Apr 2019 17:29:55 +0000 (UTC)
 (envelope-from owner-src-committers@freebsd.org)
Received: from freefall.freebsd.org (freefall.freebsd.org [96.47.72.132])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 server-signature RSA-PSS (4096 bits)
 client-signature RSA-PSS (4096 bits) client-digest SHA256)
 (Client CN "freefall.freebsd.org",
 Issuer "Let's Encrypt Authority X3" (verified OK))
 by mx1.freebsd.org (Postfix) with ESMTPS id 57108841FC;
 Thu,  4 Apr 2019 17:29:55 +0000 (UTC)
 (envelope-from owner-src-committers@freebsd.org)
Received: by freefall.freebsd.org (Postfix, from userid 538)
 id 0B6251818A; Thu,  4 Apr 2019 17:29:48 +0000 (UTC)
Delivered-To: src-committers@localmail.freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [96.47.72.80])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
 (Client CN "mx1.freebsd.org",
 Issuer "Let's Encrypt Authority X3" (verified OK))
 by freefall.freebsd.org (Postfix) with ESMTPS id 3A006180B2
 for <src-committers@localmail.freebsd.org>;
 Thu,  4 Apr 2019 17:29:45 +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.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 server-signature RSA-PSS (4096 bits)
 client-signature RSA-PSS (4096 bits) client-digest SHA256)
 (Client CN "mxrelay.nyi.freebsd.org",
 Issuer "Let's Encrypt Authority X3" (verified OK))
 by mx1.freebsd.org (Postfix) with ESMTPS id 0028784113;
 Thu,  4 Apr 2019 17:29:45 +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 C786F95F;
 Thu,  4 Apr 2019 17:29:44 +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 x34HTibw034701;
 Thu, 4 Apr 2019 17:29:44 GMT (envelope-from kevans@FreeBSD.org)
Received: (from kevans@localhost)
 by repo.freebsd.org (8.15.2/8.15.2/Submit) id x34HTi11034698;
 Thu, 4 Apr 2019 17:29:44 GMT (envelope-from kevans@FreeBSD.org)
Message-Id: <201904041729.x34HTi11034698@repo.freebsd.org>
X-Authentication-Warning: repo.freebsd.org: kevans set sender to
 kevans@FreeBSD.org using -f
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
X-SVN-Group: stable-11
X-SVN-Commit-Author: kevans
X-SVN-Commit-Paths: in stable: 11/stand/lua 12/stand/lua
X-SVN-Commit-Revision: 345882
X-SVN-Commit-Repository: base
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Precedence: bulk
X-Loop: FreeBSD.org
Sender: owner-src-committers@freebsd.org
X-Rspamd-Queue-Id: 57108841FC
X-Spamd-Bar: --
Authentication-Results: mx1.freebsd.org
X-Spamd-Result: default: False [-2.92 / 15.00];
 local_wl_from(0.00)[freebsd.org];
 NEURAL_HAM_MEDIUM(-1.00)[-0.999,0];
 NEURAL_HAM_SHORT(-0.92)[-0.920,0];
 ASN(0.00)[asn:11403, ipnet:96.47.64.0/20, country:US];
 NEURAL_HAM_LONG(-1.00)[-1.000,0]
Status: O
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.29
List-Id: SVN commit messages for all the -stable branches of the src tree
 <svn-src-stable.freebsd.org>
List-Unsubscribe: <https://lists.freebsd.org/mailman/options/svn-src-stable>, 
 <mailto:svn-src-stable-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-stable/>
List-Post: <mailto:svn-src-stable@freebsd.org>
List-Help: <mailto:svn-src-stable-request@freebsd.org?subject=help>
List-Subscribe: <https://lists.freebsd.org/mailman/listinfo/svn-src-stable>,
 <mailto:svn-src-stable-request@freebsd.org?subject=subscribe>
Date: Tue, 03 Sep 2019 14:06:13 -0000
X-Original-Date: Thu, 4 Apr 2019 17:29:44 +0000 (UTC)
X-List-Received-Date: Tue, 03 Sep 2019 14:06:13 -0000

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