From 56c58a5402dce20c09b5bc0d8006f34b62dbc932 Mon Sep 17 00:00:00 2001
From: landley <landley@69ca8d6d-28ef-0310-b511-8ec308f3f277>
Date: Thu, 1 Sep 2005 09:38:32 +0000
Subject: Tracking system but #4: php needs the environment variable
 SCRIPT_FILENAME.

git-svn-id: svn://busybox.net/trunk/busybox@11309 69ca8d6d-28ef-0310-b511-8ec308f3f277
---
 networking/httpd.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/networking/httpd.c b/networking/httpd.c
index e3f4027dc..191a316a1 100644
--- a/networking/httpd.c
+++ b/networking/httpd.c
@@ -1146,6 +1146,11 @@ static int sendCgi(const char *url,
       }
       if(script != NULL)
 	*script = '\0';         /* reduce /PATH_INFO */
+       /* SCRIPT_FILENAME required by PHP in CGI mode */
+       if(realpath(purl + 1, realpath_buff))
+         addEnv("SCRIPT", "FILENAME", realpath_buff);
+       else
+         *realpath_buff = 0;
       /* set SCRIPT_NAME as full path: /cgi-bin/dirs/script.cgi */
       addEnv("SCRIPT_NAME",    "",         purl);
       addEnv("QUERY_STRING",   "",         config->query);
@@ -1178,7 +1183,7 @@ static int sendCgi(const char *url,
 	/* set execve argp[0] without path */
       argp[0] = strrchr( purl, '/' ) + 1;
 	/* but script argp[0] must have absolute path and chdiring to this */
-      if(realpath(purl + 1, realpath_buff) != NULL) {
+      if(*realpath_buff) {
 	    script = strrchr(realpath_buff, '/');
 	    if(script) {
 		*script = '\0';
-- 
cgit v1.2.3-55-g6feb