From: mattias at sudac dot org
Operating system:
PHP version: 4CVS-2003-07-25 (stable)
PHP Bug Type: Other web server
Bug description: Patch for implementing missing getenv in thttpd SAPI
Description:
------------
Hello
I think this is a better-then-nothing implementation of getenv for the
thttpd SAPI.
The patch should proabably work with both rev 1.77.2.13.2.2 and 1.91 of
thttpd.c
--- thttpd.c.orig 2003-07-25 10:56:54.000000000 +0200
+++ thttpd.c 2003-07-25 11:02:00.000000000 +0200
@@ -368,6 +368,20 @@
return SUCCESS;
}
+/* This implementation will return values of environment variables
matched in the
+ * $_SERVER array, if not return NULL and it will fallback to normal libc
getenv.
+ * By doing this getenv("REMOTE_ADDR") and others will work fine.
+ */
+static char *sapi_thttpd_getenv(char *name, size_t name_len TSRMLS_DC)
+{
+ zval **val = NULL;
+
+
if(zend_hash_find(HASH_OF(PG(http_globals)[TRACK_VARS_SERVER]),name,name_len+1,(void**)&v
+ return Z_STRVAL_PP(val);
+ else
+ return NULL;
+}
+
static sapi_module_struct thttpd_sapi_module = {
"thttpd",
"thttpd",
@@ -381,7 +395,7 @@
sapi_thttpd_ub_write,
NULL,
NULL, /* get uid */
- NULL, /* getenv */
+ sapi_thttpd_getenv, /* getenv */
php_error,
--
Edit bug report at http://bugs.php.net/?id=24802&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=24802&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=24802&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=24802&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=24802&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=24802&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=24802&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=24802&r=support
Expected behavior: http://bugs.php.net/fix.php?id=24802&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=24802&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=24802&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=24802&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=24802&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=24802&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=24802&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=24802&r=gnused