Bug #1664

include directive in configuration file do not manage absolute file paths

Added by lunatic almost 12 years ago. Updated almost 12 years ago.

Target version:
Start date:
Due date:
% Done:


Estimated time:
Missing in 1.5.x:


When an "include_shell" generate "include file" lines there is sometimes some unexpected behavior due to the interaction between the "chdir basedir" in config_parse_cmd and the basedir prepending to the filename in config_parse_file.

For example if I do

   $ cd /my/home/rep
   $ /usr/sbin/lighttpd -f my_config_rep/lighttpd.conf

and an include_shell directive in lighttpd.conf generate "{{{include ./my_include_file}}}",
then lighttpd try to open the filename "{{{my_config_rep/./my_include_file}}}" (with the basedir prepended) from "{{{/my/top/rep/my_config_rep}}}" (to which it just changed).

When writing that you do not expect opening "{{{/my/top/rep/my_config_rep/my_config_rep/my_include_file}}}" which of course does not exist.

One solution is to not chdir when include_shell but it is not really good.
Another could be to have a special treatment of filename with "./" at the beginning and not prepending basedir for them.

This bug is perhaps related to #219 and #1221.

As a side note I just do not understand how this condition from configfile.c:875:

                      buffer_is_empty(context->basedir) &&
                        (fn[0] == '/' || fn[0] == '\\') &&
                        (fn[0] == '.' && (fn[1] == '/' || fn[1] == '\\'))

can ever be true ({{{fnr0 '/' && fnr0 '.'}}})


test_config_file.diff (595 Bytes) test_config_file.diff include_filename.diff lunatic, 2008-05-14 10:51

Updated by lunatic almost 12 years ago

Perhaps a quick fix should be just to document that only absolute filename behave well inside include_shell.


Updated by lunatic almost 12 years ago

Indeed the problem is worse than I thought, absolute filenames do not work at all with includes. The problem really is with the test before-mentioned.

I would rewrite it

    buffer_is_empty(context->basedir) ||
    (fn[0] == '/' || fn[0] == '\\') ||
    (fn[0] == '.' && (fn[1] == '/' || fn[1] == '\\'))

Updated by moo almost 12 years ago

  • Status changed from New to Assigned

let's see...

$ svn blame svn:// |grep -F 'fn['
   506        moo           (fn[0] == '/' || fn[0] == '\\') &&
   506        moo           (fn[0] == '.' && (fn[1] == '/' || fn[1] == '\\'))) {

$ svn blame svn:// |grep -F 'fn['
   307        moo           (fn[0] == '/' || fn[0] == '\\') &&
   307        moo           (fn[0] == '.' && (fn[1] == '/' || fn[1] == '\\'))) {

assign to me, but can u pls try to change && to || and see if it works for you? or if it works in a reasonable way.


Updated by lunatic almost 12 years ago

Attached patch do it for me. Not a good patch and only barely tested but this my first try at the resolution.


Updated by moo almost 12 years ago

  • Status changed from Assigned to Fixed
  • Resolution set to fixed

can i assume that it fixed for you? commited to trunk as r2170, pending for 1.4.x


Updated by moo almost 12 years ago

fixed in r2171 for 1.4.x


Updated by lunatic almost 12 years ago

Works for me. Thanks.

Also available in: Atom