You are viewing a plain text version of this content. The canonical link for it is here.
Posted to rivet-dev@tcl.apache.org by vm...@apache.org on 2007/12/03 20:29:31 UTC

svn commit: r600639 - in /tcl/rivet/trunk: ./ src/apache-1/ src/apache-2/ tests/ tests/apachetest/ tests/logs/

Author: vmasutin
Date: Mon Dec  3 11:29:30 2007
New Revision: 600639

URL: http://svn.apache.org/viewvc?rev=600639&view=rev
Log:
* tests/apachetest/: multiple changes has been made to tests
to get them working with apache2
* src/apache-2/mod_rivet.c, src/apache-2/apache_multipart_buffer.c:
fixes for  issues that has been discovered with tests, mostly
there were problems with multipart buffer parsing during POST
* configure.ac: minor issue with apache includes handling has been
fixed

Added:
    tcl/rivet/trunk/tests/apachetest/template.conf.1.tcl
    tcl/rivet/trunk/tests/apachetest/template.conf.2.tcl
    tcl/rivet/trunk/tests/logs/
Removed:
    tcl/rivet/trunk/tests/apachetest/template.conf.tcl
Modified:
    tcl/rivet/trunk/ChangeLog
    tcl/rivet/trunk/configure.ac
    tcl/rivet/trunk/src/apache-1/Makefile.am
    tcl/rivet/trunk/src/apache-2/apache_multipart_buffer.c
    tcl/rivet/trunk/src/apache-2/mod_rivet.c
    tcl/rivet/trunk/tests/apachetest/apachetest.tcl
    tcl/rivet/trunk/tests/runtests.tcl

Modified: tcl/rivet/trunk/ChangeLog
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/ChangeLog?rev=600639&r1=600638&r2=600639&view=diff
==============================================================================
--- tcl/rivet/trunk/ChangeLog (original)
+++ tcl/rivet/trunk/ChangeLog Mon Dec  3 11:29:30 2007
@@ -1,3 +1,13 @@
+2007-12-03  Valery Masiutsin <va...@gmail.com>
+
+	* tests/apachetest/: multiple changes has been made to tests
+	to get them working with apache2
+	* src/apache-2/mod_rivet.c, src/apache-2/apache_multipart_buffer.c:
+	fixes for  issues that has been discovered with tests, mostly
+	there were problems with multipart buffer parsing during POST
+	* configure.ac: minor issue with apache includes handling has been
+	fixed
+
 2007-11-18  Massimo Manghi <ma...@unipr.it>
 
 	* doc/rivet.xml: note added to description of

Modified: tcl/rivet/trunk/configure.ac
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/configure.ac?rev=600639&r1=600638&r2=600639&view=diff
==============================================================================
--- tcl/rivet/trunk/configure.ac (original)
+++ tcl/rivet/trunk/configure.ac Mon Dec  3 11:29:30 2007
@@ -23,7 +23,7 @@
 #-----------------------------------------------------------------------
 
 AC_INIT([Rivet],[0.8.0])
-AM_CONFIG_HEADER(config.h)
+AC_CONFIG_HEADERS([config.h])
 
 #--------------------------------------------------------------------
 # Call TEA_INIT as the first TEA_ macro to set up initial vars.
@@ -31,6 +31,7 @@
 # as well as PKG_LIB_FILE and PKG_STUB_LIB_FILE.
 #--------------------------------------------------------------------
 
+
 TEA_INIT([3.6])
 
 AC_CONFIG_AUX_DIR(tclconfig)
@@ -307,8 +308,10 @@
   AC_ARG_WITH(
     apache_include,
     [  --with-apache-include[=DIR]     Apache server directory],
-    ,[apache_include="${APXS_INCLUDES}"]
+	 [apache_include="${with_apache_include}"] 
+	,[apache_include="${APXS_INCLUDES}"]
   )
