This change adds statistics gathering to Stasis topics,
subscriptions, and message types. These can be viewed using
CLI commands and provide insight into how Stasis is used
and how long certain operations take to execute.
These are only available when Asterisk is compiled in
developer mode and do not have any impact under normal
operation.
ASTERISK-28117
Change-Id: I94411b53767f89ee01714daaecf0c2f1666e863f
We cannot use need_el_end and SIGURG when restarting. Instead we need
to run el_end within the SIGHUP restartnow handler.
ASTERISK-28158
Change-Id: Ia852276363c81bdcf1aa29eb4558c5c2fa1218a0
* Ignore console=yes configuration option in remote console processes.
* Use new flag to tell consolethread to run el_end and exit when needed.
ASTERISK-28158
Change-Id: I9e23b31d4211417ddc88c6bbfd83ea4c9f3e5438
Changing any Menuselect option in the `Compiler Flags` section causes a
full rebuild of the Asterisk source tree. Every enabled option causes
a #define to be added to buildopts.h, thus breaking ccache caching for
every source file that includes "asterisk.h". In most cases each option
only applies to one or two files. Now we only define those options for
the specific sources which use them, this causes much better cache
matching when working with multiple builds. For example testing code
with an without MALLOC_DEBUG will now use just over half the ccache
size, only main/astmm.o will have two builds cached instead of every
file.
Reorder main/Makefile so _ASTCFLAGS set on specific object files are all
together, sorted by filename. Stop adding -DMALLOC_DEBUG to CFLAGS of
bundled pjproject, this define is no longer used by any header so only
serves to break cache.
The only code change is a slight adjustment to how main/astmm.c is
initialized. Initialization functions always exist so main/asterisk.c
can call them unconditionally. Additionally rename the astmm
initialization functions so they are not exported.
Change-Id: Ie2085237a964f6e1e6fff55ed046e2afff83c027
* Merge the preload and load stages, use load ordering to try preload's
first. This fixes an issue where `preload=res_config_curl` would fail
unless res_curl and func_curl were also preloaded. Now it is only
required that those modules be loaded during startup: autoload or
regular load is good enough.
* The configuration option `require` and `preload-require` were only
effective if the modules failed to load. These options will now abort
Asterisk startup if required modules fail to reach the 'Running'
state.
* Missing or invalid 'module.conf' did not prevent startup. Asterisk
doesn't do anything without modules so this a fatal error.
Change-Id: Ie4176699133f0e3a823b43f90c3348677e43a5f3
Setting optind = 0 is forced to 1 in glibc implementation, but
causes option parsing to be flawed in other implementations, for
example on FreeBSD.
ASTERISK-27773 #close
Change-Id: Ia548e69f8302e9754dbbedb6bc451c0700c66f61
This creates a separate source to 'own' symbols related to options.h and
paths.h. This significantly reduces the number of exports created by
main/asterisk.o. This change is required to eventually be able to
link unmodified Asterisk sources to utilities and/or stand-alone tests.
ASTERISK~26245
Change-Id: I5cf184f4757f9363b80c9e678bdc35c477122380
If the two formats on a channel are equal, we don't transcode and since
the generic plc needs slin to work, it doesn't get invoked.
* A new configuration option "genericplc_on_equal_codecs" was added
to the "plc" section of codecs.conf to allow generic packet loss
concealment even if no transcoding was originally needed.
Transcoding via SLIN is forced in this case.
ASTERISK-27743
Change-Id: I0577026a179dea34232e63123254b4e0508378f4
* Define CHAR_T_LIBEDIT and CHAR_TO_LIBEDIT based on
HAVE_LIBEDIT_IS_UNICODE. This avoids needing to repeatedly use
conditional blocks, eliminates having multiple function prototypes.
* Remove parenthesis from return values.
* Add missing code block brackets {}.
* Reduce use of 'else' conditional statements where possible.
Change-Id: I4315328ebea2f62641faf6881de2ac20a9f9d08e
* acl (named_acl.c)
* cdr
* cel
* ccss
* dnsmgr
* dsp
* enum
* extconfig (config.c)
* features
* http
* indications
* logger
* manager
* plc
* sounds
* udptl
These modules are now loaded at appropriate time by the module loader.
Unlike loadable modules these use AST_MODULE_LOAD_FAILURE on error so
the module loader will abort startup on failure of these modules.
Some of these modules are still initialized or shutdown from outside the
module loader. logger.c is initialized very early and shutdown very
late, manager.c is initialized by the module loader but is shutdown by
the Asterisk core (too much uses it without holding references).
Change-Id: I371a9a45064f20026c492623ea8062d02a1ab97f
When built-in components of Asterisk fail to start they cause the
Asterisk startup to abort. In these cases only the most critical
cleanup should be performed - closing databases and terminating
proceses. These cleanups are registered using ast_register_atexit, all
other cleanups should not be run during startup abort.
The main reason for this change is that these cleanup procedures are
untestable from the partially initialized states, if they fail it could
prevent us from ever running the critical cleanup with ast_run_atexits.
Create separate initialization for dns_core.c to be run unconditionally
during startup instead of being initialized by the first dns resolver to
be registered. This ensures that 'sched' is initialized before it can be
potentially used.
Replace ast_register_atexit with ast_register_cleanup in media_cache.c.
There is no reason for this cleanup to happen unconditionally.
Change-Id: Iecc2df98008b21509925ff16740bd5fa29527db3
The pool cache gets in the way of finding use after free errors of memory
pool contents. Tools like valgrind and MALLOC_DEBUG don't know when a
pool is released because it gets put into the cache instead of being
freed.
* Added the "cache_pools" option to pjproject.conf. Disabling the option
helps track down pool content mismanagement when using valgrind or
MALLOC_DEBUG. The cache gets in the way of determining if the pool
contents are used after free and who freed it.
To disable the pool caching simply disable the cache_pools option in
pjproject.conf and restart Asterisk.
Sample pjproject.conf setting:
[startup]
cache_pools=no
* Made current users of the caching pool factory initialization and
destruction calls call common routines to create and destroy cached pools.
ASTERISK-27704
Change-Id: I64d5befbaeed2532f93aa027a51eb52347d2b828
This removes the embedded copy of editline from the Asterisk source
tree, making a system copy of libedit mandatory in Asterisk 16+.
ASTERISK-27634 #close
Change-Id: Iedb64ad92acb78419f3caefedaa2bb7cd2a1a33f
The previous fix broke the case
HAVE_SYSINFO = no
HAVE_SYSCTL = yes
HAVE_SWAPCTL = no
which occurs on FreeBSD 11.1 for example.
ASTERISK-26563
Change-Id: If77c39bc75f0b83a6c8a24ecb2fa69be8846160a
Move initialization of units which do not require configuration to occur
before preload modules. This leaves only units which load config between
module preload and regular load stages.
Change-Id: I1d15384acad16a22c3498124421af474fa517478
Apparently in OSX it's possible for OSX to HAVE_SYSCTL but not
HAVE_SYSINFO or HAVE_SWAPCTL. In this case freeswap caused an unused
variable error.
ASTERISK-26563 #close
Change-Id: I8ec5b1897b786cc1abaf62264aa75039eea05510
* listen uses the variable `s` for the result from ast_poll() then
overwrites it with the result of accept(). Create a separate variable
poll_result to avoid confusion since ast_poll does not return a file
descriptor.
* Resolve fd leak that would occur if setsockopt failed in listen.
* Reserve an extra byte while processing completion results from remote
daemon. This fixes a bug where completion processing used strstr() on
a string that was not '\0' terminated. This was no risk to the Asterisk
daemon, the bug was only reachable the remote console process.
* Resolve leak in handle_showchan when the channel is not found.
* Multiple leaks and a deadlock in pbx_config CLI completion.
* Fix leaks in "manager show command".
Change-Id: I8f633ceb1714867ae30ef4e421858f77c14485a9
rasterisk does not need to handle setting verbose levels locally, it
should just tell the daemon what it wants and print what it is given.
Just max out the verbose level on the local client so all filtering
happens on the daemon.
ASTERISK-20281 #close
Change-Id: Ia305f75f1fc424a9169bfa30ef70d626ace2c8a8
There are many places in the code base where we ignore the return value
of fcntl() when getting/setting file descriptior flags. This patch
introduces a convenience function that allows setting or clearing file
descriptor flags and will also log an error on failure for later
analysis.
Change-Id: I8b81901e1b1bd537ca632567cdb408931c6eded7
The sounds index is rebuilt each time a format is registered or
unregistered. This causes the index to be repeatedly rebuilt during
startup and shutdown.
This patch significantly reduces the work done by delaying sound index
initialization until after modules are loaded. This way a reindex only
occurs if a format module is loaded after startup. We also skip
reindexing when format modules are unloaded during shutdown.
Change-Id: I585fd6ee04200612ab1490dc804f76805f89cf0a
Previous commits maintained compatibility with older remote console
clients as well as maintaining all API's.
Remove the following compatibility code:
* ast_cli_generatornummatches.
* Remote command "_command nummatches".
* Sorting / duplicate removal by remote console.
Change-Id: I59e6ce94fa57ae564888442049695f7e46746437
* Stop using "_COMMAND NUMMATCHES" on remote consoles. Using this
command had doubled the amount of work needed from the Asterisk
daemon for each completion request.
* Fix code formatting.
* Remove static buffer used to send the command, use the same buffer
that will receive the results.
* Move sort from ast_cli_display_match_list.
Change-Id: Ie2211b519a3d4bec45bf46e0095bdd01d384cb69
This rewrites ast_el_strtoarr to use vector's internally, but still
return the original NULL terminated array of strings.
Change-Id: Ibfe776cbe14f750effa9ca360930acaccc02e957
* Stop estimating line count, just print until we run out of matches.
* Stop freeing entries, the caller does that anyways.
* Stop calculating / returning numoutput, it was ignored.
Change-Id: I7f92afa8bea92241a95227587367424c8c32a5cb
Reduce the signal monitoring thread file descriptor use from two to one
on systems that support eventfd.
Change-Id: Id4041a237d481ff699639e153ea6982fee14a462
The remote console socket path is the combination of asterisk.conf
settings astrundir from [directories] and astctl from [files].
Unconditionally combine the two strings after processing all values
to ensure we end up with the correct socket path.
ASTERISK-27415
Change-Id: Ib1e2805d55d6b0955c6430a1a2a93acbf9b091e8
The media frame cache gets in the way of finding use after free errors of
media frames. Tools like valgrind and MALLOC_DEBUG don't know when a
frame is released because it gets put into the cache instead of being
freed.
* Added the "cache_media_frames" option to asterisk.conf. Disabling the
option helps track down media frame mismanagement when using valgrind or
MALLOC_DEBUG. The cache gets in the way of determining if the frame is
used after free and who freed it. NOTE: This option has no effect when
Asterisk is compiled with the LOW_MEMORY compile time option enabled
because the cache code does not exist.
To disable the media frame cache simply disable the cache_media_frames
option in asterisk.conf and restart Asterisk.
Sample asterisk.conf setting:
[options]
cache_media_frames=no
ASTERISK-27413
Change-Id: I0ab2ce0f4547cccf2eb214901835c2d951b78c00
An admin can configure app_minivm with an externnotify program to be run
when a voicemail is received. The app_minivm application MinivmNotify
uses ast_safe_system() for this purpose which is vulnerable to command
injection since the Caller-ID name and number values given to externnotify
can come from an external untrusted source.
* Add ast_safe_execvp() function. This gives modules the ability to run
external commands with greater safety compared to ast_safe_system().
Specifically when some parameters are filled by untrusted sources the new
function does not allow malicious input to break argument encoding. This
may be of particular concern where CALLERID(name) or CALLERID(num) may be
used as a parameter to a script run by ast_safe_system() which could
potentially allow arbitrary command execution.
* Changed app_minivm.c:run_externnotify() to use the new ast_safe_execvp()
instead of ast_safe_system() to avoid command injection.
* Document code injection potential from untrusted data sources for other
shell commands that are under user control.
ASTERISK-27103
Change-Id: I7552472247a84cde24e1358aaf64af160107aef1
GCC 7 has added capability to produce warnings, this fixes most of those
warnings. The specific warnings are disabled in a few places:
* app_voicemail.c: truncation of paths more than 4096 chars in many places.
* chan_mgcp.c: callid truncated to 80 chars.
* cdr.c: two userfields are combined to cdr copy, fix would break ABI.
* tcptls.c: ignore use of deprecated method SSLv3_client_method().
ASTERISK-27156 #close
Change-Id: I65f280e7d3cfad279d16f41823a4d6fddcbc4c88
Setting maxfiles (maximum number of open files) has no practical
effect on a remote asterisk (rasterisk, rasterisk -x).
It has an ill effect of printing an extra message, which
may be annoying in case of -x.
ASTERISK-27105 #close
Change-Id: Iaf9eb344e4b4b517df91b736b27ec55f6a6921a2
This API was not actively maintained, was not added to new modules
(such as res_pjsip), and there exist better alternatives to acquire the
same information, such as the ARI.
Change-Id: I4b2185a83aeb74798b4ad43ff8f89f971096aa83