git: e9eee0f256a3 - main - lua: Export loaded modules env vars via environment

From: Warner Losh <imp_at_FreeBSD.org>
Date: Thu, 09 Feb 2023 18:56:53 UTC
The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=e9eee0f256a3501862beafaa6a45bcac8dd193d9

commit e9eee0f256a3501862beafaa6a45bcac8dd193d9
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2023-02-09 16:49:43 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2023-02-09 18:56:20 +0000

    lua: Export loaded modules env vars via environment
    
    To make auditing and debugging easier, export foo_load=XXX foo_name=yyy
    etc to the loader env that we export to the kernel.
    
    Original by:            dhw
    Sponsored by:           Netflix
    Discussed with:         kevans
    Differential Revsion:   https://reviews.freebsd.org/D38466
---
 stand/lua/config.lua | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/stand/lua/config.lua b/stand/lua/config.lua
index 9ef7c0796f46..04d5cda1e704 100644
--- a/stand/lua/config.lua
+++ b/stand/lua/config.lua
@@ -256,6 +256,7 @@ local pattern_table = {
 				modules[k] = {}
 			end
 			modules[k].load = v:upper()
+			setEnv(k .. "_load", v:upper())
 		end,
 	},
 	--  module_name="value"
@@ -263,6 +264,7 @@ local pattern_table = {
 		str = MODULEEXPR .. "_name%s*=%s*$VALUE",
 		process = function(k, v)
 			setKey(k, "name", v)
+			setEnv(k .. "_name", v)
 		end,
 	},
 	--  module_type="value"
@@ -270,6 +272,7 @@ local pattern_table = {
 		str = MODULEEXPR .. "_type%s*=%s*$VALUE",
 		process = function(k, v)
 			setKey(k, "type", v)
+			setEnv(k .. "_type", v)
 		end,
 	},
 	--  module_flags="value"
@@ -277,6 +280,7 @@ local pattern_table = {
 		str = MODULEEXPR .. "_flags%s*=%s*$VALUE",
 		process = function(k, v)
 			setKey(k, "flags", v)
+			setEnv(k .. "_flags", v)
 		end,
 	},
 	--  module_before="value"
@@ -284,6 +288,7 @@ local pattern_table = {
 		str = MODULEEXPR .. "_before%s*=%s*$VALUE",
 		process = function(k, v)
 			setKey(k, "before", v)
+			setEnv(k .. "_before", v)
 		end,
 	},
 	--  module_after="value"
@@ -291,6 +296,7 @@ local pattern_table = {
 		str = MODULEEXPR .. "_after%s*=%s*$VALUE",
 		process = function(k, v)
 			setKey(k, "after", v)
+			setEnv(k .. "_after", v)
 		end,
 	},
 	--  module_error="value"
@@ -298,6 +304,7 @@ local pattern_table = {
 		str = MODULEEXPR .. "_error%s*=%s*$VALUE",
 		process = function(k, v)
 			setKey(k, "error", v)
+			setEnv(k .. "_error", v)
 		end,
 	},
 	--  exec="command"