+	AC_SUBST(apache_include)
 ])
 
 AC_DEFUN([APR_HANDLING],[
@@ -419,7 +422,6 @@
 APACHE_INCLUDES
 APR_HANDLING
 RIVET_TCL_LIB
-AC_SUBST(apache_include)
 AC_SUBST(apache_version_dir)
 
 AC_DEFINE_UNQUOTED(RIVETLIB_DESTDIR,"${RIVET_TCL_TARGET}",[The path to the rivet tcl library])

Modified: tcl/rivet/trunk/src/apache-1/Makefile.am
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/src/apache-1/Makefile.am?rev=600639&r1=600638&r2=600639&view=diff
==============================================================================
--- tcl/rivet/trunk/src/apache-1/Makefile.am (original)
+++ tcl/rivet/trunk/src/apache-1/Makefile.am Mon Dec  3 11:29:30 2007
@@ -38,7 +38,8 @@
 	TclWebapache.c \
 	../rivetCore.c \
 	../rivetChannel.c \
-	../rivetParser.c
+	../rivetParser.c \
+	../rivetWWW.c
 
 mod_rivet_la_LDFLAGS = @TCL_LIB_SPEC@ @APXS_LDFLAGS@ @APR_LDFLAGS@ -module -avoid-version
 mod_rivet_la_LIBADD = @TCL_LIBS@ @APXS_LIBS@

Modified: tcl/rivet/trunk/src/apache-2/apache_multipart_buffer.c
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/src/apache-2/apache_multipart_buffer.c?rev=600639&r1=600638&r2=600639&view=diff
==============================================================================
--- tcl/rivet/trunk/src/apache-2/apache_multipart_buffer.c (original)
+++ tcl/rivet/trunk/src/apache-2/apache_multipart_buffer.c Mon Dec  3 11:29:30 2007
@@ -40,9 +40,9 @@
     while( (ptr = memchr(ptr, needle[0], len)) ) {
 	/* calculate length after match */
 	len = haystacklen - (ptr - (char *)haystack);
-
+	 ;
 	/* done if matches up to capacity of buffer */
-	if(memcmp(needle, ptr, needlen < len ? needlen : len) == 0 &&
+	if(memcmp(needle, ptr, needlen) == 0 &&
 	   (partial || len >= needlen))
 	    break;
 
@@ -190,7 +190,7 @@
     self->bufsize = minsize;
     self->request_length = length;
     self->boundary = (char*) apr_pstrcat(r->pool, "--", boundary, NULL);
-    self->boundary_next = (char*) apr_pstrcat(r->pool, "\n", self->boundary, NULL);
+    self->boundary_next = (char*) apr_pstrcat(r->pool, "\n", self->boundary+2, NULL);
     self->buf_begin = self->buffer;
     self->bytes_in_buffer = 0;
 
@@ -254,13 +254,15 @@
 
     /* look for a potential boundary match, only read data up to that point */
     if( (bound = my_memstr(self->buf_begin, self->bytes_in_buffer,
-			   self->boundary_next, 1)) )
-	max = bound - self->buf_begin;
-    else
+			   self->boundary_next, 1)) ) {
+	max = bound - self->buf_begin - 1 ;
+	self->bytes_in_buffer=max+1;
+     } else {
 	max = self->bytes_in_buffer;
-
+     }
     /* maximum number of bytes we are reading */
     len = max < bytes-1 ? max : bytes-1;
+
 
     /* if we read any data... */
     if(len > 0) {

Modified: tcl/rivet/trunk/src/apache-2/mod_rivet.c
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/src/apache-2/mod_rivet.c?rev=600639&r1=600638&r2=600639&view=diff
==============================================================================
--- tcl/rivet/trunk/src/apache-2/mod_rivet.c (original)
+++ tcl/rivet/trunk/src/apache-2/mod_rivet.c Mon Dec  3 11:29:30 2007
@@ -682,9 +682,8 @@
 {
     rivet_server_conf *rsc = RIVET_SERVER_CONF( r->server->module_config );
     void *dconf = r->per_dir_config;
-    //rivet_server_conf *newconfig = NULL;
-    //rivet_server_conf *rdc;
-    //int tst;
+    rivet_server_conf *newconfig = NULL;
+    rivet_server_conf *rdc;
     
     FILEDEBUGINFO;
 
@@ -692,9 +691,7 @@
     if (dconf == NULL) {
         return rsc;
     }
-    return rsc;
-/*
-    rdc = RIVET_SERVER_CONF( dconf );
+    rdc = RIVET_SERVER_CONF( dconf ); 
     
     newconfig = RIVET_NEW_CONF( r->pool );
 
@@ -703,7 +700,6 @@
     Rivet_MergeDirConfigVars( r->pool, newconfig, rsc, rdc );
 
     return newconfig;
- */
 }
 
 static void *

Modified: tcl/rivet/trunk/tests/apachetest/apachetest.tcl
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/tests/apachetest/apachetest.tcl?rev=600639&r1=600638&r2=600639&view=diff
==============================================================================
--- tcl/rivet/trunk/tests/apachetest/apachetest.tcl (original)
+++ tcl/rivet/trunk/tests/apachetest/apachetest.tcl Mon Dec  3 11:29:30 2007
@@ -34,9 +34,14 @@
 
     # name of the apache binary, such as /usr/sbin/httpd
     variable binname ""
+	if ![info exists ::httpd_version ] {
+    	puts stderr "Please create httpd_version variable in global namespace"
+	    exit 1
+	} 
+	variable httpd_version  $::httpd_version
     # this file should be in the same directory this script is.
     variable templatefile [file join [file dirname [info script]] \
-			       template.conf.tcl]
+			       template.conf.$httpd_version\.tcl]
 }
 
 # apachetest::need_modules --
