diff options
author | André Malo <nd@apache.org> | 2003-02-19 04:01:21 +0100 |
---|---|---|
committer | André Malo <nd@apache.org> | 2003-02-19 04:01:21 +0100 |
commit | bb51a76b7949cbfd124911fdb08d464e4a6bcf8d (patch) | |
tree | 456634c2cc0320881c6879a5ed49685b6ff26937 /support/apxs.in | |
parent | doc typo fix: s/ap_fine_path_info/ap_find_path_info/ (diff) | |
download | apache2-bb51a76b7949cbfd124911fdb08d464e4a6bcf8d.tar.xz apache2-bb51a76b7949cbfd124911fdb08d464e4a6bcf8d.zip |
insert LoadModule directives only outside of sections.
PR: 9012
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@98721 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'support/apxs.in')
-rw-r--r-- | support/apxs.in | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/support/apxs.in b/support/apxs.in index 184f6727bf..fe545a883d 100644 --- a/support/apxs.in +++ b/support/apxs.in @@ -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]"); |