Bug #1722

mod_fastcgi/mod_scgi: bin-environment doesn't override parent environment

Added by chris@arachsys.com over 7 years ago. Updated over 7 years ago.

Status:FixedStart date:
Priority:NormalDue date:
Assignee:-% Done:


Target version:1.4.20
Missing in 1.5.x:


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.)

lighttpd-1.4.19-env_add.patch Magnifier - Patch to fix env_add against lighttpd 1.4.19 (1.27 KB) chris@arachsys.com, 2008-07-15 19:51


#1 Updated by stbuehler over 7 years ago

  • Status changed from New to Fixed
  • Resolution set to fixed

Fixed in r2265

Also available in: Atom