@@ -105,6 +110,7 @@
     variable serverpid 0
     variable binname
     variable debug
+    variable httpd_version
 
     set fn [file join [pwd] test.conf]
     catch {file delete -force $fn}
@@ -112,27 +118,34 @@
     puts $fl [uplevel [list subst $conftext]]
     close $fl
 
+    #OpenBSD related workaround, their stock apache tries to chroot by default
+    #have to  add -u to the arguments to prevent this
+    catch {exec uname} uname_str
+    if {[string equal $uname_str OpenBSD] && $httpd_version == 1 } {
+        set server_args "-u -X -f"
+    } else {
+        set server_args "-X -f"
+    }
     # There has got to be a better way to do this, aside from waiting.
-    set serverpid [eval exec  $binname -X -f \
-		       [file join [pwd] server.conf] $options >& apachelog.txt &]
-
+    set serverpid [eval exec  $binname $server_args \
+	       [file join [pwd] server.conf] $options >& apachelog.txt &] 
     apachetest::connect
     if { $debug > 0 } {
-	puts "Apache started as PID $serverpid"
+	    puts "Apache started as PID $serverpid"
     }
     if { [catch {
 	uplevel $code
     } err] } {
-	puts $err
     }
     # Kill and wait are the only reasons we need TclX.
-    kill $serverpid
+    # apache2 binary started with -X reacts to SIGQUIT and ignores TERM
+    kill QUIT $serverpid 
     catch {
-	set waitres [wait $serverpid]
-	if { $debug > 0 } {
-	    puts $waitres
-	}
-    }
+        set waitres [wait $serverpid]
+        if { $debug > 0 } {
+            puts $waitres
+        }
+    } 
 }
 
 # startserver - start the server with 'options'.
