Lukas,

Am 22.06.20 um 18:41 schrieb Lukas Tribus:
> On Mon, 22 Jun 2020 at 18:16, Tim Duesterhus <t...@bastelstu.be> wrote:
>>
>> Fix parsing of configurations if the configuration file does not end with
>> an LF.
> 
> ... but it's also warning about it at the same time.
> 
> So it's unclear to me:
> 
> Do we support a configuration without trailing LF or not?
> 
> If yes, there is no point in a warning (just as < 2.1).
> If no, we should abort and error out.
> 
> We can "just warn" if we plan to deprecate it in future release, and
> at that point, explain that fact. But I find it strange to warn about
> something, without a clear indication about *WHY* (unsupported,
> deprecated, etc).
> 
> 
> Thoughts?
> 
I consider leaving out a trailing newline a bug for these reasons:

1. POSIX defines a line as "A sequence of zero or more non- <newline>
characters plus a terminating <newline> character."
(https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206).
A non-terminated line thus is not a line and handling non-terminated
lines is a bit wonky.

2. Leaving out the trailing newline causes ./haproxy -f config/ with
config/ being a folder not to be equivalent to ./haproxy -f config with
config being the catenation of all files of the config/ folder (⏎
indicates a missing trailing newline in my shell):

> $ ls -alh
> total 84K
> drwxrwxr-x  2 timwolla timwolla 4.0K Jun 22 18:47 .
> drwxrwxrwt 29 root     root      68K Jun 22 18:47 ..
> -rw-rw-r--  1 timwolla timwolla   22 Jun 22 18:47 a.cfg
> -rw-rw-r--  1 timwolla timwolla   23 Jun 22 18:47 b.cfg
> $ cat a.cfg
> listen foo
> bind *:8080⏎> $ cat b.cfg
> listen foo2
> bind *:8081⏎> $ cat a.cfg b.cfg > cat
Then:

> $ ./haproxy -d -f /tmp/example/
> [WARNING] 173/185127 (17393) : parsing [/tmp/example//a.cfg:2]: line is not 
> terminated by a newline (LF / '\n').
> [WARNING] 173/185127 (17393) : parsing [/tmp/example//b.cfg:2]: line is not 
> terminated by a newline (LF / '\n').
> [WARNING] 173/185127 (17393) : config : missing timeouts for proxy 'foo'.
>    | While not properly invalid, you will certainly encounter various problems
>    | with such a configuration. To fix this, please ensure that all following
>    | timeouts are set to a non-zero value: 'client', 'connect', 'server'.
> [WARNING] 173/185127 (17393) : config : missing timeouts for proxy 'foo2'.
>    | While not properly invalid, you will certainly encounter various problems
>    | with such a configuration. To fix this, please ensure that all following
>    | timeouts are set to a non-zero value: 'client', 'connect', 'server'.
> Note: setting global.maxconn to 524276.
> Available polling systems :
>       epoll : pref=300,  test result OK
>        poll : pref=200,  test result OK
>      select : pref=150,  test result FAILED
> Total: 3 (2 usable), will use epoll.
> 
> Available filters :
>       [SPOE] spoe
>       [COMP] compression
>       [TRACE] trace
>       [CACHE] cache
>       [FCGI] fcgi-app
> Using epoll() as the polling mechanism.
> ^C⏎
> $ ./haproxy -d -f /tmp/example/cat
> [NOTICE] 173/185130 (17415) : haproxy version is 2.2-dev10-55729a-1
> [NOTICE] 173/185130 (17415) : path to executable is ./haproxy
> [ALERT] 173/185130 (17415) : parsing [/tmp/example/cat:2] : 'bind 
> *:8080listen' unknown keyword 'foo2'. Registered keywords :
>     [STAT] level <arg>
>     [STAT] expose-fd <arg>
>     [STAT] severity-output <arg>
>     [ ALL] accept-netscaler-cip <arg>
>     [ ALL] accept-proxy
>     [ ALL] backlog <arg>
>     [ ALL] id <arg>
>     [ ALL] maxconn <arg>
>     [ ALL] name <arg>
>     [ ALL] nice <arg>
>     [ ALL] process <arg>
>     [ ALL] proto <arg>
>     [UNIX] gid <arg>
>     [UNIX] group <arg>
>     [UNIX] mode <arg>
>     [UNIX] uid <arg>
>     [UNIX] user <arg>
>     [ TCP] defer-accept
>     [ TCP] interface <arg>
>     [ TCP] mss <arg>
>     [ TCP] tcp-ut <arg>
>     [ TCP] tfo
>     [ TCP] transparent
>     [ TCP] v4v6
>     [ TCP] v6only
>     [ TCP] namespace <arg>
> [WARNING] 173/185130 (17415) : parsing [/tmp/example/cat:3]: line is not 
> terminated by a newline (LF / '\n').
> [ALERT] 173/185130 (17415) : Error(s) found in configuration file : 
> /tmp/example/cat
> [ALERT] 173/185130 (17415) : Fatal errors found in configuration.
Thus even if we might never not support leaving out the trailing newline
I consider that something worthwhile to warn about.

Best regards
Tim Düsterhus

Reply via email to