You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Aaron Bannert <aa...@clove.org> on 2001/10/09 19:44:39 UTC

[PATCH] add LoadModule directives for each built DSO to httpd.conf

This patch fixes a recent showstopper. A makefile variable has been
created to collect the names of all modules which were built as DSOs.
I've broken the sed substitution into phases so I could insert multiple
LoadModule lines into the resultant config file:

 1) do normal sed substitution until we find a @@LoadModule@@ string.
 2) if the string was found, print out formatted LoadModule lines,
    and then perform sed substitution on any lines following the first
    @@LoadModule@@ string.

Input config files containing no @@LoadModule@@ lines are not otherwise
affected. Input files containing more than one @@LoadModule@@ line will
only have LoadModule lines inserted for the first instance, and the other
@@LoadModule@@ lines will be simply removed.

I've tested this on Solaris8 (which has strict old-school sed syntax).

** I am by no means an experienced sed/borne shell user, so if anyone has
a better way of doing this, I'd love to hear it. I spent quite a long time
playing with the various levels of shell interpolation and this was the
only way I could get multiline insertions to work with generic sed called
in a borne shell script called in a makefile generated by autoconf. :)

-aaron


Index: acinclude.m4
===================================================================
RCS file: /home/cvspublic/httpd-2.0/acinclude.m4,v
retrieving revision 1.102
diff -u -r1.102 acinclude.m4
--- acinclude.m4	2001/10/03 17:47:50	1.102
+++ acinclude.m4	2001/10/09 17:22:57
@@ -94,6 +94,7 @@
   APACHE_SUBST(SH_LIBTOOL)
   APACHE_SUBST(MK_IMPLIB)
   APACHE_SUBST(INSTALL_PROG_FLAGS)
+  APACHE_SUBST(DSO_MODULES)
 
   abs_srcdir="`(cd $srcdir && pwd)`"
 
@@ -259,7 +260,9 @@
     shared*)
       enable_$1=`echo $ac_n $enable_$1$ac_c|sed 's/shared,*//'`
       sharedobjs=yes
-      shared=yes;;
+      shared=yes
+      DSO_MODULES="$DSO_MODULES $1"
+      ;;
     *)
       MODLIST="$MODLIST ifelse($4,,$1,$4)"
       if test "$1" = "so"; then
Index: Makefile.in
===================================================================
RCS file: /home/cvspublic/httpd-2.0/Makefile.in,v
retrieving revision 1.87
diff -u -r1.87 Makefile.in
--- Makefile.in	2001/10/08 10:15:37	1.87
+++ Makefile.in	2001/10/09 17:22:57
@@ -36,9 +36,24 @@
 	done; \
 	for i in *-std* ldap.conf proxy.conf ssl.conf; do \
 		[ -f $$i ] || continue; \
-		sed -e 's#@@ServerRoot@@#$(prefix)#g' \
-		    -e 's#@@Port@@#$(PORT)#g' \
-			< $$i > $(sysconfdir)/$$i; \
+		( \
+			sed -n -e '/@@LoadModule@@/q' \
+				-e 's#@@ServerRoot@@#$(prefix)#g' \
+				-e 's#@@Port@@#$(PORT)#g' \
+				-e 'p' \
+				< $$i; \
+			n_lm=`awk '/@@LoadModule@@/ {n+=1} END {print n}' < $$i`; \
+			if test $$n_lm -gt 0 -a "x$(DSO_MODULES)" != "x"; then \
+				for j in $(DSO_MODULES); do \
+					echo "LoadModule $${j}_module modules/mod_$${j}.so"; \
+				done; \
+				sed -e '1,/@@LoadModule@@/d' \
+					-e '/@@LoadModule@@/d' \
+					-e 's#@@ServerRoot@@#$(prefix)#g' \
+					-e 's#@@Port@@#$(PORT)#g' \
+					< $$i; \
+			fi \
+		) > $(sysconfdir)/$$i; \
 		chmod 0644 $(sysconfdir)/$$i; \
 		file=`echo $$i|sed s/-std//`; \
 		if [ "$$file" = "httpd.conf" ]; then \
Index: STATUS
===================================================================
RCS file: /home/cvspublic/httpd-2.0/STATUS,v
retrieving revision 1.301
diff -u -r1.301 STATUS
--- STATUS	2001/10/09 03:11:08	1.301
+++ STATUS	2001/10/09 17:22:58
@@ -89,10 +89,6 @@
       to make it agree with the operation of the StartServers
       directive.
 
-    * Fix the configure script to add a LoadModule directive to
-      the default httpd.conf for any module that was compiled
-      as a DSO.
-
     * revamp the input filter semantics, per discussions since
       February (and especially at the hackathon last
       April). Specifically, ap_get_brigade will return a brigade with
