]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: cli: fix CLI handler "set anon global-key" call
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Fri, 3 Mar 2023 16:11:10 +0000 (17:11 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Fri, 3 Mar 2023 17:05:58 +0000 (18:05 +0100)
Anonymization mode has two CLI handlers "set anon <on|off>" and "set
anon global-key". The last one only requires admin level. However, as
cli_find_kw() is implemented, only the first handler will be retrieved
as they both start with the same prefix "set anon".

This has the effect to execute the wrong handler for "set anon
global-key" with an error message about an invalid keyword. To fix this,
handlers definition have been separated for both "set anon on" and "set
anon off" commands. This allows to have minimal changes while keeping
the same "set anon" prefix for each commands.

Also take this opportunity to fix a reference to a non-existing "set
global-key" CLI handler in the documentation.

This must be backported up to 2.7.

doc/configuration.txt
src/cli.c

index ae9c49e31507b989d1611ecd18014556aed1239a..d437946151d0f181589b98ee47e2d5263f0f5c91 100644 (file)
@@ -3433,8 +3433,8 @@ anonkey <key>
   This sets the global anonymizing key to <key>, which must be a 32-bit number
   between 0 and 4294967295. This is the key that will be used by default by CLI
   commands when anonymized mode is enabled. This key may also be set at runtime
-  from the CLI command "set global-key". See also command line argument "-dC"
-  in the management manual.
+  from the CLI command "set anon global-key". See also command line argument
+  "-dC" in the management manual.
 
 quick-exit
   This speeds up the old process exit upon reload by skipping the releasing of
index cf39cb68032a114493920e9bbcd8f98189a93d18..62c4fc587cfae7ee9322de1dbddfc715eaec30df 100644 (file)
--- a/src/cli.c
+++ b/src/cli.c
@@ -3143,7 +3143,8 @@ static struct cli_kw_list cli_kws = {{ },{
        { { "expert-mode", NULL },               NULL,                                                                                                cli_parse_expert_experimental_mode, NULL, NULL, NULL, ACCESS_MASTER }, // not listed
        { { "experimental-mode", NULL },         NULL,                                                                                                cli_parse_expert_experimental_mode, NULL, NULL, NULL, ACCESS_MASTER }, // not listed
        { { "mcli-debug-mode", NULL },         NULL,                                                                                                  cli_parse_expert_experimental_mode, NULL, NULL, NULL, ACCESS_MASTER_ONLY }, // not listed
-       { { "set", "anon", NULL },               "set anon <setting> [value]              : change the anonymized mode setting",                      cli_parse_set_anon, NULL, NULL },
+       { { "set", "anon", "on" },               "set anon on [value]                     : activate the anonymized mode",                            cli_parse_set_anon, NULL, NULL },
+       { { "set", "anon", "off" },              "set anon off                            : deactivate the anonymized mode",                          cli_parse_set_anon, NULL, NULL },
        { { "set", "anon", "global-key", NULL }, "set anon global-key <value>             : change the global anonymizing key",                       cli_parse_set_global_key, NULL, NULL },
        { { "set", "maxconn", "global",  NULL }, "set maxconn global <value>              : change the per-process maxconn setting",                  cli_parse_set_maxconn_global, NULL },
        { { "set", "rate-limit", NULL },         "set rate-limit <setting> <value>        : change a rate limiting value",                            cli_parse_set_ratelimit, NULL },