git: 8ea26f3280f7 - stable/14 - loader: Fetch initial script from loader_lua env

From: Warner Losh <imp_at_FreeBSD.org>
Date: Tue, 16 Apr 2024 20:12:39 UTC
The branch stable/14 has been updated by imp:

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

commit 8ea26f3280f7df1aad1c34d5bad1472a02c18fdf
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2024-02-14 17:51:38 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2024-04-16 19:54:23 +0000

    loader: Fetch initial script from loader_lua env
    
    Sometimes it is nice to override the initial script that we run. Make it
    possible by fetching loader_lua from the env and using that instead of
    the default if prsent.
    
    Sponsored by:           Netflix
    Differential Revision:  https://reviews.freebsd.org/D43819
    
    (cherry picked from commit cd147a2a024301a796f307c7bae686305d2bf302)
---
 stand/common/interp_lua.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/stand/common/interp_lua.c b/stand/common/interp_lua.c
index db58d80b2048..3f758baebc2d 100644
--- a/stand/common/interp_lua.c
+++ b/stand/common/interp_lua.c
@@ -123,7 +123,9 @@ interp_init(void)
 		lua_pop(luap, 1);  /* remove lib */
 	}
 
-	filename = LOADER_LUA;
+	filename = getenv("loader_lua");
+	if (filename == NULL)
+		filename = LOADER_LUA;
 	if (interp_include(filename) != 0) {
 		const char *errstr = lua_tostring(luap, -1);
 		errstr = errstr == NULL ? "unknown" : errstr;