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;
271 if (append_ha_error) {
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);
589 .
requires =
"extconfig",
Access Control of various sorts.
void ast_free_ha(struct ast_ha *ha)
Free a list of HAs.
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
void ast_ha_output(int fd, const struct ast_ha *ha, const char *prefix)
output an HA to the provided fd
struct ast_ha * ast_duplicate_ha_list(struct ast_ha *original)
Duplicate the contents of a list of host access rules.
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.
Asterisk main include file. File version handling, generic pbx functions.
#define ast_strdup(str)
A wrapper for strdup()
#define ao2_iterator_next(iter)
@ AO2_ALLOC_OPT_LOCK_MUTEX
#define AO2_STRING_FIELD_CMP_FN(stype, field)
Creates a compare function for a structure string field.
#define ao2_global_obj_ref(holder)
Get a reference to the object stored in the global holder.
#define ao2_find(container, arg, flags)
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
#define ao2_global_obj_release(holder)
Release the ao2 object held in the global holder.
#define AO2_STRING_FIELD_HASH_FN(stype, field)
Creates a hash function for a structure string field.
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
#define ao2_alloc(data_size, destructor_fn)
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
Allocate and initialize a hash container with the desired number of buckets.
static struct console_pvt globals
Standard Command Line Interface.
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
#define AST_CLI_DEFINE(fn, txt,...)
int ast_cli_completion_add(char *value)
Add a result to a request for completion options.
void ast_cli(int fd, const char *fmt,...)
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Configuration option-handling.
void aco_info_destroy(struct aco_info *info)
Destroy an initialized aco_info struct.
aco_process_status
Return values for the aco_process functions.
@ ACO_PROCESS_UNCHANGED
The config had not been edited and no changes applied.
@ ACO_PROCESS_ERROR
Their was an error and no changes were applied.
int aco_info_init(struct aco_info *info)
Initialize an aco_info structure.
#define FLDSET(type,...)
Convert a struct and list of fields to an argument list of field offsets.
#define aco_option_register(info, name, matchtype, types, default_val, opt_type, flags,...)
Register a config option.
@ OPT_ACL_T
Type for default option handler for ACLs.
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.
#define ACO_TYPES(...)
A helper macro to ensure that aco_info types always have a sentinel.
Configuration File Parser.
char * ast_category_browse(struct ast_config *config, const char *prev_name)
Browse categories.
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.
struct ast_config * ast_load_realtime_multientry(const char *family,...) attribute_sentinel
Retrieve realtime configuration.
int ast_realtime_is_mapping_defined(const char *family)
Determine if a mapping exists for a given family.
int ast_check_realtime(const char *family)
Check if realtime engine is configured for family.
void ast_config_destroy(struct ast_config *cfg)
Destroys a config.
const char * ast_variable_retrieve(struct ast_config *config, const char *category, const char *variable)
struct ast_variable * ast_category_first(struct ast_category *cat)
given a pointer to a category, return the root variable.
Asterisk JSON abstraction layer.
struct ast_json * ast_json_string_create(const char *value)
Construct a JSON string from value.
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
struct ast_json * ast_json_object_create(void)
Create a new JSON object.
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.
int ast_json_object_set(struct ast_json *object, const char *key, struct ast_json *value)
Set a field in a JSON object.
Asterisk module definitions.
@ AST_MODFLAG_GLOBAL_SYMBOLS
#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...)
@ AST_MODULE_SUPPORT_CORE
#define ASTERISK_GPL_KEY
The text the key() function should return.
@ AST_MODULE_LOAD_FAILURE
Module could not be loaded properly.
@ AST_MODULE_LOAD_SUCCESS
struct aco_file named_acl_conf
struct aco_type * named_acl_types[]
static void named_acl_config_destructor(void *obj)
destructor for named_acl_config
static void * named_acl_alloc(const char *cat)
Create a named ACL structure.
static void * named_acl_find(struct ao2_container *container, const char *cat)
Find a named ACL in a container by its name.
static struct named_acl * named_acl_find_realtime(const char *name)
static void destroy_named_acl(void *obj)
Destroy a named ACL object.
static AO2_GLOBAL_OBJ_STATIC(globals)
static int reload_module(void)
struct ast_ha * ast_named_acl_find(const char *name, int *is_realtime, int *is_undefined)
Retrieve a named ACL.
static int acl_order_comparator(struct ast_category *p, struct ast_category *q)
static void cli_display_named_acl_list(int fd)
CONFIG_INFO_CORE("named_acl", cfg_info, globals, named_acl_config_alloc,.files=ACO_FILES(&named_acl_conf),)
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 int load_module(void)
static struct ast_cli_entry cli_named_acl[]
static int unload_module(void)
static int publish_acl_change(const char *name)
static void cli_display_named_acl(int fd, const char *name)
static struct aco_type named_acl_type
STASIS_MESSAGE_TYPE_DEFN(ast_named_acl_change_type)
Message type for named ACL changes.
static char * handle_show_named_acl_cmd(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
ACL command show <name>
Asterisk file paths, configured in asterisk.conf.
const char * ast_config_AST_SYSTEM_NAME
struct ao2_container * container
Security Event Reporting API.
struct stasis_topic * ast_security_topic(void)
A stasis_topic which publishes messages for security related issues.
Stasis Message Bus API. See Stasis Message Bus API for detailed documentation.
#define STASIS_MESSAGE_TYPE_CLEANUP(name)
Boiler-plate messaging macro for cleaning up message types.
#define STASIS_MESSAGE_TYPE_INIT(name)
Boiler-plate messaging macro for initializing message types.
struct stasis_message * stasis_message_create(struct stasis_message_type *type, void *data)
Create a new message.
void stasis_publish(struct stasis_topic *topic, struct stasis_message *message)
Publish a message to a topic's subscribers.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
The representation of a single configuration file to be processed.
Type information about a category-level configurable object.
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
descriptor for a cli entry.
internal representation of ACL entries In principle user applications would have no need for this,...
Abstract JSON element (object, array, string, int, ...).
Structure for variables, used for configurations and for channel variables.
struct ast_variable * next
struct ao2_container * named_acl_list
char name[ACL_NAME_LENGTH]
static struct aco_type item
int error(const char *format,...)
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.