]> xenbits.xensource.com Git - freebsd.git/commitdiff
lualoader: Revert to ASCII menu frame for serial console
authorkevans <kevans@FreeBSD.org>
Tue, 10 Sep 2019 21:30:38 +0000 (21:30 +0000)
committerkevans <kevans@FreeBSD.org>
Tue, 10 Sep 2019 21:30:38 +0000 (21:30 +0000)
The box drawing characters we use aren't necessarily safe with a serial
console; for instance, in the report by npn@, these were causing his xterm
to send back a sequence that lua picked up as input and halted the boot.
This is less than ideal.

Fallback to ASCII frames for console with 'comconsole' in it.  This is a
partial revert r338108 by imp@ -- instead of removing the menu entirely and
disabling color/cursor sequences, just reverting the default frame to ASCII
is enough to not break in this setup.

Reported by: npn
Triaged and recommended by: tsoome

stand/lua/core.lua
stand/lua/drawer.lua

index 722381e0a066e5f01ed90a1f7f72337e8db97ce7..61476a2ed7219a5689d228e95d44d0fc64fc184a 100644 (file)
@@ -325,6 +325,16 @@ function core.isZFSBoot()
        return false
 end
 
+function core.isSerialConsole()
+       local c = loader.getenv("console")
+       if c ~= nil then
+               if c:find("comconsole") ~= nil then
+                       return true
+               end
+       end
+       return false
+end
+
 function core.isSerialBoot()
        local s = loader.getenv("boot_serial")
        if s ~= nil then
index 18030979398c79660d5a54df281bd884b6c5bd00..6a5b62b79817265e491a2bf7eededf0e566161a6 100644 (file)
@@ -144,13 +144,20 @@ local function drawmenu(menudef)
        return alias_table
 end
 
+local function defaultframe()
+       if core.isSerialConsole() then
+               return "ascii"
+       end
+       return "double"
+end
+
 local function drawbox()
        local x = menu_position.x - 3
        local y = menu_position.y - 1
        local w = frame_size.w
        local h = frame_size.h
 
-       local framestyle = loader.getenv("loader_menu_frame") or "double"
+       local framestyle = loader.getenv("loader_menu_frame") or defaultframe()
        local framespec = drawer.frame_styles[framestyle]
        -- If we don't have a framespec for the current frame style, just don't
        -- draw a box.