@@ -225,28 +238,34 @@
 #	Text of configuration files.
 
 proc apachetest::getallincludes { conffile } {
-    set fl [open $conffile r]
-    set data [read $fl]
-    close $fl
-
-    set newdata {}
-    foreach line [split $data \n] {
-	# Look for Include lines.
-	if { [regexp -line {^[^\#]*Include +(.*)} $line match file] } {
-	    set file [string trim $file]
-	    # Since directories may be included, glob them for all
-	    # files contained therein.
-	    if { [file isdirectory $file] } {
-		foreach fl [glob -nocomplain [file join $file *]] {
-		    append newdata [getallincludes $fl]
+    if [file  exists $conffile] {
+	    set fl [open $conffile r]
+	    set data [read $fl]
+	    close $fl
+
+	    set newdata {}
+	    foreach line [split $data \n] {
+		# Look for Include lines.
+		if { [regexp -line {^[^\#]*Include +(.*)} $line match file] } {
+		    set file [string trim $file]
+		    # Since directories may be included, glob them for all
+		    # files contained therein.
+		    if { [file isdirectory $file] } {
+			foreach fl [glob -nocomplain [file join $file *]] {
+			    if [file  exists $fl] {
+				    append newdata [getallincludes $fl]
+			    }
+			}
+		    } else {
+			append newdata [getallincludes $file]
+		    }
 		}
-	    } else {
-		append newdata [getallincludes $file]
 	    }
-	}
-    }
-    append data $newdata
-    return $data
+	    append data $newdata
+	    return $data
+   } else {
+	return
+   }
 }
 
 # apachetest::getloadmodules --
@@ -267,14 +286,24 @@
 proc apachetest::getloadmodules { conffile needtoget } {
     set confdata [getallincludes $conffile]
     set loadline [list]
+    regexp -line {^[^#]*(ServerRoot[\s]?[\"]?)([^\"]+)()([\"]?)} $confdata \
+    match sub1 server_root_path sub2 
     foreach mod $needtoget {
-	# Look for LoadModule lines.
-	if { ! [regexp -line "^\[^\#\]*(LoadModule\\s+$mod\\s+.+)\$"\
-		    $confdata match line] } {
-	    error "No LoadModule line for $mod!"
-	} else {
-	    lappend loadline $line
-	}
+    	# Look for LoadModule lines.
+        if { ! [regexp -line "^\[^\#\]*(LoadModule\\s+$mod\\s+.+)\$"\
+                $confdata match line] } {
+            error "No LoadModule line for $mod!"
+        } else {
+			set raw_path [join [lrange [split $line { }] 2 end]]
+			#trimming leading whitespaces
+			set path [string trimleft $raw_path]
+            if ![string equal [file pathtype $line] "absolute"] {
+                set absolute_path [file join $server_root_path $path]
+                lappend loadline "[join [lrange [split $line " "]  0 1]] $absolute_path"
+            } else {
+                lappend loadline $line
+            }
+        }
     }
     return [join $loadline "\n"]
 }
@@ -322,6 +351,11 @@
     variable binname
     variable templatefile
     set CWD [pwd]
+
+    #getting uid and gid of user
+    catch {exec id} raw_string		
+    set username  [lindex [regexp -inline {(uid=)([\d]+)(\()([^\)]+)(\))} $raw_string]  4]
+    set group  [lindex [regexp -inline {(groups=)([\d]+)(\()([^\)]+)(\))} $raw_string]  4]
 
     # replace with determinemodules
     set LOADMODULES [determinemodules $binname]

Added: tcl/rivet/trunk/tests/apachetest/template.conf.1.tcl
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/tests/apachetest/template.conf.1.tcl?rev=600639&view=auto
==============================================================================
--- tcl/rivet/trunk/tests/apachetest/template.conf.1.tcl (added)
+++ tcl/rivet/trunk/tests/apachetest/template.conf.1.tcl Mon Dec  3 11:29:30 2007
@@ -0,0 +1,45 @@
+# \$Id\$
+# Minimal config file for testing
+
+# Parsed by makeconf.tcl
+
+ServerRoot "$CWD"
+
+PidFile "$CWD/httpd.pid"
+
+ResourceConfig "$CWD/srm.conf"
+AccessConfig "$CWD/access.conf"
+
+Timeout 300
+
+MaxRequestsPerChild 0
+
+$LOADMODULES
+
+Port 8081
+
+ServerName localhost
+
+DocumentRoot "$CWD"
+
+<Directory "$CWD">
+Options All MultiViews
+AllowOverride All
+Order allow,deny
+Allow from all
+</Directory>
+
+<IfModule mod_dir.c>
+DirectoryIndex index.html
+</IfModule>
+
+AccessFileName .htaccess
+
+HostnameLookups Off
+
+ErrorLog $CWD/error_log
+
+LogLevel debug
+
+LogFormat "%h %l %u %t \\"%r\\" %>s %b \\"%{Referer}i\\" \\"%{User-Agent}i\\"" combined
+CustomLog "$CWD/access_log" combined

Added: tcl/rivet/trunk/tests/apachetest/template.conf.2.tcl
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/tests/apachetest/template.conf.2.tcl?rev=600639&view=auto
==============================================================================
--- tcl/rivet/trunk/tests/apachetest/template.conf.2.tcl (added)
+++ tcl/rivet/trunk/tests/apachetest/template.conf.2.tcl Mon Dec  3 11:29:30 2007
@@ -0,0 +1,46 @@
+# \$Id\$
+# Minimal config file for testing
+
+# Parsed by makeconf.tcl
+
+ServerRoot "$CWD"
+
+PidFile "$CWD/httpd.pid"
+
+#ResourceConfig "$CWD/srm.conf"
+#AccessConfig "$CWD/access.conf"
+
+Timeout 300
+KeepAliveTimeout 100
+KeepAlive On
+MaxRequestsPerChild 0
+
+$LOADMODULES
+
+Listen 8081
+
+ServerName localhost
+
+DocumentRoot "$CWD"
+
+<Directory "$CWD">
+Options All MultiViews
+AllowOverride All
+Order allow,deny
+Allow from all
+</Directory>
+
+<IfModule mod_dir.c>
+DirectoryIndex index.html
+</IfModule>
+
+AccessFileName .htaccess
+
+HostnameLookups Off
+
+ErrorLog $CWD/error_log
+
+LogLevel debug
+
+LogFormat "%h %l %u %t \\"%r\\" %>s %b \\"%{Referer}i\\" \\"%{User-Agent}i\\"" combined
+CustomLog "$CWD/access_log" combined

Modified: tcl/rivet/trunk/tests/runtests.tcl
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/tests/runtests.tcl?rev=600639&r1=600638&r2=600639&view=diff
==============================================================================
--- tcl/rivet/trunk/tests/runtests.tcl (original)
+++ tcl/rivet/trunk/tests/runtests.tcl Mon Dec  3 11:29:30 2007
@@ -18,18 +18,33 @@
 
 # $Id$
 
+
 set auto_path [linsert $auto_path 0 [file join [file dirname [info script]] apachetest]]
-package require apachetest
+
 
 proc runtests_usage {} {
     puts stderr "Usage: $::argv0 /path/to/apache/httpd ?startserver?"
     exit 1
 }
 
+proc get_httpd_version {httpd} {
+	catch {exec $httpd -v} raw_string
+	set version  [lindex [regexp -inline {([0-9]{1,}\.[0-9]{1,}\.[0-9]{1,})} $raw_string]  1]
+	if [string match "1.3.*" $version] {
+		return 1
+	} else {
+		return 2
+	}
+}
+
 if { [llength $argv] < 1 } {
     runtests_usage
+} else {
+	set httpd_version [get_httpd_version  [lindex $argv 0]]
 }
 
+package require apachetest
+
 if { [encoding system] eq "utf-8" } {
     puts stderr {
 	System encoding is utf-8 - this is known to cause problems
@@ -46,17 +61,31 @@
     runtests_usage
 }
 
-apachetest::need_modules {
-    {mod_log_config	  config_log_module}
-    {mod_mime		mime_module}
-    {mod_negotiation	 negotiation_module}
-    {mod_dir		         dir_module}
-    {mod_access	      access_module}
-    {mod_auth		auth_module}
+
+if {$httpd_version == 1} {
+	apachetest::need_modules {
+		{mod_log_config		config_log_module}
+		{mod_mime			mime_module}
+		{mod_negotiation	negotiation_module}
+		{mod_dir			dir_module}
+		{mod_auth			auth_module}
+		{mod_access			access_module}
+	}
+} else {
+	apachetest::need_modules {
+		{mod_mime           mime_module}
+		{mod_negotiation    negotiation_module}
+		{mod_dir            dir_module}
+		{mod_log_config     log_config_module}
+		{mod_authz_host     authz_host_module}
+	}
 }
 
 apachetest::makeconf server.conf {
-    LoadModule rivet_module [file join $CWD .. src .libs mod_rivet[info sharedlibextension]]
+    LoadModule rivet_module [file join $CWD .. src/apache-$apachetest::httpd_version .libs mod_rivet[info sharedlibextension]]
+
+    User $username
+    Group $group
 
     <IfModule mod_mime.c>
     TypesConfig $CWD/mime.types
@@ -67,7 +96,6 @@
     AddType application/x-rivet-tcl .tcl
     </IfModule>
 
-    RivetServerConf UploadFilesToVar on
 
     <IfDefine SERVERCONFTEST>
     RivetServerConf BeforeScript 'puts "Page Header"'
@@ -87,7 +115,6 @@
     # For testing, we want core dumps.
     CoreDumpDirectory $CWD
 }
-
 # Copy the rivet init files.
 file delete -force rivet
 file copy -force [file join .. rivet] .



---------------------------------------------------------------------
To unsubscribe, e-mail: rivet-cvs-unsubscribe@tcl.apache.org
For additional commands, e-mail: rivet-cvs-help@tcl.apache.org