acl: implement a centralized ACL output mechanism for HAs and ACLs.

named_acl.c (which is really a named_ha) now uses ast_ha_output.

I've also updated main/manager.c to output the actual ACL on "manager
show user <username>" if one is set.  If this works then we can add
similar to other modules as required.

Change-Id: I0ec9876a90dddd379c80ec078d48e3ee6991eb0f
This commit is contained in:
Jaco Kroon
2020-03-18 15:49:56 +02:00
committed by Joshua Colp
parent ebe7749127
commit 85fca26c24
4 changed files with 65 additions and 8 deletions

View File

@@ -411,8 +411,6 @@ publish_failure:
*/
static void cli_display_named_acl(int fd, const char *name)
{
struct ast_ha *ha;
int ha_index = 0;
int is_realtime = 0;
RAII_VAR(struct named_acl_config *, cfg, ao2_global_obj_ref(globals), ao2_cleanup);
@@ -437,12 +435,7 @@ static void cli_display_named_acl(int fd, const char *name)
}
ast_cli(fd, "\nACL: %s%s\n---------------------------------------------\n", name, is_realtime ? " (realtime)" : "");
for (ha = named_acl->ha; ha; ha = ha->next) {
char *addr = ast_strdupa(ast_sockaddr_stringify_addr(&ha->addr));
char *mask = ast_sockaddr_stringify_addr(&ha->netmask);
ast_cli(fd, "%3d: %s - %s/%s\n", ha_index, ha->sense == AST_SENSE_ALLOW ? "allow" : " deny", addr, mask);
ha_index++;
}
ast_ha_output(fd, named_acl->ha, NULL);
}
/*!