BUG/MINOR: tcpcheck: Don't use arg list for default proxies during parsing
During tcp/http check rules parsing, when a sample fetch or a log-format
string is parsed, the proxy's argument list used to track unresolved
argument is no longer passed for default proxies. It means it is no longer
possible to rely on sample fetches depending on the execution context (for
instance 'nbsrv').
It is important to avoid HAProxy crashes because these arguments are
resolved during the configuration validity check. But, default proxies are
not evaluated during this stage. Thus, these arguments remain unresolved.
It will probably be possible to relax this rule. But to ease backports, it
is forbidden for now.
This patch must be backported as far as 2.2. It depends on the commit
"MINOR: arg: Be able to forbid unresolved args when building an argument
list". It must be adapted for the 2.3 because PR_CAP_DEF capability was
introduced in the 2.4. A solution may be to test The proxy's id agains NULL.
diff --git a/src/tcpcheck.c b/src/tcpcheck.c
index 2b93af5..c34095d 100644
--- a/src/tcpcheck.c
+++ b/src/tcpcheck.c
@@ -2432,7 +2432,7 @@
px->conf.args.ctx = ARGC_SRV;
port_expr = sample_parse_expr((char *[]){args[cur_arg], NULL}, &idx,
- file, line, errmsg, &px->conf.args, NULL);
+ file, line, errmsg, (px->cap & PR_CAP_DEF) ? NULL: &px->conf.args, NULL);
if (!port_expr) {
memprintf(errmsg, "error detected while parsing port expression : %s", *errmsg);
@@ -3234,7 +3234,7 @@
release_sample_expr(status_expr);
px->conf.args.ctx = ARGC_SRV;
status_expr = sample_parse_expr((char *[]){args[cur_arg], NULL}, &idx,
- file, line, errmsg, &px->conf.args, NULL);
+ file, line, errmsg, (px->cap & PR_CAP_DEF) ? NULL: &px->conf.args, NULL);
if (!status_expr) {
memprintf(errmsg, "error detected while parsing status-code expression : %s", *errmsg);
goto error;