From bc5c821cc259d343b6f1c8e457ead9518fd8198d Mon Sep 17 00:00:00 2001 From: Emeric Brun Date: Fri, 13 Aug 2021 09:32:50 +0200 Subject: [PATCH] BUG/MEDIUM: cfgcheck: verify existing log-forward listeners during config check User reported that the config check returns an error with the message: "Configuration file has no error but will not start (no listener) => exit(2)." if the configuration present only a log-forward section with bind or dgram-bind listeners but no listen/backend nor peer sections. The process checked if there was 'peers' section avalaible with an internal frontend (and so a listener) or a 'listen/backend' section not disabled with at least one configured listener (into the global proxies_list). Since the log-forward proxies appear in a different list, they were not checked. This patch adds a lookup on the 'log-forward' proxies list to check if one of them presents a listener and is not disabled. And this is done only if there was no available listener found into 'listen/backend' sections. I have also studied how to re-work this check considering the 'listeners' counter used after startup/init to keep the same algo and avoid further mistakes but currently this counter seems increased during config parsing and if a proxy is disabled, decreased during startup/init which is done after the current config check. So the fix still not rely on this counter. This patch should fix the github issue #1346 This patch should be backported as far as 2.3 (so on branches including the "log-forward" feature) --- src/haproxy.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/haproxy.c b/src/haproxy.c index 7bc260a405..047861ca94 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -2059,6 +2059,13 @@ static void init(int argc, char **argv) if (!px->disabled && px->li_all) break; + if (!px) { + /* We may only have log-forward section */ + for (px = cfg_log_forward; px; px = px->next) + if (!px->disabled && px->li_all) + break; + } + if (pr || px) { /* At least one peer or one listener has been found */ qfprintf(stdout, "Configuration file is valid\n");