}
bind_conf = bind_conf_alloc(global.stats_fe, file, line, args[2], xprt_get(XPRT_RAW));
- bind_conf->level = ACCESS_LVL_OPER; /* default access level */
+ bind_conf->level &= ~ACCESS_LVL_MASK;
+ bind_conf->level |= ACCESS_LVL_OPER; /* default access level */
if (!str2listener(args[2], global.stats_fe, bind_conf, file, line, err)) {
memprintf(err, "parsing [%s:%d] : '%s %s' : %s\n",
struct stream_interface *si = appctx->owner;
struct stream *s = si_strm(si);
- if (strm_li(s)->bind_conf->level < level) {
+ if ((strm_li(s)->bind_conf->level & ACCESS_LVL_MASK) < level) {
appctx->ctx.cli.msg = stats_permission_denied_msg;
appctx->st0 = CLI_ST_PRINT;
return 0;
} else
continue;
- if (bind_conf->level == ACCESS_LVL_USER)
- chunk_appendf(&trash, "user ");
- else if (bind_conf->level == ACCESS_LVL_OPER)
- chunk_appendf(&trash, "operator ");
- else if (bind_conf->level == ACCESS_LVL_ADMIN)
+ if ((bind_conf->level & ACCESS_LVL_MASK) == ACCESS_LVL_ADMIN)
chunk_appendf(&trash, "admin ");
+ else if ((bind_conf->level & ACCESS_LVL_MASK) == ACCESS_LVL_OPER)
+ chunk_appendf(&trash, "operator ");
+ else if ((bind_conf->level & ACCESS_LVL_MASK) == ACCESS_LVL_USER)
+ chunk_appendf(&trash, "user ");
else
chunk_appendf(&trash, " ");
return ERR_ALERT | ERR_FATAL;
}
- if (!strcmp(args[cur_arg+1], "user"))
- conf->level = ACCESS_LVL_USER;
- else if (!strcmp(args[cur_arg+1], "operator"))
- conf->level = ACCESS_LVL_OPER;
- else if (!strcmp(args[cur_arg+1], "admin"))
- conf->level = ACCESS_LVL_ADMIN;
- else {
+ if (!strcmp(args[cur_arg+1], "user")) {
+ conf->level &= ~ACCESS_LVL_MASK;
+ conf->level |= ACCESS_LVL_USER;
+ } else if (!strcmp(args[cur_arg+1], "operator")) {
+ conf->level &= ~ACCESS_LVL_MASK;
+ conf->level |= ACCESS_LVL_OPER;
+ } else if (!strcmp(args[cur_arg+1], "admin")) {
+ conf->level &= ~ACCESS_LVL_MASK;
+ conf->level |= ACCESS_LVL_ADMIN;
+ } else {
memprintf(err, "'%s' only supports 'user', 'operator', and 'admin' (got '%s')",
args[cur_arg], args[cur_arg+1]);
return ERR_ALERT | ERR_FATAL;
/* any other information should be dumped here */
- if (target && strm_li(s)->bind_conf->level < ACCESS_LVL_OPER)
+ if (target && (strm_li(s)->bind_conf->level & ACCESS_LVL_MASK) < ACCESS_LVL_OPER)
chunk_appendf(msg, "# contents not dumped due to insufficient privileges\n");
if (bi_putchk(si_ic(si), msg) == -1) {
return 0;
if (appctx->ctx.table.target &&
- strm_li(s)->bind_conf->level >= ACCESS_LVL_OPER) {
+ (strm_li(s)->bind_conf->level & ACCESS_LVL_MASK) >= ACCESS_LVL_OPER) {
/* dump entries only if table explicitly requested */
eb = ebmb_first(&appctx->ctx.table.proxy->table.keys);
if (eb) {