Req #24802 [Opn->Csd]: [THTTPD SAPI] Patch for implementing missing getenv

From: Date: Sun, 08 Jan 2017 06:23:22 +0000
Subject: Req #24802 [Opn->Csd]: [THTTPD SAPI] Patch for implementing missing getenv
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-206384@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=24802&edit=1

 ID:                 24802
 Updated by:         krakjoe@php.net
 Reported by:        mattias at sudac dot org
 Summary:            [THTTPD SAPI] Patch for implementing missing getenv
-Status:             Open
+Status:             Closed
 Type:               Feature/Change Request
 Package:            Other web server
 PHP Version:        4CVS-2003-07-25 (stable)
-Assigned To:        
+Assigned To:        krakjoe
 Block user comment: N
 Private report:     N

 New Comment:

This SAPI has been removed from PHP.


Previous Comments:
------------------------------------------------------------------------
[2003-07-25 06:16:26] magnus@php.net

Send it to internals@lists.php.net and CC Sascha (sas@php.net)

------------------------------------------------------------------------
[2003-07-25 05:48:41] mattias at sudac dot org

The web form seams to have mangle the patch a bit, &v insted of &val for example.

------------------------------------------------------------------------
[2003-07-25 04:14:04] mattias at sudac dot org

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 this bug report at https://bugs.php.net/bug.php?id=24802&edit=1


Thread (4 messages)

« previous php.bugs (#206384) next »