MEDIUM: cli: store CLI level in the appctx

Store and check the level in the appctx in order to allow dynamic
permission changes over the CLI.
This commit is contained in:
William Lallemand 2018-12-13 09:05:44 +01:00 committed by Willy Tarreau
parent 86ff9c8f3a
commit f630d01c9f
2 changed files with 3 additions and 3 deletions

View File

@ -66,6 +66,7 @@ struct appctx {
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 */
int cli_severity_output; /* used within the cli_io_handler to format severity output of informational feedback */
int cli_level; /* the level of CLI which can be lowered dynamically */
struct buffer_wait buffer_wait; /* position in the list of objects waiting for a buffer */
unsigned long thread_mask; /* mask of thread IDs authorized to process the applet */
struct task *t; /* task associated to the applet */

View File

@ -381,10 +381,8 @@ static int stats_parse_global(char **args, int section_type, struct proxy *curpx
*/
int cli_has_level(struct appctx *appctx, int level)
{
struct stream_interface *si = appctx->owner;
struct stream *s = si_strm(si);
if ((strm_li(s)->bind_conf->level & ACCESS_LVL_MASK) < level) {
if ((appctx->cli_level & ACCESS_LVL_MASK) < level) {
appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = stats_permission_denied_msg;
appctx->st0 = CLI_ST_PRINT;
@ -563,6 +561,7 @@ static void cli_io_handler(struct appctx *appctx)
/* reset severity to default at init */
appctx->cli_severity_output = bind_conf->severity_output;
appctx->st0 = CLI_ST_GETREQ;
appctx->cli_level = bind_conf->level;
}
else if (appctx->st0 == CLI_ST_END) {
/* Let's close for real now. We just close the request