Index: CHANGES
===================================================================
RCS file: /home/cvspublic/httpd-2.0/CHANGES,v
retrieving revision 1.383
diff -u -r1.383 CHANGES
--- CHANGES	2001/10/09 02:40:56	1.383
+++ CHANGES	2001/10/09 17:23:11
@@ -1,5 +1,9 @@
 Changes with Apache 2.0.26-dev
 
+  *) Fixed the configure script to add a LoadModule directive to
+     the default httpd.conf for any module that was compiled
+     as a DSO.       [Aaron Bannert <aa...@clove.org>]
+
   *) Introduce ap_directory_walk rewrite (with further optimizations
      required) to adapt to the ap_process_request_internal() changes.
      Optimized so subrequests and redirects now reuse previous section 
Index: docs/conf/httpd-std.conf
===================================================================
RCS file: /home/cvspublic/httpd-2.0/docs/conf/httpd-std.conf,v
retrieving revision 1.56
diff -u -r1.56 httpd-std.conf
--- docs/conf/httpd-std.conf	2001/10/05 03:32:42	1.56
+++ docs/conf/httpd-std.conf	2001/10/09 17:23:12
@@ -193,6 +193,7 @@
 # Statically compiled modules (those listed by `httpd -l') do not need
 # to be loaded here.
 #
+@@LoadModule@@
 #LoadModule auth_anon_module modules/mod_auth_anon.so
 #LoadModule auth_db_module modules/mod_auth_db.so
 #LoadModule auth_dbm_module modules/mod_auth_dbm.so

Re: [PATCH] add LoadModule directives for each built DSO to httpd.conf

Posted by Ryan Bloom <rb...@covalent.net>.
On Tuesday 09 October 2001 10:44 am, Aaron Bannert wrote:

This doesn't work for me.

The error is simple enough, but I don't have the energy to parse the 
command to figure out why it is happening.

/bin/sh: -c: line 1: syntax error near unexpected token `;'  

This is on Linux.

Ryan


> This patch fixes a recent showstopper. A makefile variable has been
> created to collect the names of all modules which were built as DSOs.
> I've broken the sed substitution into phases so I could insert multiple
> LoadModule lines into the resultant config file:
>
>  1) do normal sed substitution until we find a @@LoadModule@@ string.
>  2) if the string was found, print out formatted LoadModule lines,
>     and then perform sed substitution on any lines following the first
>     @@LoadModule@@ string.
>
> Input config files containing no @@LoadModule@@ lines are not otherwise
> affected. Input files containing more than one @@LoadModule@@ line will
> only have LoadModule lines inserted for the first instance, and the other
> @@LoadModule@@ lines will be simply removed.
>
> I've tested this on Solaris8 (which has strict old-school sed syntax).
>
> ** I am by no means an experienced sed/borne shell user, so if anyone has
> a better way of doing this, I'd love to hear it. I spent quite a long time
> playing with the various levels of shell interpolation and this was the
> only way I could get multiline insertions to work with generic sed called
> in a borne shell script called in a makefile generated by autoconf. :)

Ryan
______________________________________________________________
Ryan Bloom				rbb@apache.org
Covalent Technologies			rbb@covalent.net
--------------------------------------------------------------

Re: [PATCH] add LoadModule directives for each built DSO to httpd.conf

Posted by Aaron Bannert <aa...@clove.org>.
[second posting, snafu(s) fixed]

> > This patch fixes a recent showstopper. A makefile variable has been
> > created to collect the names of all modules which were built as DSOs.
> > I've broken the sed substitution into phases so I could insert multiple
> > LoadModule lines into the resultant config file:
> > 
> >  1) do normal sed substitution until we find a @@LoadModule@@ string.
> >  2) if the string was found, print out formatted LoadModule lines,
> >     and then perform sed substitution on any lines following the first
> >     @@LoadModule@@ string.
> > 
> > Input config files containing no @@LoadModule@@ lines are not otherwise
> > affected. Input files containing more than one @@LoadModule@@ line will
> > only have LoadModule lines inserted for the first instance, and the other
> > @@LoadModule@@ lines will be simply removed.
> > 
> > I've tested this on Solaris8 (which has strict old-school sed syntax).
> > 
> > ** I am by no means an experienced sed/borne shell user, so if anyone has
> > a better way of doing this, I'd love to hear it. I spent quite a long time
> > playing with the various levels of shell interpolation and this was the
> > only way I could get multiline insertions to work with generic sed called
> > in a borne shell script called in a makefile generated by autoconf. :)

I tested --enable-mods-shared=most and it now will start with the default
httpd.conf. My other test case was just a simple ./configure --prefix
and that also seems to work. In both cases I verified that the other
filtered files were otherwise unaffected by these new changes.

-aaron


Index: docs/conf/httpd-std.conf
===================================================================
RCS file: /home/cvspublic/httpd-2.0/docs/conf/httpd-std.conf,v
retrieving revision 1.56
diff -u -r1.56 httpd-std.conf
--- docs/conf/httpd-std.conf	2001/10/05 03:32:42	1.56
+++ docs/conf/httpd-std.conf	2001/10/10 19:41:09
@@ -193,6 +193,7 @@
 # Statically compiled modules (those listed by `httpd -l') do not need
 # to be loaded here.
 #
