From 55d8f3074e76acfe4530396074947749e5a8362d Mon Sep 17 00:00:00 2001 From: fattylin0110 Date: Sat, 14 Nov 2026 18:58:24 +0800 Subject: [PATCH 1/2] mod_lua: Restrict LuaRoot to RSRC_CONF to fix per-dir pool lifetime bug register_root_dir() stores the resolved LuaRoot path pointer into the server-level configuration (ap_lua_server_cfg on parms->server->module_config) rather than the per-directory configuration. When LuaRoot is used in an .htaccess file (permitted by OR_ALL), parms->pool is the transient request pool (r->pool), causing cross-request server config pollution and leaving a dangling pointer in server_cfg->root_path once the request pool is cleared. Restrict LuaRoot to RSRC_CONF to match its server-scoped implementation. --- modules/lua/mod_lua.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/lua/mod_lua.c b/modules/lua/mod_lua.c index c2c751a92ae..125994964e1 100644 --- a/modules/lua/mod_lua.c +++ b/modules/lua/mod_lua.c @@ -1852,7 +1852,7 @@ static const char *register_authz_provider(cmd_parms *cmd, void *_cfg, static const command_rec lua_commands[] = { - AP_INIT_TAKE1("LuaRoot", register_lua_root, NULL, OR_ALL, + AP_INIT_TAKE1("LuaRoot", register_lua_root, NULL, RSRC_CONF, "Specify the base path for resolving relative paths for mod_lua directives"), AP_INIT_TAKE1("LuaPackagePath", register_package_dir, NULL, OR_ALL, From bf605820d9ffa197a849df1c5367288ec471e46e Mon Sep 17 00:00:00 2001 From: Eric Covener Date: Sat, 14 Nov 2026 07:21:17 -0500 Subject: [PATCH 2/2] mod_lua: document LuaRoot's server-level scope Update the manual for the LuaRoot context change and add a CHANGES entry, since existing configurations which used the directive in or .htaccess will now fail to start. Co-Authored-By: Claude Fable 5.1 --- changes-entries/lua_root_context.txt | 3 +++ docs/manual/mod/mod_lua.xml | 11 +++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 changes-entries/lua_root_context.txt diff --git a/changes-entries/lua_root_context.txt b/changes-entries/lua_root_context.txt new file mode 100644 index 00000000000..75705b4a451 --- /dev/null +++ b/changes-entries/lua_root_context.txt @@ -0,0 +1,3 @@ + *) mod_lua: LuaRoot is now allowed only in server config and virtual + host context, matching where it has always taken effect. + [fattylin0110 ] diff --git a/docs/manual/mod/mod_lua.xml b/docs/manual/mod/mod_lua.xml index cecac502347..deaf9eef3b7 100644 --- a/docs/manual/mod/mod_lua.xml +++ b/docs/manual/mod/mod_lua.xml @@ -1309,15 +1309,22 @@ collectgarbage() -- close the handle via GC Specify the base path for resolving relative paths for mod_lua directives LuaRoot /path/to/a/directory server configvirtual host -directory.htaccess -All +Allowed only in server config and virtual host context +in version 2.5.1 and later; earlier versions also accepted it in +directory and .htaccess context, where it applied to the whole +virtual host.

Specify the base path which will be used to evaluate all relative paths within mod_lua. If not specified they will be resolved relative to the current working directory, which may not always work well for a server.

+ +

The directive applies to the whole virtual host and must appear + before any LuaPackagePath or + LuaPackageCPath directive whose + argument it should resolve.