69        e->
command = 
"core show functions [like]";
 
   71            "Usage: core show functions [like <text>]\n" 
   72            "       List builtin functions, optionally only those matching a given string\n";
 
   78    if (
a->argc == 5 && (!strcmp(
a->argv[3], 
"like")) ) {
 
   80    } 
else if (
a->argc != 3) {
 
   84    ast_cli(
a->fd, 
"%s Custom Functions:\n" 
   85        "--------------------------------------------------------------------------------\n",
 
   86        like ? 
"Matching" : 
"Installed");
 
   90        if (!like || strstr(acf->
name, 
a->argv[4])) {
 
   92            ast_cli(
a->fd, 
"%-20.20s  %-35.35s  %s\n",
 
  100    ast_cli(
a->fd, 
"%d %scustom functions installed.\n", count_acf, like ? 
"matching " : 
"");
 
 
  117    wordlen = strlen(
word);
 
  127        cmp = strncasecmp(
word, cur->
name, wordlen);
 
  130            if (++which <= 
state) {
 
 
  152        e->
command = 
"core show function";
 
  154            "Usage: core show function <function>\n" 
  155            "       Describe a particular dialplan function.\n";
 
  166        ast_cli(
a->fd, 
"No function by that name registered.\n");
 
  196        "%s  -= Info about Function '%s' =- %s\n\n" 
 
  278        ast_verb(5, 
"Unregistered custom function %s\n", cur->
name);
 
 
  400        if (strcmp(acf->
name, cur->
name) < 0) {
 
 
  426    switch (escalation) {
 
 
  449    char *
args = strchr(function, 
'(');
 
  452        ast_log(
LOG_WARNING, 
"Function '%s' doesn't contain parentheses.  Assuming null argument.\n", function);
 
  456        if ((p = strrchr(
args, 
')'))) {
 
 
  469            "See https://docs.asterisk.org/Configuration/Dialplan/Privilege-Escalations-with-Dialplan-Functions/ for more details.\n");
 
 
  480    int *thread_inhibit_escalations;
 
  483        &thread_inhibit_escalations_tl, 
sizeof(*thread_inhibit_escalations));
 
  484    if (thread_inhibit_escalations == 
NULL) {
 
  485        ast_log(
LOG_ERROR, 
"Error inhibiting privilege escalations for current thread\n");
 
  489    *thread_inhibit_escalations = 1;
 
 
  495    int *thread_inhibit_escalations;
 
  499        &thread_inhibit_escalations_tl, 
sizeof(*thread_inhibit_escalations));
 
  500    if (thread_inhibit_escalations == 
NULL) {
 
  501        ast_log(
LOG_ERROR, 
"Error swapping privilege escalations inhibit for current thread\n");
 
  505    orig = *thread_inhibit_escalations;
 
  506    *thread_inhibit_escalations = !!inhibit;
 
 
  519    int *thread_inhibit_escalations;
 
  522        &thread_inhibit_escalations_tl, 
sizeof(*thread_inhibit_escalations));
 
  523    if (thread_inhibit_escalations == 
NULL) {
 
  524        ast_log(
LOG_ERROR, 
"Error checking thread's ability to run dangerous functions\n");
 
  529    return *thread_inhibit_escalations;
 
 
  556        ast_debug(2, 
"Reading %s from a dangerous context\n",
 
 
  589        ast_debug(2, 
"Writing %s from a dangerous context\n",
 
 
  606    if (acfptr == 
NULL) {
 
  608    } 
else if (!acfptr->
read && !acfptr->
read2) {
 
  612    } 
else if (acfptr->
read) {
 
  617        if (acfptr->
mod && u) {
 
  629        if (acfptr->
mod && u) {
 
 
  649    if (acfptr == 
NULL) {
 
  651    } 
else if (!acfptr->
read && !acfptr->
read2) {
 
  682        if (acfptr->
mod && u) {
 
 
  698    if (acfptr == 
NULL) {
 
  700    } 
else if (!acfptr->
write) {
 
  712        if (acfptr->
mod && u) {
 
 
Prototypes for public functions only of internal interest,.
void ast_cli_unregister_multiple(void)
static int copy(char *infile, char *outfile)
Utility function to copy a file.
Asterisk main include file. File version handling, generic pbx functions.
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
#define ast_strdup(str)
A wrapper for strdup()
#define ast_strdupa(s)
duplicate a string in memory from the stack
Standard Command Line Interface.
#define AST_CLI_DEFINE(fn, txt,...)
void ast_cli(int fd, const char *fmt,...)
#define ast_cli_register_multiple(e, len)
Register multiple commands.
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
#define ast_debug(level,...)
Log a DEBUG message.
#define ast_verb(level,...)
A set of macros to manage forward-linked lists.
#define AST_RWLIST_RDLOCK(head)
Read locks a list.
#define AST_RWLIST_TRAVERSE_SAFE_BEGIN
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
#define AST_RWLIST_HEAD_STATIC(name, type)
Defines a structure to be used to hold a read/write list of specified type, statically initialized.
#define AST_RWLIST_REMOVE
#define AST_RWLIST_TRAVERSE_SAFE_END
#define AST_RWLIST_TRAVERSE
#define AST_RWLIST_INSERT_TAIL
#define AST_RWLIST_INSERT_BEFORE_CURRENT
Asterisk module definitions.
struct ast_module_user * __ast_module_user_add(struct ast_module *, struct ast_channel *)
const char * ast_module_name(const struct ast_module *mod)
Get the name of a module.
void __ast_module_user_remove(struct ast_module *, struct ast_module_user *)
Core PBX routines and definitions.
ast_custom_function_escalation
Description of the ways in which a function may escalate privileges.
static int thread_inhibits_escalations(void)
Indicates whether the current thread inhibits the execution of dangerous functions.
static int is_read_allowed(struct ast_custom_function *acfptr)
Determines whether execution of a custom function's read function is allowed.
static int read_escalates(const struct ast_custom_function *acf)
Returns true if given custom function escalates privileges on read.
void pbx_live_dangerously(int new_live_dangerously)
Enable/disable the execution of 'dangerous' functions from external protocols (AMI,...
int ast_thread_inhibit_escalations_swap(int inhibit)
Swap the current thread escalation inhibit setting.
int __ast_custom_function_register_escalating(struct ast_custom_function *acf, enum ast_custom_function_escalation escalation, struct ast_module *mod)
Register a custom function which requires escalated privileges.
static struct ast_custom_function * ast_custom_function_find_nolock(const char *name)
static int write_escalates(const struct ast_custom_function *acf)
Returns true if given custom function escalates privileges on write.
struct ast_custom_function * ast_custom_function_find(const char *name)
int load_pbx_functions_cli(void)
static int acf_retrieve_docs(struct ast_custom_function *acf)
static void unload_pbx_functions_cli(void)
static int live_dangerously
Set to true (non-zero) to globally allow all dangerous dialplan functions to run.
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
static char * complete_functions(const char *word, int pos, int state)
int ast_func_read2(struct ast_channel *chan, const char *function, struct ast_str **str, ssize_t maxlen)
executes a read operation on a function
static char * handle_show_functions(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
int ast_func_read(struct ast_channel *chan, const char *function, char *workspace, size_t len)
executes a read operation on a function
static char * handle_show_function(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
int __ast_custom_function_register(struct ast_custom_function *acf, struct ast_module *mod)
Register a custom function.
static int is_write_allowed(struct ast_custom_function *acfptr)
Determines whether execution of a custom function's write function is allowed.
static char * func_args(char *function)
return a pointer to the arguments of the function, and terminates the function name with '\0'
int ast_func_write(struct ast_channel *chan, const char *function, const char *value)
executes a write operation on a function
int ast_thread_inhibit_escalations(void)
Inhibit (in the current thread) the execution of dialplan functions which cause privilege escalations...
static struct ast_cli_entry acf_cli[]
Private include file for pbx.
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
#define ast_string_field_init(x, size)
Initialize a field pool and fields.
#define ast_string_field_init_extended(x, field)
Initialize an extended string field.
#define ast_string_field_free_memory(x)
free all memory - to be called before destroying the object
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
void ast_str_reset(struct ast_str *buf)
Reset the content of a dynamic string. Useful before a series of ast_str_append.
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
#define ast_str_make_space(buf, new_len)
void ast_str_update(struct ast_str *buf)
Update the length of the buffer, after using ast_str merely as a buffer.
char *attribute_pure ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
size_t attribute_pure ast_str_size(const struct ast_str *buf)
Returns the current maximum length (without reallocation) of the current buffer.
Registered functions container.
Main Channel structure associated with a channel.
descriptor for a cli entry.
Data structure associated with a custom dialplan function.
const ast_string_field desc
const ast_string_field synopsis
struct ast_custom_function::@256 acflist
const ast_string_field seealso
const ast_string_field syntax
const ast_string_field arguments
unsigned int read_escalates
unsigned int write_escalates
struct ast_channel * chan
Support for dynamic strings.
Handy terminal functions for vt* terms.
const char * ast_term_reset(void)
Returns the terminal reset code.
const char * ast_term_color(int fgcolor, int bgcolor)
Return a color sequence string.
#define COLORIZE(fg, bg, str)
#define COLORIZE_FMT
Shortcut macros for coloring a set of text.
Definitions to aid in the use of thread local storage.
void * ast_threadstorage_get(struct ast_threadstorage *ts, size_t init_size)
Retrieve thread storage.
#define AST_THREADSTORAGE(name)
Define a thread storage variable.
Asterisk XML Documentation API.
char * ast_xmldoc_build_description(const char *type, const char *name, const char *module)
Generate description documentation from XML.
char * ast_xmldoc_build_syntax(const char *type, const char *name, const char *module)
Get the syntax for a specified application or function.
char * ast_xmldoc_build_arguments(const char *type, const char *name, const char *module)
Generate the [arguments] tag based on type of node ('application', 'function' or 'agi') and name.
char * ast_xmldoc_build_synopsis(const char *type, const char *name, const char *module)
Generate synopsis documentation from XML.
char * ast_xmldoc_build_since(const char *type, const char *name, const char *module)
Parse the <since> node content.
char * ast_xmldoc_build_seealso(const char *type, const char *name, const char *module)
Parse the <see-also> node content.
char * ast_xmldoc_printable(const char *bwinput, int withcolors)
Colorize and put delimiters (instead of tags) to the xmldoc output.