pjsip: Update ACLs on named ACL changes.

This change extends the Sorcery API to allow a wizard to be
told to explicitly reload objects or a specific object type
even if the wizard believes that nothing has changed.

This has been leveraged by res_pjsip and res_pjsip_acl to
reload endpoints and PJSIP ACLs when a named ACL changes.

ASTERISK-28697

Change-Id: Ib8fee9bd9dd490db635132c479127a4114c1ca0b
This commit is contained in:
Joshua C. Colp
2020-02-18 13:10:16 +00:00
committed by Joshua Colp
parent 78b01f41ae
commit d6712790cd
5 changed files with 112 additions and 1 deletions

View File

@@ -34,6 +34,8 @@
#include "asterisk/statsd.h"
#include "asterisk/pbx.h"
#include "asterisk/stream.h"
#include "asterisk/stasis.h"
#include "asterisk/security_events.h"
/*! \brief Number of buckets for persistent endpoint information */
#define PERSISTENT_BUCKETS 53
@@ -49,6 +51,8 @@ static struct ao2_container *persistent_endpoints;
static struct ast_sorcery *sip_sorcery;
static struct stasis_subscription *acl_change_sub;
/*! \brief Hashing function for persistent endpoint information */
static int persistent_endpoint_hash(const void *obj, const int flags)
{
@@ -1787,6 +1791,16 @@ static void load_all_endpoints(void)
ao2_cleanup(endpoints);
}
static void acl_change_stasis_cb(void *data, struct stasis_subscription *sub,
struct stasis_message *message)
{
if (stasis_message_type(message) != ast_named_acl_change_type()) {
return;
}
ast_sorcery_force_reload_object(sip_sorcery, "endpoint");
}
int ast_res_pjsip_initialize_configuration(void)
{
if (ast_manager_register_xml(AMI_SHOW_ENDPOINTS, EVENT_FLAG_SYSTEM, ami_show_endpoints) ||
@@ -2007,6 +2021,10 @@ int ast_res_pjsip_initialize_configuration(void)
ast_sip_location_prune_boot_contacts();
acl_change_sub = stasis_subscribe(ast_security_topic(), acl_change_stasis_cb, NULL);
stasis_subscription_accept_message_type(acl_change_sub, ast_named_acl_change_type());
stasis_subscription_set_filter(acl_change_sub, STASIS_SUBSCRIPTION_FILTER_SELECTIVE);
return 0;
}
@@ -2016,6 +2034,7 @@ void ast_res_pjsip_destroy_configuration(void)
return;
}
acl_change_sub = stasis_unsubscribe_and_join(acl_change_sub);
ast_sip_destroy_sorcery_global();
ast_sip_destroy_sorcery_location();
ast_sip_destroy_sorcery_auth();