]> git.kaiwu.me - haproxy.git/commitdiff
MINOR: server: report incorrect usage of "from" keyword
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 23 Nov 2026 10:04:24 +0000 (11:04 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 23 Nov 2026 13:54:31 +0000 (14:54 +0100)
Define a parser for the "from" server keyword. It always returns an
error reporting its invalid position as any "from" setting has already
been parsed during _srv_parse_from().

Also, this prevents a later keyword list from overriding this name.

src/server.c

index b9d7d967ad68a977b7ac6e4ef3218930bb1f25f4..86918ce04a8f977f69c083738985ec12ccb7f642 100644 (file)
@@ -986,6 +986,15 @@ static int srv_parse_error_limit(char **args, int *cur_arg,
        return 0;
 }
 
+/* Reports incorrect position of "from" server keyword. */
+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]);
+       return ERR_ALERT | ERR_FATAL;
+}
+
 /* Parse the "guid" keyword */
 static int srv_parse_guid(char **args, int *cur_arg,
                         struct proxy *curproxy, struct server *newsrv, char **err)
@@ -2502,6 +2511,7 @@ static struct srv_kw_list srv_kws = { "ALL", { }, {
        { "disabled",             srv_parse_disabled,             0,  1,  1 }, /* Start the server in 'disabled' state */
        { "enabled",              srv_parse_enabled,              0,  1,  0 }, /* Start the server in 'enabled' state */
        { "error-limit",          srv_parse_error_limit,          1,  1,  1 }, /* Configure the consecutive count of check failures to consider a server on error */
+       { "from",                 srv_parse_from,                 1,  1,  1 }, /* Not a real parser - prevent conflict with 'from' positional keyword */
        { "guid",                 srv_parse_guid,                 1,  0,  1 }, /* Set global unique ID of the server */
        { "ws",                   srv_parse_ws,                   1,  1,  1 }, /* websocket protocol */
        { "hash-key",             srv_parse_hash_key,             1,  1,  1 }, /* Configure how chash keys are computed */