]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MEDIUM: server/log: "mode log" after server keyword causes crash
authorAurelien DARRAGON <adarragon@haproxy.com>
Thu, 19 Oct 2023 08:59:26 +0000 (10:59 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 25 Oct 2023 09:59:27 +0000 (11:59 +0200)
commit29b76cae47b15b1f0fc663fc53d323a6e9aaf801
tree2fadc7b5e00e96649610b54386796a168a54e5fa
parent55d2fc0c02103841725354cbba97d33f73c6ff4e
BUG/MEDIUM: server/log: "mode log" after server keyword causes crash

In 9a74a6c ("MAJOR: log: introduce log backends"), a mistake was made:
it was assumed that the proxy mode was already known during server
keyword parsing in parse_server() function, but this is wrong.

Indeed, "mode log" can be declared late in the proxy section. Due to this,
a simple config like this will cause the process to crash:

   |backend test
   |
   |  server name 127.0.0.1:8080
   |  mode log

In order to fix this, we relax some checks in _srv_parse_init() and store
the address protocol from str2sa_range() in server struct, then we set-up
a postparsing function that is to be called after config parsing to
finish the server checks/initialization that depend on the proxy mode
to be known. We achieve this by checking the PR_CAP_LB capability from
the parent proxy to know if we're in such case where the effective proxy
mode is not yet known (it is assumed that other proxies which are implicit
ones don't provide this possibility and thus don't suffer from this
constraint).

Only then, if the capability is not found, we immediately perform the
server checks that depend on the proxy mode, else the check is postponed
and it will automatically be performed during postparsing thanks to the
REGISTER_POST_SERVER_CHECK() hook.

Note that we remove the SRV_PARSE_IN_LOG_BE flag because it was introduced
in the above commit and it is no longer relevant.

No backport needed unless 9a74a6c gets backported.
include/haproxy/server-t.h
src/cfgparse-listen.c
src/server.c