From: Amaury Denoyelle Date: Tue, 1 Dec 2026 12:58:55 +0000 (+0100) Subject: BUG/MINOR: server: reject from/name in peers section X-Git-Url: https://git.kaiwu.me/http/%22../doc/static/%7B@url%7D?a=commitdiff_plain;h=0e166c943812e603fe33f6daa96b7b100645468c;p=haproxy.git BUG/MINOR: server: reject from/name in peers section The new positional keywords 'from' and 'name' were introduced to extend server inheritance. However, nothing was implemented to ensure they were rejected in a peers section. Thus, it would be possible for a peer server to inherit from a default-server in a standard backend. This could cause unexpected behavior as a peer server does not support the full keyword range of the instances declared in standard proxies. Clarify this situation by rejecting usage of these keywords in a peers section. A fatal error is reported if this is encountered. Note that _srv_parse_from() is still called for peers server and default-server, as it is necessary to preserve the original unnamed default-server overloading mechanism. The new error is only reported if 'from' is found. This is not a breaking change since 'from' and 'name' were implemented in the current dev branch. No need to backport. --- diff --git a/src/server.c b/src/server.c index 540791541..35e97a4e6 100644 --- a/src/server.c +++ b/src/server.c @@ -991,8 +991,13 @@ static int srv_parse_error_limit(char **args, int *cur_arg, static int srv_parse_from(char **args, int *cur_arg, struct proxy *curproxy, struct server *newsrv, char **err) { - memprintf(err, "'%s' is a positional keyword. It must be specified" - " before any other server setting", args[*cur_arg]); + if (curproxy->mode == PR_MODE_PEERS) { + memprintf(err, "'%s' not supported in a peers section", args[*cur_arg]); + } + else { + memprintf(err, "'%s' is a positional keyword. It must be specified" + " before any other server setting", args[*cur_arg]); + } return ERR_ALERT | ERR_FATAL; } @@ -4001,6 +4006,12 @@ static int _srv_parse_init(struct server **srv, char **args, int *cur_arg, else { /* Parse optional "name" default-server keyword. */ if (*args[1] && strcmp(args[1], "name") == 0) { + if (parse_flags & SRV_PARSE_IN_PEER_SECTION) { + ha_alert("named default-server are not supported in a peers section.\n"); + err_code |= ERR_ALERT | ERR_FATAL; + goto out; + } + if (!*args[2]) { ha_alert("default-server name: missing value.\n"); err_code |= ERR_ALERT | ERR_FATAL; @@ -4130,6 +4141,12 @@ static int _srv_parse_from(struct server *srv, char **args, int *cur_arg, int err_code = ERR_NONE; if (strcmp(args[*cur_arg], "from") == 0) { + if (parse_flags & SRV_PARSE_IN_PEER_SECTION) { + ha_alert("'%s' not supported in a peers section.\n", args[*cur_arg]); + err_code |= ERR_FATAL | ERR_ALERT; + goto out; + } + if (!*args[*cur_arg + 1]) { ha_alert("from: missing value.\n"); err_code |= ERR_FATAL | ERR_ALERT;