]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: cli: remove error message with 'set anon on|off'
authorErwan Le Goas <elegoas@haproxy.com>
Wed, 28 Sep 2022 15:04:29 +0000 (17:04 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 29 Sep 2022 08:53:14 +0000 (10:53 +0200)
Removed the error message in 'set anon on|off', it's more user
friendly: users use 'set anon on' even if the mode is already
activated, and the same for 'set anon off'. That allows users
to write the command line in the anonymized mode they want
without errors.

No backport needed, except if anonymization mechanism is backported.

src/cli.c

index 7d91b2d962e3b2bfbca31e46ed7b8258f9b45dd8..a2eb87aea21ac2870630530d64fbafd62726525c 100644 (file)
--- a/src/cli.c
+++ b/src/cli.c
@@ -1882,28 +1882,24 @@ static int cli_parse_set_anon(char **args, char *payload, struct appctx *appctx,
        long long key;
 
        if (strcmp(args[2], "on") == 0) {
-               if (appctx->cli_anon_key != 0)
-                       return cli_err(appctx, "Mode already enabled\n");
+
+               if (*args[3]) {
+                       key = atoll(args[3]);
+                       if (key < 1 || key > UINT_MAX)
+                               return cli_err(appctx, "Value out of range (1 to 4294967295 expected).\n");
+                       appctx->cli_anon_key = key;
+               }
                else {
-                       if (*args[3]) {
-                               key = atoll(args[3]);
-                               if (key < 1 || key > UINT_MAX)
-                                       return cli_err(appctx, "Value out of range (1 to 4294967295 expected).\n");
-                               appctx->cli_anon_key = key;
-                       }
-                       else {
-                               tmp = HA_ATOMIC_LOAD(&global.anon_key);
-                               if (tmp != 0)
-                                       appctx->cli_anon_key = tmp;
-                               else
-                                       appctx->cli_anon_key = ha_random32();
-                       }
+                       tmp = HA_ATOMIC_LOAD(&global.anon_key);
+                       if (tmp != 0)
+                               appctx->cli_anon_key = tmp;
+                       else
+                               appctx->cli_anon_key = ha_random32();
                }
        }
        else if (strcmp(args[2], "off") == 0) {
-               if (appctx->cli_anon_key == 0)
-                       return cli_err(appctx, "Mode already disabled\n");
-               else if (*args[3]) {
+
+               if (*args[3]) {
                        return cli_err(appctx, "Key can't be added while disabling anonymized mode\n");
                }
                else {