Subject: | Unexpected behaviour when using ConfigPath with IncludeRelative |
--- 8< ---
if (/^\s*<<include\s+(.+?)>>\s*$/i || (/^\s*include\s+(.+?)\s*$/i
&& $this->{UseApacheInclude})) {
| $incl_file = $1;
| if ( $this->{IncludeRelative} && $path &&
!file_name_is_absolute($incl_file) ) {
| # include the file from within location of $this->{configfile}
| $this->_open( catfile($path, $incl_file) );
| }
| else {
| # include the file from within pwd, or absolute
| $this->_open($incl_file);
| }
--- 8< ---
The documentation indicates that if -IncludeRelative and -ConfigPath are
specified, relative includes will be looked for relative to the primary
absolute config file. However, if it cannot find it relative to the
primary config file, it will look in the ConfigPath directories for the
include file. This does happen, but by the time the _open() sub realises
that it cannot find the include file relative to the primary config
file, the include filename has already been prefixed by the absolute
path of the primary config file... the end result of this is that the
ConfigPaths are prepended on to the absolute path location of the
primary filename, and then the include file.
Thus:
-ConfigFile => '/home/nicolaw/webroot/apache/conf/httpd.conf',
-ConfigPath => [('/home/nicolaw/webroot/apache')],
-IncludeRelative => 1,
-IncludeDirectories => 1,
-IncludeGlob => 1,
.. if httpd.conf contains:
Include conf/extras/foo.conf
.. Config::General will look for :
/home/nicolaw/webroot/apache/conf/conf/extras/foo.conf (this is correct
and will fail to find the file)
then it will look for
/home/nicolaw/webroot/apache/home/nicolaw/webroot/apache/conf/conf/extras/foo.conf
... which is obviously incorrect. I would expect it to look for this
instead:
/home/nicolaw/webroot/apache/conf/extras/foo.conf