From dd3a33f863c4a40af68eb9399860d25d7c56a658 Mon Sep 17 00:00:00 2001 From: Amaury Denoyelle Date: Fri, 3 Mar 2023 17:11:10 +0100 Subject: [PATCH] BUG/MINOR: cli: fix CLI handler "set anon global-key" call Anonymization mode has two CLI handlers "set anon " 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 | 4 ++-- src/cli.c | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/doc/configuration.txt b/doc/configuration.txt index ae9c49e31..d43794615 100644 --- a/doc/configuration.txt +++ b/doc/configuration.txt @@ -3433,8 +3433,8 @@ anonkey This sets the global anonymizing key to , 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 diff --git a/src/cli.c b/src/cli.c index cf39cb680..62c4fc587 100644 --- 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 [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 : change the global anonymizing key", cli_parse_set_global_key, NULL, NULL }, { { "set", "maxconn", "global", NULL }, "set maxconn global : change the per-process maxconn setting", cli_parse_set_maxconn_global, NULL }, { { "set", "rate-limit", NULL }, "set rate-limit : change a rate limiting value", cli_parse_set_ratelimit, NULL },