+@@LoadModule@@
 #LoadModule auth_anon_module modules/mod_auth_anon.so
 #LoadModule auth_db_module modules/mod_auth_db.so
 #LoadModule auth_dbm_module modules/mod_auth_dbm.so
Index: acinclude.m4
===================================================================
RCS file: /home/cvspublic/httpd-2.0/acinclude.m4,v
retrieving revision 1.102
diff -u -r1.102 acinclude.m4
--- acinclude.m4	2001/10/03 17:47:50	1.102
+++ acinclude.m4	2001/10/10 19:41:09
@@ -94,6 +94,7 @@
   APACHE_SUBST(SH_LIBTOOL)
   APACHE_SUBST(MK_IMPLIB)
   APACHE_SUBST(INSTALL_PROG_FLAGS)
+  APACHE_SUBST(DSO_MODULES)
 
   abs_srcdir="`(cd $srcdir && pwd)`"
 
@@ -259,7 +260,9 @@
     shared*)
       enable_$1=`echo $ac_n $enable_$1$ac_c|sed 's/shared,*//'`
       sharedobjs=yes
-      shared=yes;;
+      shared=yes
+      DSO_MODULES="$DSO_MODULES $1"
+      ;;
     *)
       MODLIST="$MODLIST ifelse($4,,$1,$4)"
       if test "$1" = "so"; then
Index: Makefile.in
===================================================================
RCS file: /home/cvspublic/httpd-2.0/Makefile.in,v
retrieving revision 1.87
diff -u -r1.87 Makefile.in
--- Makefile.in	2001/10/08 10:15:37	1.87
+++ Makefile.in	2001/10/10 19:41:10
@@ -36,9 +36,31 @@
 	done; \
 	for i in *-std* ldap.conf proxy.conf ssl.conf; do \
 		[ -f $$i ] || continue; \
-		sed -e 's#@@ServerRoot@@#$(prefix)#g' \
-		    -e 's#@@Port@@#$(PORT)#g' \
-			< $$i > $(sysconfdir)/$$i; \
+		( \
+			n_lm=`awk 'BEGIN {n=0} /@@LoadModule@@/ {n+=1} END {print n}' < $$i`; \
+			if test $$n_lm -eq 0 -o "x$(DSO_MODULES)" = "x"; then \
+				sed -e 's#@@ServerRoot@@#$(prefix)#g' \
+					-e 's#@@Port@@#$(PORT)#g' \
+					-e '/@@LoadModule@@/d' \
+					< $$i; \
+			else \
+				sed -n -e '/@@LoadModule@@/q' \
+					-e 's#@@ServerRoot@@#$(prefix)#g' \
+					-e 's#@@Port@@#$(PORT)#g' \
+					-e 'p' \
+					< $$i; \
+				for j in $(DSO_MODULES) "^EOL^"; do \
+					if test $$j != "^EOL^"; then \
+						echo "LoadModule $${j}_module modules/mod_$${j}.so"; \
+					fi; \
+				done; \
+				sed -e '1,/@@LoadModule@@/d' \
+					-e '/@@LoadModule@@/d' \
+					-e 's#@@ServerRoot@@#$(prefix)#g' \
+					-e 's#@@Port@@#$(PORT)#g' \
+					< $$i; \
+			fi \
+		) > $(sysconfdir)/$$i; \
 		chmod 0644 $(sysconfdir)/$$i; \
 		file=`echo $$i|sed s/-std//`; \
 		if [ "$$file" = "httpd.conf" ]; then \
Index: CHANGES
===================================================================
RCS file: /home/cvspublic/httpd-2.0/CHANGES,v
retrieving revision 1.386
diff -u -r1.386 CHANGES
--- CHANGES	2001/10/10 15:12:12	1.386
+++ CHANGES	2001/10/10 19:41:23
@@ -1,5 +1,9 @@
 Changes with Apache 2.0.26-dev
 
+  *) Fixed the configure script to add a LoadModule directive to
+     the default httpd.conf for any module that was compiled
+     as a DSO.       [Aaron Bannert <aa...@clove.org>]
+
   *) prefork: Don't segfault when we are able to listen on some but
      not all of the configured ports.  [Jeff Trawick]
 
Index: STATUS
===================================================================
RCS file: /home/cvspublic/httpd-2.0/STATUS,v
retrieving revision 1.302
diff -u -r1.302 STATUS
--- STATUS	2001/10/09 19:29:19	1.302
+++ STATUS	2001/10/10 19:41:23
@@ -91,10 +91,6 @@
       to make it agree with the operation of the StartServers
       directive.
 
