Discussion:
getting config file in TestConfigParse.pm
Randy Kobes
2005-10-03 05:38:12 UTC
Permalink
I was wondering about this change:
http://svn.apache.org/viewcvs.cgi/perl/Apache-Test/trunk/lib/Apache/TestConfigParse.pm?rev=279322&r1=226979&r2=279322
in TestConfigParse.pm, which reads in part:

# SERVER_CONFIG_FILE might be an absolute path
- $file = $default_conf if !-e $file and -e $default_conf;
+ if (! -e $file && -e $default_conf) {
+ $file = $default_conf;
+ }
+ else {
+ # try a little harder
+ if (my $root = $self->{httpd_defines}->{HTTPD_ROOT}) {
+ debug "using HTTPD_ROOT to resolve $default_conf";
+ $file = catfile $root, $default_conf;
+ }
+ }
}
}

If $file does exist, then the
if (! -e $file && -e $default_conf) {
}
is ignored, but the
else {
}
will be followed; in my case, on Win32, it overwrote
the correct, exisiting $file with
$file = catfile $root, $default_conf;
which didn't exist. The following patch:
=========================================================
Index: Apache-Test/lib/Apache/TestConfigParse.pm
===================================================================
--- Apache-Test/lib/Apache/TestConfigParse.pm (revision 293219)
+++ Apache-Test/lib/Apache/TestConfigParse.pm (working copy)
@@ -347,15 +347,17 @@
$file = catfile $base, $default_conf;

# SERVER_CONFIG_FILE might be an absolute path
- if (! -e $file && -e $default_conf) {
- $file = $default_conf;
- }
- else {
- # try a little harder
- if (my $root = $self->{httpd_defines}->{HTTPD_ROOT}) {
- debug "using HTTPD_ROOT to resolve $default_conf";
- $file = catfile $root, $default_conf;
+ unless (-e $file) {
+ if (-e $default_conf) {
+ $file = $default_conf;
}
+ else {
+ # try a little harder
+ if (my $root = $self->{httpd_defines}->{HTTPD_ROOT}) {
+ debug "using HTTPD_ROOT to resolve $default_conf";
+ $file = catfile $root, $default_conf;
+ }
+ }
}
}
}

==========================================================================
fixed that for me.
--
best regards,
randy
Geoffrey Young
2005-10-03 23:41:50 UTC
Permalink
Post by Randy Kobes
If $file does exist, then the
if (! -e $file && -e $default_conf) {
}
is ignored, but the
else {
}
will be followed; in my case, on Win32, it overwrote the correct,
exisiting $file with
$file = catfile $root, $default_conf;
blarg, sorry about that.
looks good.

--Geoff

Loading...