Project

General

Profile

Actions

Bug #1664

closed

include directive in configuration file do not manage absolute file paths

Added by lunatic over 16 years ago. Updated over 16 years ago.

Status:
Fixed
Priority:
Low
Category:
core
Target version:
ASK QUESTIONS IN Forums:

Description

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 '.'}}})


Files

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

Updated by lunatic over 16 years ago

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

Actions #2

Updated by lunatic over 16 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] == '\\'))
Actions #3

Updated by moo over 16 years ago

  • Status changed from New to Assigned

let's see...


$ svn blame svn://svn.lighttpd.net/lighttpd/trunk/src/configfile.c@506 |grep -F 'fn['
   506        moo           (fn[0] == '/' || fn[0] == '\\') &&
   506        moo           (fn[0] == '.' && (fn[1] == '/' || fn[1] == '\\'))) {

$ svn blame svn://svn.lighttpd.net/lighttpd/trunk/src/configfile.c@505 |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.

Actions #4

Updated by lunatic over 16 years ago

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

Actions #5

Updated by moo over 16 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

Actions #6

Updated by moo over 16 years ago

fixed in r2171 for 1.4.x

Actions #7

Updated by lunatic over 16 years ago

Works for me. Thanks.

Actions

Also available in: Atom