-    * Fix the configure script to add a LoadModule directive to
-      the default httpd.conf for any module that was compiled
-      as a DSO.
-
     * revamp the input filter semantics, per discussions since
       February (and especially at the hackathon last
       April). Specifically, ap_get_brigade will return a brigade with

Re: [PATCH] add LoadModule directives for each built DSO to httpd.conf

Posted by Aaron Bannert <aa...@clove.org>.
Shortly after posting this I discovered a slight problem. Please review
this submission and I will post the updated patch tomorrow morning (if
the list catches up by then ;).

-aaron


On Tue, Oct 09, 2001 at 10:44:39AM -0700, Aaron Bannert wrote:
> This patch fixes a recent showstopper. A makefile variable has been
> created to collect the names of all modules which were built as DSOs.
> I've broken the sed substitution into phases so I could insert multiple
> LoadModule lines into the resultant config file:
> 
>  1) do normal sed substitution until we find a @@LoadModule@@ string.
>  2) if the string was found, print out formatted LoadModule lines,
>     and then perform sed substitution on any lines following the first
>     @@LoadModule@@ string.
> 
> Input config files containing no @@LoadModule@@ lines are not otherwise
> affected. Input files containing more than one @@LoadModule@@ line will
> only have LoadModule lines inserted for the first instance, and the other
> @@LoadModule@@ lines will be simply removed.
> 
> I've tested this on Solaris8 (which has strict old-school sed syntax).
> 
> ** I am by no means an experienced sed/borne shell user, so if anyone has
> a better way of doing this, I'd love to hear it. I spent quite a long time
> playing with the various levels of shell interpolation and this was the
> only way I could get multiline insertions to work with generic sed called
> in a borne shell script called in a makefile generated by autoconf. :)

[...]

Re: [PATCH] add LoadModule directives for each built DSO to httpd.conf

Posted by Cliff Woolley <cl...@yahoo.com>.
On Wed, 10 Oct 2001, Aaron Bannert wrote:

> > I haven't tried building proxy in a while, so I'm assuming that
> > their module is like the above given the file name and the config
> > syntax - the APACHE_MODULE lines lead me to believe they are
> > separate modules.  I'll try it out later to be sure...  -- justin
>
> This is a legitimate problem for proxy and any other abnormally named
> module. We should either change their filename and module structure to
> match the pattern

ISTR that back when we started doing it this way, we decided that this
naming convention was the rule now and that we'd enforce it.  We renamed a
bunch of the core modules' structs to fit the pattern...

--Cliff

--------------------------------------------------------------
   Cliff Woolley
   cliffwoolley@yahoo.com
   Charlottesville, VA



Re: [PATCH] add LoadModule directives for each built DSO to httpd.conf

Posted by Aaron Bannert <aa...@clove.org>.
On Tue, Oct 09, 2001 at 10:24:01PM -0700, Justin Erenkrantz wrote:
> How do we handle proxy's proxy_connect, proxy_ftp, etc?
> 
> I think their lines should be:
> 
> LoadModule proxy_connect_module modules/proxy_connect_module.so
> 
> I'm not sure if we have a standard naming convention here that
> enforces $${j}_module and the mod_$${j} prefix.
> 
> I haven't tried building proxy in a while, so I'm assuming that
> their module is like the above given the file name and the config
> syntax - the APACHE_MODULE lines lead me to believe they are
> separate modules.  I'll try it out later to be sure...  -- justin

This is a legitimate problem for proxy and any other abnormally named
module. We should either change their filename and module structure to
match the pattern, or we'll have to design some configure.in parameter
and probably another APACHE_MODULE parameter for stating the name of the
module structure. I'm partial to the easy name fix, keeps things simple.

-aaron

Re: [PATCH] add LoadModule directives for each built DSO to httpd.conf

Posted by Justin Erenkrantz <je...@ebuilt.com>.
On Tue, Oct 09, 2001 at 10:44:39AM -0700, Aaron Bannert wrote:
> +			if test $$n_lm -gt 0 -a "x$(DSO_MODULES)" != "x"; then \
> +				for j in $(DSO_MODULES); do \
> +					echo "LoadModule $${j}_module modules/mod_$${j}.so"; \
> +				done; \

How do we handle proxy's proxy_connect, proxy_ftp, etc?

I think their lines should be:

LoadModule proxy_connect_module modules/proxy_connect_module.so

I'm not sure if we have a standard naming convention here that
enforces $${j}_module and the mod_$${j} prefix.

I haven't tried building proxy in a while, so I'm assuming that
their module is like the above given the file name and the config
syntax - the APACHE_MODULE lines lead me to believe they are
separate modules.  I'll try it out later to be sure...  -- justin