mod_fastcgi/mod_scgi: bin-environment doesn't override parent environment
Both mod_fastcgi and mod_scgi have a bin-environment option which allows the environment of a child fastcgi/scgi process to be set. However, if a variable is inherited from the parent of lighttpd itself, it can't be overridden using bin-environment (unless masked out by bin-copy-environment).
This is because there is a bug in env_add in mod_fastcgi.c and mod_scgi.c which unconditionally adds the VAR=VAL string to the end of the environment, rather than replacing an existing VAR=OLDVAR entry if one exists. As a result, if a variable is both inherited from the parent and set in bin-environment, execve is called with an environment array containing both values for VAR. Typically getenv(2) will return the first value with such a process environment, so the likely result is that the bin-environment fails to have the expected effect.
The attached patch against lighttpd-1.4.19 fixes this problem by making env_add consistent with the behaviour of putenv(2)/setenv(2). (The fix is presumably not relevant for 1.5.x as mod_fastcgi and mod_scgi are deprecated there.)
Updated by stbuehler over 14 years ago
- Status changed from New to Fixed
- Resolution set to fixed
Fixed in r2265
Also available in: Atom