Skip to content

Commit c70906c

Browse files
committed
BUG/MINOR: cfgparse: detect incorrect overlap of same backend names
As reported below, it's possible to declare a backend then a proxy with the same name, because for the proxy we check a frontend capability (the first one to be tested): backend b listen b bind :8888 Let's check the two capabilities in this case and not just the frontend. Better not backport this, as there's a risk of breakage of existing setups that work by accident. It might make sense to report them as diag warnings though. Link: https://www.mail-archive.com/[email protected]/msg45185.html
1 parent 17e52c9 commit c70906c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/cfgparse-listen.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,15 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
271271
err_code |= ERR_ALERT | ERR_FATAL;
272272
}
273273

274-
curproxy = (rc & PR_CAP_FE) ? proxy_fe_by_name(args[1]) : proxy_be_by_name(args[1]);
274+
curproxy = NULL;
275+
if (rc & PR_CAP_FE)
276+
curproxy = proxy_fe_by_name(args[1]);
277+
278+
if (!curproxy && (rc & PR_CAP_BE))
279+
curproxy = proxy_be_by_name(args[1]);
280+
275281
if (curproxy) {
282+
/* same capability in common: always forbidden */
276283
ha_alert("Parsing [%s:%d]: %s '%s' has the same name as %s '%s' declared at %s:%d.\n",
277284
file, linenum, proxy_cap_str(rc), args[1], proxy_type_str(curproxy),
278285
curproxy->id, curproxy->conf.file, curproxy->conf.line);

0 commit comments

Comments
 (0)