php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #5978 Fix for web server Thttpd 2.19
Submitted: 2000-08-05 00:42 UTC Modified: 2000-08-07 10:30 UTC
From: nick at sptl dot org Assigned:
Status: Closed Package: Installation problem
PHP Version: 4.0.1pl2 OS: Linux
Private report: No CVE-ID: None
 [2000-08-05 00:42 UTC] nick at sptl dot org
patch file (source page on http://phpgem.ru.net/thttpd.php3) :

diff -ur php-4.0.1.pl2.orig/configure php-4.0.1.pl2.patch/configure
--- php-4.0.1.pl2.orig/configure        Mon Jul 31 12:00:09 2000
+++ php-4.0.1.pl2.patch/configure       Mon Jul 31 12:41:51 2000
@@ -3831,9 +3831,9 @@
   INSTALL_IT="\
     echo 'PHP_LIBS = -L. -lphp4 \$(PHP_LIBS) \$(EXTRA_LIBS)' > $THTTPD/php_makefile; \
     echo 'PHP_LDFLAGS = \$(NATIVE_RPATHS) \$(PHP_LDFLAGS)' >> $THTTPD/php_makefile; \
-    cp $abs_srcdir/sapi/thttpd/php_thttpd.h $SAPI_STATIC $THTTPD;\
+    cp \$(top_srcdir)/sapi/thttpd/php_thttpd.h $SAPI_STATIC $THTTPD;\
     test -f $THTTPD/php_patched || \
-    (cd $THTTPD && patch < $abs_srcdir/sapi/thttpd/thttpd_patch && touch php_patched)"
+    (cd $THTTPD && patch < \$(top_srcdir)/sapi/thttpd/thttpd_patch && touch php_patched)"
   PHP_THTTPD="yes, using $THTTPD"
   
   if test "$THTTPD" != "/usr/include"; then
diff -ur php-4.0.1.pl2.orig/sapi/thttpd/config.m4 php-4.0.1.pl2.patch/sapi/thttpd/config.m4
--- php-4.0.1.pl2.orig/sapi/thttpd/config.m4    Thu Dec 30 06:59:52 1999
+++ php-4.0.1.pl2.patch/sapi/thttpd/config.m4   Mon Jul 31 12:38:46 2000
@@ -5,9 +5,9 @@
   INSTALL_IT="\
     echo 'PHP_LIBS = -L. -lphp4 \$(PHP_LIBS) \$(EXTRA_LIBS)' > $THTTPD/php_makefile; \
     echo 'PHP_LDFLAGS = \$(NATIVE_RPATHS) \$(PHP_LDFLAGS)' >> $THTTPD/php_makefile; \
-    cp $abs_srcdir/sapi/thttpd/php_thttpd.h $SAPI_STATIC $THTTPD;\
+    cp $top_srcdir/sapi/thttpd/php_thttpd.h $SAPI_STATIC $THTTPD;\
     test -f $THTTPD/php_patched || \
-    (cd $THTTPD && patch < $abs_srcdir/sapi/thttpd/thttpd_patch && touch php_patched)"
+    (cd $THTTPD && patch < $top_srcdir/sapi/thttpd/thttpd_patch && touch php_patched)"
   PHP_THTTPD="yes, using $THTTPD"
   AC_ADD_INCLUDE($THTTPD)
   PHP_BUILD_STATIC
diff -ur php-4.0.1.pl2.orig/sapi/thttpd/thttpd_patch php-4.0.1.pl2.patch/sapi/thttpd/thttpd_patch
--- php-4.0.1.pl2.orig/sapi/thttpd/thttpd_patch Mon Dec 20 11:11:14 1999
+++ php-4.0.1.pl2.patch/sapi/thttpd/thttpd_patch        Tue Jul 11 18:36:23 2000
@@ -1,7 +1,15 @@
-diff -ur thttpd-2.10/Makefile.in thttpd-2.10-php/Makefile.in
---- thttpd-2.10/Makefile.in    Mon Oct 11 20:45:38 1999
-+++ thttpd-2.10-php/Makefile.in        Mon Dec 20 01:37:49 1999
-@@ -46,13 +46,15 @@
+diff -ur thttpd-2.19/Makefile.in thttpd-2.19-php/Makefile.in
+--- thttpd-2.19/Makefile.in    Tue Jul  4 21:21:32 2000
++++ thttpd-2.19-php/Makefile.in        Tue Jul 11 02:45:41 2000
+@@ -39,20 +39,22 @@
+ # CONFIGURE: The group that the web directory belongs to.  This is so that
+ # the makeweb program can be installed set-group-id to that group, and make
+ # subdirectories.  If you're not going to use makeweb, ignore this.
+-WEBGROUP =    www
++WEBGROUP =    nobody
+ 
+ # CONFIGURE: Directory for CGI executables.
+ CGIBINDIR =   $(WEBDIR)/cgi-bin
  
  # You shouldn't need to edit anything below here.
  
@@ -19,9 +27,33 @@
  NETLIBS =     @V_NETLIBS@
  INSTALL =     @INSTALL@
  
-diff -ur thttpd-2.10/libhttpd.c thttpd-2.10-php/libhttpd.c
---- thttpd-2.10/libhttpd.c     Wed Dec 15 23:22:50 1999
-+++ thttpd-2.10-php/libhttpd.c Mon Dec 20 01:05:47 1999
+diff -ur thttpd-2.19/config.h thttpd-2.19-php/config.h
+--- thttpd-2.19/config.h       Tue Jun 27 23:44:44 2000
++++ thttpd-2.19-php/config.h   Tue Jul 11 18:21:55 2000
+@@ -249,7 +249,7 @@
+ 
+ /* CONFIGURE: $PATH to use for CGI programs.
+ */
+-#define CGI_PATH "/usr/local/bin:/usr/ucb:/bin:/usr/bin"
++#define CGI_PATH "/usr/local/bin:/bin:/usr/bin"
+ 
+ /* CONFIGURE: If defined, $LD_LIBRARY_PATH to use for CGI programs.
+ */
+diff -ur thttpd-2.19/configure thttpd-2.19-php/configure
+--- thttpd-2.19/configure      Wed May 10 05:41:57 2000
++++ thttpd-2.19-php/configure  Tue Jul 11 18:21:43 2000
+@@ -854,7 +854,7 @@
+ fi
+ 
+ 
+-V_CCOPT="-O"
++V_CCOPT="-O2"
+ if test "$GCC" = yes ; then
+       echo $ac_n "checking gcc version""... $ac_c" 1>&6
+ echo "configure:861: checking gcc version" >&5
+diff -ur thttpd-2.19/libhttpd.c thttpd-2.19-php/libhttpd.c
+--- thttpd-2.19/libhttpd.c     Fri Jun 23 08:43:40 2000
++++ thttpd-2.19-php/libhttpd.c Tue Jul 11 18:36:01 2000
 @@ -75,6 +75,8 @@
  #include "match.h"
  #include "tdate_parse.h"
@@ -31,36 +63,44 @@
  #ifndef STDIN_FILENO
  #define STDIN_FILENO 0
  #endif
-@@ -211,7 +213,11 @@
-       free( (void*) hs->cwd );
-     if ( hs->cgi_pattern != (char*) 0 )
-       free( (void*) hs->cgi_pattern );
-+    if ( hs->php_pattern != (char*) 0 )
-+      free( (void *) hs->php_pattern );
+@@ -230,14 +232,18 @@
+       free( (void*) hs->url_pattern );
+     if ( hs->local_pattern != (char*) 0 )
+       free( (void*) hs->local_pattern );
++     if ( hs->php_pattern != (char*) 0 )
++      free( (void *) hs->php_pattern );
++
      free( (void*) hs );
-+      
 +    thttpd_php_shutdown();
      }
  
  
