]> granicus.if.org Git - apache/commitdiff
insert LoadModule directives only outside of sections.
authorAndre Malo <nd@apache.org>
Wed, 19 Feb 2003 03:01:21 +0000 (03:01 +0000)
committerAndre Malo <nd@apache.org>
Wed, 19 Feb 2003 03:01:21 +0000 (03:01 +0000)
PR: 9012

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@98721 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
support/apxs.in

diff --git a/CHANGES b/CHANGES
index 4d939855e83fc701a5f2d185acacef032b0b9a49..a8b291b80eeca24c83e10dbfdd30bf669ebfeabc 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,9 @@ Changes with Apache 2.1.0-dev
 
   [Remove entries to the current 2.0 section below, when backported]
 
+  *) Fix apxs to insert LoadModule directives only outside of sections.
+     PR 9012.  [AndrĂ© Malo]
+
   *) Hook mod_proxy's fixup before mod_rewrite's fixup, so that by
      mod_rewrite proxied URLs will not be escaped accidentally by
      mod_proxy's fixup. PR 16368  [AndrĂ© Malo]
index 184f6727bf5915eee2a28a5dc4f3c25c5f253798..fe545a883d91056e8e6ff2b5bf7ad79cfb311e51 100644 (file)
@@ -577,9 +577,30 @@ if ($opt_i or $opt_e) {
         foreach $lmd (@lmd) {
             my $what = $opt_A ? "preparing" : "activating";
             if ($content !~ m|\n#?\s*$lmd|) {
-                 $content =~ s|^(.*\n#?\s*LoadModule\s+[^\n]+\n)|$1$c$lmd\n|sg;
+                # check for open <containers>, so that the new LoadModule
+                # directive always appears *outside* of an <container>.
+
+                my $before = ($content =~ m|^(.*\n)#?\s*LoadModule\s+[^\n]+\n|s)[0];
+                my $cntopen = () = ($before =~ m|^\s*<[^/].*$|mg);
+                my $cntclose = () = ($before =~ m|^\s*</.*$|mg);
+
+                if ($cntopen == $cntclose) {
+                    # fine. Last LoadModule is contextless.
+                    $content =~ s|^(.*\n#?\s*LoadModule\s+[^\n]+\n)|$1$c$lmd\n|s;
+                }
+                elsif ($cntopen < $cntclose) {
+                    error('Configuration file is not valid. There are sections'
+                          . ' closed before opened.');
+                    exit(1);
+                }
+                else {
+                    # put our cmd after the section containing the last
+                    # LoadModule.
+                    $content =~ s!\A((?:(?:^\s*(?:[^<]|<[^/]).*(?:$)\n)*^\s*</.*(?:$)\n?){$cntopen})!$1$c$lmd\n!m;
+                }
             } else {
-                 $content =~ s|^(.*\n)#?\s*$lmd[^\n]*\n|$1$c$lmd\n|sg;
+                # replace already existing LoadModule line
+                $content =~ s|^(.*\n)#?\s*$lmd[^\n]*\n|$1$c$lmd\n|s;
             }
             $lmd =~ m|LoadModule\s+(.+?)_module.*|;
             notice("[$what module `$1' in $CFG_SYSCONFDIR/$CFG_TARGET.conf]");