diff --git a/include/haproxy/applet-t.h b/include/haproxy/applet-t.h index e10c8240f..be76d5c4b 100644 --- a/include/haproxy/applet-t.h +++ b/include/haproxy/applet-t.h @@ -130,6 +130,7 @@ struct appctx { int (*io_handler)(struct appctx *appctx); /* used within the cli_io_handler when st0 = CLI_ST_CALLBACK */ void (*io_release)(struct appctx *appctx); /* used within the cli_io_handler when st0 = CLI_ST_CALLBACK, if the command is terminated or the session released */ + struct cli_kw *kw; /* the keyword being processed */ } cli_ctx; /* context dedicated to the CLI applet */ struct buffer_wait buffer_wait; /* position in the list of objects waiting for a buffer */ diff --git a/src/cli.c b/src/cli.c index 104b7175d..f49cca210 100644 --- a/src/cli.c +++ b/src/cli.c @@ -849,6 +849,7 @@ static int cli_process_cmdline(struct appctx *appctx) else if (kw->level == ACCESS_EXPERIMENTAL) mark_tainted(TAINTED_CLI_EXPERIMENTAL_MODE); + appctx->cli_ctx.kw = kw; appctx->cli_ctx.io_handler = kw->io_handler; appctx->cli_ctx.io_release = kw->io_release; @@ -868,6 +869,7 @@ static int cli_process_cmdline(struct appctx *appctx) goto end; fail: + appctx->cli_ctx.kw = NULL; appctx->cli_ctx.io_handler = NULL; appctx->cli_ctx.io_release = NULL; @@ -1215,11 +1217,13 @@ void cli_io_handler(struct appctx *appctx) if (appctx->cli_ctx.io_release) { appctx->cli_ctx.io_release(appctx); appctx->cli_ctx.io_release = NULL; + appctx->cli_ctx.kw = NULL; /* some release handlers might have * pending output to print. */ continue; } + appctx->cli_ctx.kw = NULL; } break; default: /* abnormal state */ @@ -1327,6 +1331,7 @@ static void cli_release_handler(struct appctx *appctx) if (appctx->cli_ctx.io_release) { appctx->cli_ctx.io_release(appctx); appctx->cli_ctx.io_release = NULL; + appctx->cli_ctx.kw = NULL; } else if (appctx->st0 == CLI_ST_PRINT_DYN || appctx->st0 == CLI_ST_PRINT_DYNERR) { struct cli_print_ctx *ctx = applet_reserve_svcctx(appctx, sizeof(*ctx));