freebsd-dev/stand
Kyle Evans 576562856e lualoader: improve loader.conf var processing
lualoader was previously not processing \ as escapes; this commit fixes
that and does better error checking on the value as well.

Additionally, loader.conf had some odd restrictions on values that make
little sense. Previously, lines like:

kernel=foo

Would simply be discarded with a malformed line complaint you might not
see unless you disable beastie.

lualoader tries to process these as well as it can and manipulates the
environment, while forthloader did minimal processing and constructed a
`set` command to do the heavy lifting instead. The lua approach was
re-envisioned from building a `set` command so that we can appropriately
reset the environment when, for example, boot environments change.

Lift the previous restrictions to allow unquoted values on the right hand
side of an expression.  Note that an unquoted value is effectively:

[A-Za-z0-9-][A-Za-z0-9-_.]*

This commit also stops trying to weirdly limit what it can handle in a
quoted value. Previously it only allowed spaces, alphanumeric, and
punctuation, which is kind of weird. Change it here to grab as much as it
can between two sets of quotes, then let processEnvVar() do the needful and
complain if it finds something malformed looking.

My extremely sophisticated test suite is as follows:

<<EOF
X_01_simple_string="simple"
X_02_escaped_string="s\imple"

X_03_unquoted_val=3
X_04_unquoted_strval=simple_test

X_05_subval="${X_03_unquoted_val}"
X_06_escaped_subval="\${X_03_unquoted_val}"

X_07_embedded="truth${X_03_unquoted_val}"
X_08_escaped_embedded="truth\${X_03_unquoted_val}"

X_09_unknown="${unknown_val}"
X_10_unknown_embedded="truth${unknown_val}"

X_11_crunchy="crunch$unknown_val crunch"
X_12_crunchy="crunch${unknown_val}crunch"

Y_01_badquote="te"lol"
Y_02_eolesc="lol\"
Y_02_noteolesc="lol\\"
Y_03_eolvar="lol$"
Y_03_noteolvar="lol\$"
Y_04_badvar="lol${"

exec="echo Done!"
EOF

Future work may provide a stub loader module in userland so that we can
formally test the loader scripts rather than sketchy setups like the above
in conjunction with the lua-* tools in ^/tools/boot.
2021-01-24 13:54:47 -06:00
..
arm Remove tests for obsolete compilers in the build system 2020-05-12 15:22:40 +00:00
arm64 No need to make objects here. 2018-04-27 22:15:18 +00:00
common Reuse the amd64 loader relocation code on arm64 2021-01-20 17:59:38 +00:00
defaults Fix date 2021-01-07 21:15:26 +01:00
efi loader: create built in font from bold font face 2021-01-23 10:53:30 +02:00
fdt stand/fdt: Scale blob size better as overlays apply 2020-01-09 04:34:42 +00:00
ficl loader: implement framebuffer console 2021-01-02 21:41:36 +02:00
ficl32 Enable veriexec for loader 2019-02-26 06:22:10 +00:00
fonts loader: really use bold font for vga text mode 2021-01-08 01:24:30 +02:00
forth loader: implement framebuffer console 2021-01-02 21:41:36 +02:00
i386 loader: create built in font from bold font face 2021-01-23 10:53:30 +02:00
images loader: implement framebuffer console 2021-01-02 21:41:36 +02:00
kshim Properly define the bool type in the BSD kernel shim. 2020-12-07 16:08:31 +00:00
liblua contrib/lua: update to 5.4.2 2021-01-13 23:56:18 -06:00
liblua32 Add Lua as a scripting langauge to /boot/loader 2018-02-12 15:31:53 +00:00
libofw Fix 64-bit build of libofw. 2020-09-08 23:22:11 +00:00
libsa pkgfs_open: follow symlinks 2021-01-14 17:33:05 -08:00
libsa32 Enable veriexec for loader 2019-02-26 06:22:10 +00:00
lua lualoader: improve loader.conf var processing 2021-01-24 13:54:47 -06:00
man Correct the documented size of kern.msgbufsize 2020-10-02 15:37:51 +00:00
mips loader: fix mips build with gfx_fb 2021-01-04 16:57:50 +00:00
powerpc loader: fix powerpc build with gfx_fb 2021-01-04 16:57:58 +00:00
uboot loader: fix uboot build with gfx_fb 2021-01-03 20:45:37 +02:00
usb Fix build of stand/usb . 2020-01-23 10:40:34 +00:00
userboot loader: implement framebuffer console 2021-01-02 21:41:36 +02:00
defs.mk [PowerPC64LE] Set up powerpc.powerpc64le architecture 2020-09-22 23:49:30 +00:00
fdt.mk
ficl.mk loader: implement framebuffer console 2021-01-02 21:41:36 +02:00
loader.mk loader: fix build on non-x86 platforms 2021-01-03 00:04:56 +02:00
lua.mk Do not include float interfaces when using libsa. 2018-02-23 04:04:25 +00:00
Makefile stand: remove bogus dependency from libsa32 2021-01-07 16:28:21 -06:00
Makefile.amd64 stand: properly declare subdir deps or .WAIT, do parallel build 2020-12-31 11:15:45 -06:00
Makefile.inc stand: properly declare subdir deps or .WAIT, do parallel build 2020-12-31 11:15:45 -06:00
uboot.mk Unify metadata load files for arm, mips, powerpc, sparc64 2018-02-13 03:44:50 +00:00