nic-6443 commented on PR #13147:
URL: https://github.com/apache/apisix/pull/13147#issuecomment-4676906226

   I looked into the underlying issue (#13055) and I don't think this approach 
can work, unfortunately. The collision happens in init_by_lua, where 
lua-resty-core has replaced `os.getenv` with a shim backed by 
`ngx_http_lua_ffi_get_conf_env` — and at that point nginx hasn't applied `env` 
directives to the real environ yet (that happens in worker init), so the 
`ffi.C.environ` snapshot this PR builds doesn't contain `env NAME=VALUE` 
directive vars at all. The lookup misses and falls back to the captured 
`os.getenv`, which is the buggy shim itself — I verified this by simulating the 
override on openresty 1.29.2.4, and it matches the CI failures here.
   
   The real bug is in lua-nginx-module's `ngx_http_lua_ffi_get_conf_env`: it 
matches entries with `ngx_strncmp(name, var[i].data, var[i].len)` without 
checking that the queried name ends at `var[i].len`, so the first 
prefix-colliding entry wins. That needs an exact-length check upstream (plus a 
runtime patch until it's released); an APISIX-side Lua fix can detect the wrong 
entry but can't reach the correct one, since the FFI only returns the first 
match.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to