-@@ -244,6 +250,7 @@
-     else
-       hs->hostname = strdup( hostname );
+ httpd_server*
+ httpd_initialize(
+     char* hostname, httpd_sockaddr* sa4P, httpd_sockaddr* sa6P, int port,
+-    char* cgi_pattern, char* charset, char* cwd, FILE* logfp, int no_symlink,
++    char* cgi_pattern, char* php_pattern, char* charset, char* cwd, FILE* logfp, int no_symlink,
+     int vhost, char* url_pattern, char* local_pattern, int no_empty_referers )
+     {
+     httpd_server* hs;
+@@ -291,6 +297,7 @@
+       }
+ 
      hs->port = port;
-+    hs->php_pattern = strdup("*.php");
++    hs->php_pattern = strdup("*.php*");
      if ( cgi_pattern == (char*) 0 )
        hs->cgi_pattern = (char*) 0;
      else
-@@ -272,6 +279,8 @@
-     hs->no_symlinks = no_symlinks;
-     hs->vhost = vhost;
+@@ -379,6 +386,8 @@
+     int listen_fd;
+     int on, flags;
  
 +    thttpd_php_init();
 +
      /* Create socket. */
-     hs->listen_fd = socket( AF_INET, SOCK_STREAM, 0 );
-     if ( hs->listen_fd < 0 )
-@@ -3129,6 +3138,11 @@
+     listen_fd = socket( saP->sa.sa_family, SOCK_STREAM, 0 );
+     if ( listen_fd < 0 )
+@@ -3302,6 +3311,11 @@
         ( hc->sb.st_mode & S_IXOTH ) &&
         match( hc->hs->cgi_pattern, hc->expnfilename ) )
        return cgi( hc );
