- Update haproxy download URL and hash - Add new patches Signed-off-by: Christian Lachner <gladiac@gmail.com>
81 lines
3 KiB
Diff
81 lines
3 KiB
Diff
commit 1bd140ea3fab97ccd37adf9d0c106d52af9e53fa
|
|
Author: William Lallemand <wlallemand@haproxy.com>
|
|
Date: Mon Jul 1 10:56:15 2019 +0200
|
|
|
|
BUG/MINOR: mworker/cli: don't output a \n before the response
|
|
|
|
When using a level lower than admin on the master CLI, a \n is output
|
|
before the response, this is caused by the response of the "operator" or
|
|
"user" that are sent before the actual command.
|
|
|
|
To fix this problem we introduce the flag APPCTX_CLI_ST1_NOLF which ask
|
|
a command response to not be followed by the final \n.
|
|
This patch made a special case with the command operator and user
|
|
followed by a - so they are not followed by \n.
|
|
|
|
This patch must be backported to 2.0 and 1.9.
|
|
|
|
(cherry picked from commit ad03288e6b28d816abb443cf8c6d984a72bb91a6)
|
|
Signed-off-by: William Lallemand <wlallemand@haproxy.org>
|
|
|
|
diff --git a/include/types/applet.h b/include/types/applet.h
|
|
index c9e02d17..1f3a4983 100644
|
|
--- a/include/types/applet.h
|
|
+++ b/include/types/applet.h
|
|
@@ -50,6 +50,7 @@ struct applet {
|
|
|
|
#define APPCTX_CLI_ST1_PROMPT (1 << 0)
|
|
#define APPCTX_CLI_ST1_PAYLOAD (1 << 1)
|
|
+#define APPCTX_CLI_ST1_NOLF (1 << 2)
|
|
|
|
/* Context of a running applet. */
|
|
struct appctx {
|
|
diff --git a/src/cli.c b/src/cli.c
|
|
index 44ddc7bf..9a9f80f9 100644
|
|
--- a/src/cli.c
|
|
+++ b/src/cli.c
|
|
@@ -821,7 +821,7 @@ static void cli_io_handler(struct appctx *appctx)
|
|
prompt = "\n> ";
|
|
}
|
|
else {
|
|
- if (!(appctx->st1 & APPCTX_CLI_ST1_PAYLOAD))
|
|
+ if (!(appctx->st1 & (APPCTX_CLI_ST1_PAYLOAD|APPCTX_CLI_ST1_NOLF)))
|
|
prompt = "\n";
|
|
}
|
|
|
|
@@ -848,6 +848,8 @@ static void cli_io_handler(struct appctx *appctx)
|
|
|
|
/* switch state back to GETREQ to read next requests */
|
|
appctx->st0 = CLI_ST_GETREQ;
|
|
+ /* reactivate the \n at the end of the response for the next command */
|
|
+ appctx->st1 &= ~APPCTX_CLI_ST1_NOLF;
|
|
}
|
|
}
|
|
|
|
@@ -1442,6 +1444,10 @@ static int cli_parse_show_lvl(char **args, char *payload, struct appctx *appctx,
|
|
/* parse and set the CLI level dynamically */
|
|
static int cli_parse_set_lvl(char **args, char *payload, struct appctx *appctx, void *private)
|
|
{
|
|
+ /* this will ask the applet to not output a \n after the command */
|
|
+ if (!strcmp(args[1], "-"))
|
|
+ appctx->st1 |= APPCTX_CLI_ST1_NOLF;
|
|
+
|
|
if (!strcmp(args[0], "operator")) {
|
|
if (!cli_has_level(appctx, ACCESS_LVL_OPER)) {
|
|
return 1;
|
|
@@ -2097,11 +2103,11 @@ int pcli_parse_request(struct stream *s, struct channel *req, char **errmsg, int
|
|
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_line2(req, 0, "operator -", strlen("operator -"));
|
|
+ ret += strlen("operator -") + 2;
|
|
} else if (pcli_has_level(s, ACCESS_LVL_USER)) {
|
|
- ci_insert_line2(req, 0, "user", strlen("user"));
|
|
- ret += strlen("user") + 2;
|
|
+ ci_insert_line2(req, 0, "user -", strlen("user -"));
|
|
+ ret += strlen("user -") + 2;
|
|
}
|
|
}
|
|
end:
|