manager: Fix incomplete filtering of AMI events.

The global event filtering code was only in one
possible execution path, so not all events were
being properly filtered out if requested. This moves
that into the universal AMI handling code so all
events are properly handled.

Additionally, the CLI listing of disabled events can
also get truncated, so we now print out everything.

ASTERISK-30137 #close

Change-Id: If8c42edcb2abc5158552da7eba2a8ff6b20e1959
This commit is contained in:
Naveen Albert 2022-07-12 21:38:12 +00:00 committed by George Joseph
parent e8205fb166
commit 4efea4780b
1 changed files with 12 additions and 11 deletions

View File

@ -7133,6 +7133,14 @@ static int __attribute__((format(printf, 9, 0))) __manager_event_sessions_va(
struct ast_str *buf;
int i;
if (!ast_strlen_zero(manager_disabledevents)) {
if (ast_in_delimited_string(event, manager_disabledevents, ',')) {
ast_debug(3, "AMI Event '%s' is globally disabled, skipping\n", event);
/* Event is globally disabled */
return -1;
}
}
buf = ast_str_thread_get(&manager_event_buf, MANAGER_EVENT_BUF_INITSIZE);
if (!buf) {
return -1;
@ -7244,15 +7252,6 @@ int __ast_manager_event_multichan(int category, const char *event, int chancount
va_list ap;
int res;
if (!ast_strlen_zero(manager_disabledevents)) {
if (ast_in_delimited_string(event, manager_disabledevents, ',')) {
ast_debug(3, "AMI Event '%s' is globally disabled, skipping\n", event);
/* Event is globally disabled */
ao2_cleanup(sessions);
return 0;
}
}
if (!any_manager_listeners(sessions)) {
/* Nobody is listening */
ao2_cleanup(sessions);
@ -8699,6 +8698,7 @@ static char *handle_manager_show_settings(struct ast_cli_entry *e, int cmd, stru
}
#define FORMAT " %-25.25s %-15.55s\n"
#define FORMAT2 " %-25.25s %-15d\n"
#define FORMAT3 " %-25.25s %s\n"
if (a->argc != 3) {
return CLI_SHOWUSAGE;
}
@ -8716,11 +8716,12 @@ static char *handle_manager_show_settings(struct ast_cli_entry *e, int cmd, stru
ast_cli(a->fd, FORMAT, "Allow multiple login:", AST_CLI_YESNO(allowmultiplelogin));
ast_cli(a->fd, FORMAT, "Display connects:", AST_CLI_YESNO(displayconnects));
ast_cli(a->fd, FORMAT, "Timestamp events:", AST_CLI_YESNO(timestampevents));
ast_cli(a->fd, FORMAT, "Channel vars:", S_OR(manager_channelvars, ""));
ast_cli(a->fd, FORMAT, "Disabled events:", S_OR(manager_disabledevents, ""));
ast_cli(a->fd, FORMAT3, "Channel vars:", S_OR(manager_channelvars, ""));
ast_cli(a->fd, FORMAT3, "Disabled events:", S_OR(manager_disabledevents, ""));
ast_cli(a->fd, FORMAT, "Debug:", AST_CLI_YESNO(manager_debug));
#undef FORMAT
#undef FORMAT2
#undef FORMAT3
return CLI_SUCCESS;
}