@@ -72,14 +112,154 @@
  
      /* It's not CGI.  If it's executable or there's pathinfo, someone's
      ** trying to either serve or run a non-CGI file as CGI.   Either case
-diff -ur thttpd-2.10/libhttpd.h thttpd-2.10-php/libhttpd.h
---- thttpd-2.10/libhttpd.h     Wed Dec  8 19:53:34 1999
-+++ thttpd-2.10-php/libhttpd.h Mon Dec 20 01:06:09 1999
-@@ -57,6 +57,7 @@
-     struct in_addr host_addr;
+diff -ur thttpd-2.19/libhttpd.h thttpd-2.19-php/libhttpd.h
+--- thttpd-2.19/libhttpd.h     Tue Jun 13 23:48:56 2000
++++ thttpd-2.19-php/libhttpd.h Tue Jul 11 12:45:45 2000
+@@ -69,6 +69,7 @@
+     char* server_hostname;
      int port;
      char* cgi_pattern;
 +    char* php_pattern;
+     char* charset;
      char* cwd;
-     int listen_fd;
-     FILE* logfp;
+     int listen4_fd, listen6_fd;
+@@ -160,7 +161,7 @@
+ */
+ extern httpd_server* httpd_initialize(
+     char* hostname, httpd_sockaddr* sa4P, httpd_sockaddr* sa6P, int port,
+-    char* cgi_pattern, char* charset, char* cwd, FILE* logfp, int no_symlink,
++    char* cgi_pattern, char* php_pattern, char* charset, char* cwd, FILE* logfp, int no_symlink,
+     int vhost, char* url_pattern, char* local_pattern, int no_empty_referers );
+ 
+ /* Change the log file. */
+diff -ur thttpd-2.19/match.c thttpd-2.19-php/match.c
+--- thttpd-2.19/match.c        Sat Mar 18 21:15:57 2000
++++ thttpd-2.19-php/match.c    Tue Jul 11 17:47:43 2000
+@@ -32,57 +32,63 @@
+ 
+ #include "match.h"
+ 
+-static int match_one( const char* pattern, int patternlen, const char* string );
++/************************************************************************/
++/* strmatch - matches two strings                                     */
++/*                                                                    */
++/* Author: Marcus E. Hennecke <marcush@leland.stanford.edu>           */
++/* Copyright (C) 1995 by Marcus E. Hennecke                           */
++/* This program is free software; you can redistribute it and/or modify       */
++/* it under the terms of the GNU General Public License as published by       */
++/* the Free Software Foundation; either version 2 of the License, or  */
++/* (at your option) any later version.                                        */
++/*                                                                    */
++/* This program is distributed in the hope that it will be useful,    */
++/* but WITHOUT ANY WARRANTY; without even the implied warranty of     */
++/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the      */
++/* GNU General Public License for more details.                               */
++/* You should have received a copy of the GNU General Public License  */
++/* along with this program; if not, write to the Free Software                */
++/* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.          */
++/************************************************************************/
+ 
+-int
+-match( const char* pattern, const char* string )
+-    {
+-    const char* or;
++int match(const char *pattern,const char *string)
++{
++    const char *ssubstart = NULL, *psubstart = NULL;
++    char sch, pch;
+ 
+-    for (;;)
++    for (; (sch = *string); string++, pattern++)
++    {
++      pch = *pattern;
++      if (pch == '*')
+       {
+-      or = strchr( pattern, '|' );
+-      if ( or == (char*) 0 )
+-          return match_one( pattern, strlen( pattern ), string );
+-      if ( match_one( pattern, or - pattern, string ) )
+-          return 1;
+-      pattern = or + 1;
++          ssubstart = string;
++          do
++          {
++              psubstart = pattern;
++              pch = *++pattern;
++          }
++          while (pch == '*');
++          if (pch == '\0')
++              return 1;
+       }
+-    }
+ 
++      if (pch == '?')
++          continue;
+ 
+-static int
+-match_one( const char* pattern, int patternlen, const char* string )
+-    {
+-    const char* p;
++      if (pch == '\\')
++          pch = *++pattern;
+ 
+-    for ( p = pattern; p - pattern < patternlen; ++p, ++string )
+-      {
+-      if ( *p == '?' && *string != '\0' )
++      if (pch == sch)
+           continue;
+-      if ( *p == '*' )
+-          {
+-          int i, pl;
+-          ++p;
+-          if ( *p == '*' )
+-              {
+-              /* Double-wildcard matches anything. */
+-              ++p;
+-              i = strlen( string );
+-              }
+-          else
+-              /* Single-wildcard matches anything but slash. */
+-              i = strcspn( string, "/" );
+-          pl = patternlen - ( p - pattern );
+-          for ( ; i >= 0; --i )
+-              if ( match_one( p, pl, &(string[i]) ) )
+-                  return 1;
+-          return 0;
+-          }
+-      if ( *p != *string )
++
++      if (psubstart == NULL)
+           return 0;
+-      }
+-    if ( *string == '\0' )
+-      return 1;
+-    return 0;
++
++      pattern = psubstart;
++      string = ssubstart++;
+     }
++
++    while (*pattern == '*')
++      pattern++;
++    return (*pattern == '\0');
++}
+diff -ur thttpd-2.19/thttpd.c thttpd-2.19-php/thttpd.c
+--- thttpd-2.19/thttpd.c       Fri Jun 23 23:37:50 2000
++++ thttpd-2.19-php/thttpd.c   Tue Jul 11 12:48:50 2000
+@@ -66,6 +66,7 @@
+ static char* dir;
+ static int do_chroot, no_symlink, do_vhost;
+ static char* cgi_pattern;
++static char* php_pattern;
+ static char* url_pattern;
+ static int no_empty_referers;
+ static char* local_pattern;
+@@ -398,7 +399,7 @@
+     hs = httpd_initialize(
+       hostname,
+       gotv4 ? &sa4 : (httpd_sockaddr*) 0, gotv6 ? &sa6 : (httpd_sockaddr*) 0,
+-      port, cgi_pattern, charset, cwd, logfp, no_symlink, do_vhost,
++      port, cgi_pattern, php_pattern, charset, cwd, logfp, no_symlink, do_vhost,
+       url_pattern, local_pattern, no_empty_referers );
+     if ( hs == (httpd_server*) 0 )
+       exit( 1 );

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-08-07 10:30 UTC] sas@php.net
Fixed in CVS. Please wait until PHP 4.0.2 gets released or use a snapshot from 

http://snaps.php.net/

Thanks for your report.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 27 16:01:29 2024 UTC