Project

General

Profile

Bug #1722

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

Added by chris@arachsys.com almost 8 years ago. Updated almost 8 years ago.

Status:
Fixed
Priority:
Normal
Assignee:
-
Category:
mod_fastcgi
Target version:
Start date:
Due date:
% Done:

0%

Missing in 1.5.x:

Description

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 View - Patch to fix env_add against lighttpd 1.4.19 (1.27 KB) chris@arachsys.com, 2008-07-15 19:51

Associated revisions

Revision 6ce1dfb0 (diff)
Added by stbuehler almost 8 years ago

mod_{fast,s}cgi: overwrite environment variables (#1722)

git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@2265 152afb58-edef-0310-8abb-c4023f1b3aa9

History

#1 Updated by stbuehler almost 8 years ago

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

Fixed in r2265

Also available in: Atom