Ticket #1664 (closed defect: fixed)
include directive in configuration file do not manage absolute file paths
| Reported by: | lunatic | Owned by: | moo |
|---|---|---|---|
| Priority: | low | Milestone: | 1.5.0 |
| Component: | core | Version: | 1.5.x-svn |
| Severity: | minor | Keywords: | include_shell, include |
| Cc: | Blocked By: | ||
| Need User Feedback: | no | Blocking: |
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 (fn[0] == '/' && fn[0] == '.')
