BUG/MEDIUM: mworker/cli: fix pipelined modes on master CLI
Since commit 3d93ecc ("BUG/MAJOR: cli: Restore non-interactive mode
behavior with pipelined commands") and commit 598c7f16 ("BUG/MEDIUM:
cli: Warn if pipelined commands are delimited by a \n"), the pipelined
command on the master CLI are either broken or emit warnings depending
on which version.
The reason is that mode applied on the master CLI are saved on the in
the current CLI session, and then reinserted for each pipelined command,
however, these commande were inserted as new lines.
For example:
"@1; expert-mode on; debug dev log foo; debug dev log bar"
Would be sent as:
"expert mode on\ndebug dev log foo"
"expert mode on\ndebug dev log bar"
This patch fixes the issue by using the new ci_insert() function which
inserts a string instead of a newline, and the command are now suffixed
by ';' upon insertion allowing a correct pipelined command chain.
This must be backported with the previous commit introducing ci_insert()
in every stable version.
This is broken since the 3.0 version, but it emits a warning in every
version below, because 598c7f164 was backported.
(cherry picked from commit b75edf2f11486bc2f2cc92c2b5273219a5e728c6)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit a948603e9960fba9ea9f2dd0602e246b73cc25ac)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 5f1ee585b3935acb9b7e7f0b5f796a1b9329237e)
Signed-off-by: Willy Tarreau <w@1wt.eu>
diff --git a/src/cli.c b/src/cli.c
index fd22ca8..5837e1c 100644
--- a/src/cli.c
+++ b/src/cli.c
@@ -2691,36 +2691,36 @@
/* the mcli-debug-mode is only sent to the applet of the master */
if ((s->pcli_flags & ACCESS_MCLI_DEBUG) && *next_pid <= 0) {
- ci_insert_line2(req, 0, "mcli-debug-mode on -", strlen("mcli-debug-mode on -"));
- ret += strlen("mcli-debug-mode on -") + 2;
+ ci_insert(req, 0, "mcli-debug-mode on -;", strlen("mcli-debug-mode on -;"));
+ ret += strlen("mcli-debug-mode on -;");
}
if (s->pcli_flags & ACCESS_EXPERIMENTAL) {
- ci_insert_line2(req, 0, "experimental-mode on -", strlen("experimental-mode on -"));
- ret += strlen("experimental-mode on -") + 2;
+ ci_insert(req, 0, "experimental-mode on -;", strlen("experimental-mode on -;"));
+ ret += strlen("experimental-mode on -;");
}
if (s->pcli_flags & ACCESS_EXPERT) {
- ci_insert_line2(req, 0, "expert-mode on -", strlen("expert-mode on -"));
- ret += strlen("expert-mode on -") + 2;
+ ci_insert(req, 0, "expert-mode on -;", strlen("expert-mode on -;"));
+ ret += strlen("expert-mode on -;");
}
if (s->pcli_flags & ACCESS_MCLI_SEVERITY_STR) {
- const char *cmd = "set severity-output string -";
- ci_insert_line2(req, 0, cmd, strlen(cmd));
- ret += strlen(cmd) + 2;
+ const char *cmd = "set severity-output string -;";
+ ci_insert(req, 0, cmd, strlen(cmd));
+ ret += strlen(cmd);
}
if (s->pcli_flags & ACCESS_MCLI_SEVERITY_NB) {
- const char *cmd = "set severity-output number -";
- ci_insert_line2(req, 0, cmd, strlen(cmd));
- ret += strlen(cmd) + 2;
+ const char *cmd = "set severity-output number -;";
+ ci_insert(req, 0, cmd, strlen(cmd));
+ ret += strlen(cmd);
}
if (pcli_has_level(s, ACCESS_LVL_ADMIN)) {
goto end;
} else if (pcli_has_level(s, ACCESS_LVL_OPER)) {
- ci_insert_line2(req, 0, "operator -", strlen("operator -"));
- ret += strlen("operator -") + 2;
+ ci_insert(req, 0, "operator -;", strlen("operator -;"));
+ ret += strlen("operator -;");
} else if (pcli_has_level(s, ACCESS_LVL_USER)) {
- ci_insert_line2(req, 0, "user -", strlen("user -"));
- ret += strlen("user -") + 2;
+ ci_insert(req, 0, "user -;", strlen("user -;"));
+ ret += strlen("user -;");
}
}
end: