But this is not a guesswork. If ServerRoot is not specified PREFIX should be the one, since this is what Apache is doing.

ah, ok. I didn't see how ap_config.h was pulling in the apxs prefix. cool.

So use that and verify that the files can be found. If not, complain that ServerRoot can't be determined and die.

I'm not sure it's a good idea to just:

+    $self->{inherit_config}->{ServerRoot} ||= $self->apxs('PREFIX');

may be better to use PREFIX if ServerRoot is not defined in the code where it's needed, so it'll be clear that we don't have ServerRoot defined. And if we fail to expand paths we can tell a user the reason. If we have ServerRoot=PREFIX we can't tell the real reason to the user.

how about something like the attached patch? it seems to work for me under 1.3 and 2.0, and dies on a 1.3 with no ServerRoot and no mod_so. mike, can you give it a whirl?


one thing I noticed is that if ServerRoot is not specified in httpd.conf then Apache-Test can't resolve relative Include directives (such as conf/ssl.conf), so they need to be postponed until later in order to be picked up as they would if ServerRoot were specified.

--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   3 Nov 2003 19:59:47 -0000
@@ -196,12 +196,24 @@
     open($fh, $file) or return;
 
     my $c = $self->{inherit_config};
+
+    my @includes = ();
+
     while (<$fh>) {
         s/^\s*//; s/\s*$//; s/^\#.*//;
         next if /^$/;
         (my $directive, $_) = split /\s+/, $_, 2;
 
-        if ($directive eq "Include") {
+        if ($directive eq "Include" && ! $c->{ServerRoot}) {
+            # save Include files we can't resolve until 
+            # after we have ServerRoot
+
+            debug "delaying Include $_ until we have a ServerRoot";
+
+            push @includes, $_;
+            next;
+        }
+        elsif ($directive eq "Include") {
             my $include = $self->server_file_rel2abs($_);
             $self->inherit_config_file_or_directory($include);
         }
@@ -209,12 +221,29 @@
         #parse what we want
         while (my($spec, $wanted) = each %wanted_config) {
             next unless $wanted->{$directive};
+            debug "inheriting $directive $_";
             my $method = "parse_\L$spec";
             $self->$method($c, $directive);
         }
     }
 
     close $fh;
+
+    # if we don't have ServerRoot after parsing httpd.conf
+    # we will probably be in trouble.
+    # try apxs PREFIX as a last resort before croaking
+    unless ($c->{ServerRoot}) {
+        debug "no ServerRoot yet - trying apxs -q PREFIX";
+        unless ($c->{ServerRoot} = $self->apxs('PREFIX')) {
+            die 'Unable to find a ServerRoot - please specify ',
+                'a ServerRoot in your httpd.conf or use -apxs';
+        }
+    }
+
+    foreach my $include (@includes) {
+        my $file = $self->server_file_rel2abs($include);
+        $self->inherit_config_file_or_directory($file);
+    }
 }
 
 sub inherit_config {

Reply via email to