mini-httpd (1.19-9.3) 03-cgi-php.dpatch

Summary

 mini_httpd.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

    
download this patch

Patch contents

#!/bin/sh /usr/share/dpatch/dpatch-run
## 03-cgi-php.dpatch by Marvin Stark <marv@der-marv.de>
## Thanks to Thorsten Schmale who has written this patch.
##
## DP: mini_httpd does not run php cgi's.
## DP: mini_httpd shows following error: "No input file specified".

@DPATCH@

--- mini-httpd-1.19/mini_httpd.c.orig	2008-02-05 08:40:28.000000000 +0000
+++ mini-httpd-1.19/mini_httpd.c		2008-02-05 08:50:35.000000000 +0000
@@ -1129,7 +1129,7 @@
     int r, file_len, i;
     const char* index_names[] = {
 	"index.html", "index.htm", "index.xhtml", "index.xht", "Default.htm",
-	"index.cgi" };
+	"index.cgi", "index.php" };
 
     /* Set up the timeout for reading. */
 #ifdef HAVE_SIGSET
@@ -2117,6 +2117,7 @@
     int envn;
     char* cp;
     char buf[256];
+    char rp[MAXPATHLEN];
 
     envn = 0;
     envp[envn++] = build_env( "PATH=%s", CGI_PATH );
@@ -2134,7 +2135,7 @@
     envp[envn++] = build_env( "SERVER_PORT=%s", buf );
     envp[envn++] = build_env(
 	"REQUEST_METHOD=%s", get_method_str( method ) );
-    envp[envn++] = build_env( "SCRIPT_NAME=%s", path );
+    envp[envn++] = build_env( "SCRIPT_FILENAME=%s", realpath(file, rp) );
     if ( pathinfo != (char*) 0 )
 	{
 	envp[envn++] = build_env( "PATH_INFO=/%s", pathinfo );