33 #define AST_MODULE "acl" 49 #define NACL_CONFIG "acl.conf" 50 #define ACL_FAMILY "acls" 89 .category =
"general",
135 named_acl_hash_fn,
NULL, named_acl_cmp_fn);
203 int p_value = 0, q_value = 0;
208 if (!strcasecmp(p_var->
name,
"rule_order")) {
209 p_value = atoi(p_var->
value);
216 if (!strcasecmp(q_var->
name,
"rule_order")) {
217 q_value = atoi(q_var->
value);
223 if (p_value < q_value) {
225 }
else if (q_value < p_value) {
244 const char *systemname =
NULL;
265 int append_ha_error = 0;
270 built_ha =
ast_append_ha(sense, rule, built_ha, &append_ha_error);
271 if (append_ha_error) {
273 ast_log(
LOG_ERROR,
"Rejecting realtime ACL due to bad ACL definition '%s': %s - %s - %s\n", name, order, sense, rule);
309 if ((!cfg) || (!(cfg->named_acl_list))) {
310 ast_log(
LOG_ERROR,
"Attempted to find named ACL '%s', but the ACL configuration isn't available.\n", name);
331 ast_log(
LOG_WARNING,
"ACL '%s' does not exist. The ACL will be marked as undefined and will automatically fail if applied.\n" 332 "This ACL may exist in the configured realtime backend, but that backend hasn't been registered yet. " 333 "Fix this establishing preload for the backend in 'modules.conf'.\n", name);
335 ast_log(
LOG_WARNING,
"ACL '%s' does not exist. The ACL will be marked as undefined and will automatically fail if applied.\n", name);
348 ast_log(
LOG_NOTICE,
"ACL '%s' contains no rules. It is valid, but it will accept addresses unconditionally.\n", name);
378 goto publish_failure;
382 goto publish_failure;
386 goto publish_failure;
392 goto publish_failure;
420 if ((!cfg) || (!cfg->named_acl_list)) {
421 ast_log(
LOG_ERROR,
"Attempted to show named ACL '%s', but the acl configuration isn't available.\n", name);
430 ast_cli(fd,
"\nCould not find ACL named '%s'\n", name);
437 ast_cli(fd,
"\nACL: %s%s\n---------------------------------------------\n", name, is_realtime ?
" (realtime)" :
"");
455 if (!cfg || !cfg->named_acl_list) {
456 ast_cli(fd,
"ACL configuration isn't available.\n");
482 "Usage: acl show [name]\n" 483 " Shows a list of named ACLs or lists all entries in a given named ACL.\n";
494 length = strlen(a->
word);
497 if (!strncasecmp(a->
word, named_acl->
name, length)) {
589 .requires =
"extconfig",
struct ast_variable * next
struct ast_ha * ast_duplicate_ha_list(struct ast_ha *original)
Duplicate the contents of a list of host access rules.
static int reload_module(void)
#define AST_CLI_DEFINE(fn, txt,...)
static struct aco_type named_acl_type
Asterisk main include file. File version handling, generic pbx functions.
Security Event Reporting API.
CONFIG_INFO_CORE("named_acl", cfg_info, globals, named_acl_config_alloc,.files=ACO_FILES(&named_acl_conf),)
STASIS_MESSAGE_TYPE_DEFN(ast_named_acl_change_type)
Message type for named ACL changes.
#define AO2_STRING_FIELD_HASH_FN(stype, field)
Creates a hash function for a structure string field.
static int publish_acl_change(const char *name)
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
struct ast_json_payload * ast_json_payload_create(struct ast_json *json)
Create an ao2 object to pass json blobs as data payloads for stasis.
struct ao2_container * named_acl_list
struct stasis_topic * ast_security_topic(void)
A stasis_topic which publishes messages for security related issues.
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
#define STASIS_MESSAGE_TYPE_INIT(name)
Boiler-plate messaging macro for initializing message types.
Stasis Message Bus API. See Stasis Message Bus API for detailed documentation.
descriptor for a cli entry.
static char * handle_show_named_acl_cmd(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
#define aco_option_register(info, name, matchtype, types, default_val, opt_type, flags,...)
Register a config option.
int ast_check_realtime(const char *family)
Check if realtime engine is configured for family.
Structure for variables, used for configurations and for channel variables.
#define STASIS_MESSAGE_TYPE_CLEANUP(name)
Boiler-plate messaging macro for cleaning up message types.
struct stasis_message_type * ast_named_acl_change_type(void)
a stasis_message_type for changes against a named ACL or the set of all named ACLs ...
static struct named_acl * named_acl_find_realtime(const char *name)
#define ast_cli_register_multiple(e, len)
Register multiple commands.
enum aco_process_status aco_process_config(struct aco_info *info, int reload)
Process a config info via the options registered with an aco_info.
static struct aco_type item
#define ao2_global_obj_ref(holder)
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
#define ast_strdup(str)
A wrapper for strdup()
char * ast_category_browse(struct ast_config *config, const char *prev_name)
Browse categories.
The representation of a single configuration file to be processed.
void ast_cli(int fd, const char *fmt,...)
#define ACO_TYPES(...)
A helper macro to ensure that aco_info types always have a sentinel.
int ast_json_object_set(struct ast_json *object, const char *key, struct ast_json *value)
Set a field in a JSON object.
static void destroy_named_acl(void *obj)
Destroy a named ACL object.
#define ast_strlen_zero(foo)
const char * ast_config_AST_SYSTEM_NAME
static int load_module(void)
internal representation of ACL entries In principle user applications would have no need for this...
Configuration File Parser.
#define FLDSET(type,...)
Convert a struct and list of fields to an argument list of field offsets.
int aco_info_init(struct aco_info *info)
Initialize an aco_info structure.
Asterisk JSON abstraction layer.
static void cli_display_named_acl_list(int fd)
Asterisk file paths, configured in asterisk.conf.
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
struct ast_json * ast_json_string_create(const char *value)
Construct a JSON string from value.
Access Control of various sorts.
static AO2_GLOBAL_OBJ_STATIC(globals)
#define ao2_ref(o, delta)
struct ast_variable * ast_category_first(struct ast_category *cat)
given a pointer to a category, return the root variable.
void ast_config_destroy(struct ast_config *config)
Destroys a config.
aco_process_status
Return values for the aco_process functions.
struct ao2_container * container
static struct console_pvt globals
The config had not been edited and no changes applied.
Their was an error and no changes were applied.
Configuration option-handling.
struct ast_config * ast_load_realtime_multientry(const char *family,...) attribute_sentinel
Retrieve realtime configuration.
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
static void cli_display_named_acl(int fd, const char *name)
void aco_info_destroy(struct aco_info *info)
Destroy an initialized aco_info struct.
struct stasis_message * stasis_message_create(struct stasis_message_type *type, void *data)
Create a new message.
#define ao2_global_obj_release(holder)
static void * named_acl_alloc(const char *cat)
Create a named ACL structure.
struct aco_type * named_acl_types[]
#define ao2_iterator_next(iter)
#define ao2_alloc(data_size, destructor_fn)
void stasis_publish(struct stasis_topic *topic, struct stasis_message *message)
Publish a message to a topic's subscribers.
Type for default option handler for ACLs.
Module could not be loaded properly.
static int acl_order_comparator(struct ast_category *p, struct ast_category *q)
int ast_realtime_is_mapping_defined(const char *family)
Determine if a mapping exists for a given family.
static void * named_acl_find(struct ao2_container *container, const char *cat)
Find a named ACL in a container by its name.
#define ao2_find(container, arg, flags)
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS|AST_MODFLAG_LOAD_ORDER, "HTTP Phone Provisioning",.support_level=AST_MODULE_SUPPORT_EXTENDED,.load=load_module,.unload=unload_module,.reload=reload,.load_pri=AST_MODPRI_CHANNEL_DEPEND,.requires="http",)
void ast_free_ha(struct ast_ha *ha)
Free a list of HAs.
struct ast_json * ast_json_object_create(void)
Create a new JSON object.
const char * ast_variable_retrieve(struct ast_config *config, const char *category, const char *variable)
#define AO2_STRING_FIELD_CMP_FN(stype, field)
Creates a compare function for a structure string field.
struct ast_ha * ast_named_acl_find(const char *name, int *is_realtime, int *is_undefined)
Retrieve a named ACL.
static int unload_module(void)
struct aco_file named_acl_conf
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
void ast_config_sort_categories(struct ast_config *config, int descending, int(*comparator)(struct ast_category *p, struct ast_category *q))
Sorts categories in a config in the order of a numerical value contained within them.
Standard Command Line Interface.
Type information about a category-level configurable object.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
static void named_acl_config_destructor(void *obj)
destructor for named_acl_config
void ast_ha_output(int fd, const struct ast_ha *ha, const char *prefix)
output an HA to the provided fd
static void * named_acl_config_alloc(void)
allocator callback for named_acl_config. Notice it returns void * since it is used by the backend con...
static struct ast_cli_entry cli_named_acl[]
Abstract JSON element (object, array, string, int, ...).
struct ast_ha * ast_append_ha(const char *sense, const char *stuff, struct ast_ha *path, int *error)
Add a new rule to a list of HAs.
int error(const char *format,...)
int ast_cli_completion_add(char *value)
Add a result to a request for completion options.
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.
char name[ACL_NAME_LENGTH]