Your patch works fine in my config here, but I do forsee one possible issue -- although this is a VERY UNLIKELY problem:
<IfModule mod_foo.c> Include conf/foo.conf </IfModule>
If I read your patch right, it would turn that into:
<IfModule mod_foo.c> </IfModule> [rest of httpd.conf] [Contents of conf/foo.conf inserted here]
well, I don't think it was my patch that was doing that. the way I read the code is that IfModule is always ignored and Include (and other) directives are always parsed. but yes, I was moving the placement :)
Obviously, Apache-Test is only really interested in a couple directives from the user's config file, so the chances of that reordering (and removal of code from the conditional block) causing problems is very small.
As a bit of a side note: Apache 1.3.28 does it the simple way:
1) set "ap_server_root" to HTTPD_ROOT (http_main.c: 5396)
that's what we're discussing :)
2) set "ap_server_root" to "-d VAL", if present (http_main.c: 5422)
I don't think we can support that easily, since we already have -serverroot and it means something different (it's where you run the tests from). but if it comes up again we probably ought to consider it.
3) set "ap_server_root" using ServerRoot directive (via normal module initalization stuff)
Whichever one is hit last is used, since it's a single global value.
So it seems like setting things up in that order within Apache-Test would be reasonable. But I agree with Stas that having a record of WHICH ServerRoot value is being used is a good thing and would surely ease some confusion in edge cases like mine.
here is yet another approach. it's pretty verbose, but I think I want _some_ warning in there if PREFIX is used, since it's kinda odd. but maybe not on every file resolution, though. but server_file_rel2abs is the only place I can see that uses inherit_config->{ServerRoot} so that seemed like the logical place to put everything. I dunno...
one additional thing the patch does address is a bogus warning I was seeing on 1.3 where the file is already absolute.
--Geoff
Index: Apache-Test/lib/Apache/TestConfigParse.pm
===================================================================
RCS file:
/home/cvspublic/httpd-test/perl-framework/Apache-Test/lib/Apache/TestConfigParse.pm,v
retrieving revision 1.35
diff -u -r1.35 TestConfigParse.pm
--- Apache-Test/lib/Apache/TestConfigParse.pm 9 Aug 2003 02:38:44 -0000
1.35
+++ Apache-Test/lib/Apache/TestConfigParse.pm 4 Nov 2003 15:38:27 -0000
@@ -8,7 +8,7 @@
use Apache::TestTrace;
-use File::Spec::Functions qw(rel2abs splitdir);
+use File::Spec::Functions qw(rel2abs splitdir file_name_is_absolute);
use File::Basename qw(basename);
sub strip_quotes {
@@ -47,11 +47,26 @@
sub server_file_rel2abs {
my($self, $file, $base) = @_;
- $base ||= $self->{inherit_config}->{ServerRoot};
-
unless ($base) {
- warning "unable to resolve $file (ServerRoot not defined yet?)";
- return $file;
+ # no base passed in
+ # use first the inherited ServerRoot
+ # then apxs -q PREFIX
+
+ if ($base = $self->{inherit_config}->{ServerRoot}) {
+ debug "using inherited ServerRoot $base to resolve $file";
+ }
+ elsif ($base = $self->apxs('PREFIX')) {
+ warning "using apxs-derived ServerRoot $base to resolve $file";
+ }
+ elsif (file_name_is_absolute($file)) {
+ debug "$file is already absolute";
+ return $file
+ }
+ else {
+ error "unable to resolve $file - please specify a ",
+ 'ServerRoot in your httpd.conf or use apxs';
+ die '';
+ }
}
rel2abs $file, $base;
