[ previous ] [ next ] [ threads ]
 
 From:  "Manuel Kasper" <mk at neon1 dot net>
 To:  m0n0wall at lists dot m0n0 dot ch
 Subject:  Re: [m0n0wall] thttpd patch to run PHP cgi binary
 Date:  Sun, 30 Nov 2003 23:17:53 +0100 (CET)
Manuel Kasper said:
> Here's my patch to mini_httpd-1.17beta1 as used in m0n0wall (AFAIR
> somebody requested this a few days ago, too, but I forgot about it). It

Damn, ezmlm's MIME remover got me again because Apple Mail encoded it as
application/octet-stream. So hope it works this time...

- Manuel
--- mini_httpd.c.orig	Wed Oct  8 10:32:36 2003
+++ mini_httpd.c	Thu Oct  9 09:26:03 2003
@@ -646,6 +646,7 @@
 	    exit( 1 );
 	    }
 	/* Check for unnecessary security exposure. */
+	/*
 	if ( ! do_chroot )
 	    {
 	    syslog( LOG_NOTICE,
@@ -653,6 +654,7 @@
 	    (void) fprintf( stderr,
 		"%s: started as root without requesting chroot(), warning only\n", argv0 );
 	    }
+	*/
 	}
 
     /* Catch various signals. */
@@ -674,6 +676,7 @@
 
     init_mime();
 
+    /*
     if ( hostname == (char*) 0 )
 	syslog(
 	    LOG_NOTICE, "%.80s starting on port %d", SERVER_SOFTWARE, port );
@@ -681,6 +684,7 @@
 	syslog(
 	    LOG_NOTICE, "%.80s starting on %.80s, port %d", SERVER_SOFTWARE,
 	    hostname, port );
+    */
 
     /* Main loop. */
     for (;;)
@@ -1030,7 +1034,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 a timeout. */
 #ifdef HAVE_SIGSET
@@ -1067,9 +1071,11 @@
     ** solution is writev() (as used in thttpd), or send the headers with
     ** send(MSG_MORE) (only available in Linux so far).
     */
+/*
     r = 1;
     (void) setsockopt(
 	conn_fd, IPPROTO_TCP, TCP_NOPUSH, (void*) &r, sizeof(r) );
+*/
 #endif /* TCP_NOPUSH */
 
 #ifdef USE_SSL
@@ -1986,6 +1992,7 @@
     int envn;
     char* cp;
     char buf[256];
+    char rp[MAXPATHLEN];
 
     envn = 0;
     envp[envn++] = build_env( "PATH=%s", CGI_PATH );
@@ -2004,6 +2011,7 @@
     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 );
@@ -2865,8 +2873,10 @@
 static void
 handle_sigterm( int sig )
     {
+    /*
     syslog( LOG_NOTICE, "exiting due to signal %d", sig );
     (void) fprintf( stderr, "%s: exiting due to signal %d\n", argv0, sig );
+    */
     closelog();
     exit( 1 );
     }
@@ -2913,7 +2923,9 @@
 static void
 handle_sigalrm( int sig )
     {
+    /*
     syslog( LOG_INFO, "%.80s connection timed out", ntoa( &client_addr ) );
+    */
     send_error(
 	408, "Request Timeout", "",
 	"No request appeared within a reasonable time period." );