Project

General

Profile

Actions

Bug #1722

closed

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

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

Status:
Fixed
Priority:
Normal
Category:
mod_fastcgi
Target version:
ASK QUESTIONS IN Forums:

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


Files

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

Updated by stbuehler over 15 years ago

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

Fixed in r2265

Actions

Also available in: Atom