Re: [PATCH] Read acl included files relative to the configuration file

From: Willy Tarreau <w#1wt.eu>
Date: Thu, 8 Sep 2011 00:34:14 +0200


Hello,

On Tue, Sep 06, 2011 at 04:03:00PM +0200, Finn Arne Gangstad wrote:
> Previously, files included with the acl <..> -f <filename> construct would
> open <filename> relative to the current directory. This would mean that
>
> ( cd /tmp ; haproxy -d -f /etc/haproxy/haprocy.cfg ) and
> ( cd /etc/haproxy ; haproxy -d -f /etc/haproxy/haprocy.cfg )
>
> could give different results if the configuration file had
> any relative pathnames in acl -f constructs.

And this is expected. Any product using relative paths will work that way, and a number of users will expect it to work that way because "relative" clearly means relative to the current directory. Similarly, the two command lines below will load a different config file :

 ( cd /tmp ; haproxy -d -f haproxy.cfg ) and  ( cd /etc/haproxy ; haproxy -d -f haproxy.cfg )

If a specific location is desired, then an absolute path is required, as you did to load your config files above.

> Change this to always open included files relative to the
> configuration file they are being included from.

No, please don't do that ! It will break existing setups and will work in an unexpected way, because only ACL paths will be relative to the config file and the rest will be relative to the current directory.

If there is a real need for what you describe in some environments, (and I'm still doubting about it), I'd rather have a new flag on the command line which would cause a chdir() to be issued with each loaded config file to its dirname when it's parsed so that *all* locations are relative to the config file (eg: pidfiles, unix sockets, acl and other files later). For instance, the '-r' flag is not used, you could very well use it.

Regards,
Willy Received on 2011/09/08 00:34

This archive was generated by hypermail 2.2.0 : 2011/09/08 00:45 CEST