Commit Graph

866 Commits

Author SHA1 Message Date
Sean Bright 1920639eab pbx_config.c: Don't crash when unloading module.
`pbx_config` subscribes to manager events to capture the `FullyBooted`
event but fails to unsubscribe if the module is loaded after that
event fires. If the module is unloaded, a crash occurs the next time a
manager event is raised.

We now unsubscribe when the module is unloaded if we haven't already
unsubscribed.

Fixes #470
2023-12-06 21:24:50 +00:00
Naveen Albert dd171a44b7 users.conf: Deprecate users.conf configuration.
This deprecates the users.conf config file, which
is no longer as widely supported but still integrated
with a number of different modules.

Because there is no real mechanism for marking a
configuration file as "deprecated", and users.conf
is not just used in a single place, this now emits
a warning to the user when the PBX loads to notify
about the deprecation.

This configuration mechanism has been widely criticized
and discouraged since its inception, and is no longer
relevant to the configuration that most users are doing
today. Removing it will allow for some simplification
and cleanup in the codebase.

Resolves: #183

UpgradeNote: The users.conf config is now deprecated
and will be removed in a future version of Asterisk.
2023-07-12 14:09:28 +00:00
Joshua C. Colp 21c07cf6e1 pbx_dundi: Fix PJSIP endpoint configuration check.
ASTERISK-28233

Change-Id: I0f11c096b307a6178e22ca49d9c756343f0e1fdc
2023-04-13 03:36:57 -06:00
Naveen Albert ecf49ff746 pbx_dundi: Add PJSIP support.
Adds PJSIP as a supported technology to DUNDi.

To facilitate this, we now allow an endpoint to be specified
for outgoing PJSIP calls. We also allow users to force a specific
channel technology for outgoing SIP-protocol calls.

ASTERISK-28109 #close
ASTERISK-28233 #close

Change-Id: I2e28e5a5d007bd49e3df113ad567b011103899bf
2023-04-10 14:38:51 -05:00
Mike Bradeen 6b03d60c7d res_monitor: Remove deprecated module.
ASTERISK-30303

Change-Id: I0462caefb4f9544e2e2baa23c498858310b52d50
2023-01-13 08:32:33 -06:00
Mike Bradeen e8f548c155 app_macro: Remove deprecated module.
For most modules that interacted with app_macro, this change is limited
to no longer looking for the current context from the macrocontext when
set.  Additionally, the following modules are impacted:

app_dial - no longer supports M^ connected/redirecting macro
app_minivm - samples written using macro will no longer work.
The sample needs a re-write

app_queue - can no longer a macro on the called party's channel.
Use gosub which is currently supported

ccss - no callback macro, gosub only

app_voicemail - no macro support

channel  - remove macrocontext and priority, no connected line or
redirection macro options
options - stdexten is deprecated to gosub as the default and only
pbx - removed macrolock
pbx_dundi - no longer look for macro

snmp - removed macro context, exten, and priority

ASTERISK-30304

Change-Id: I830daab293117179b8d61bd4df0d971a1b3d07f6
2023-01-10 14:07:44 -06:00
Mike Bradeen 4095a382da chan_sip: Remove deprecated module.
ASTERISK-30297

Change-Id: Ic700168c80b68879d9cee8bb07afe2712fb17996
2023-01-03 09:00:42 -06:00
Boris P. Korzun 740c773781 pbx_lua: Remove compiler warnings
Improved variable definitions (specified correct type) for avoiding
compiler warnings.

ASTERISK-30117 #close

Change-Id: I3b00c1befb658ee9379ddabd9a9132765ca9201a
2022-07-06 16:04:14 -05:00
Alexander Traud cc025026b7 progdocs: Fix for Doxygen, the hidden parts.
ASTERISK-29779

Change-Id: If338163488498f65fa7248b60e80299c0a928e4b
2021-12-02 10:37:38 -06:00
Josh Soref ccb8b8ffbf pbx: Spelling fixes
Correct typos of the following word families:

process
populate
with
africa
accessing
contexts
exercise
university
organizations
withhold
maintaining
independent
rotation
ignore
eventname

ASTERISK-29714

Change-Id: I90eacc5bc3dcf75a9c898cfb85164f37dec08345
2021-11-15 18:30:07 -06:00
Mark Murawski 7fc26e8617 pbx_ael: Fix crash and lockup issue regarding 'ael reload'
Avoid infinite recursion and crash

Change-Id: I8ed05ec3aa2806c50c77edc5dd0cd4e4fa08b3f4
2021-10-08 09:41:13 -05:00
Mark Murawski bbf4f30059 pbx_ael: Fix crash and lockup issue regarding 'ael reload'
Currently pbx_ael does not check if a reload is currently pending
before proceeding with a reload. This can cause multiple threads to
operate at the same time on what should be mutex protected data. This
change adds protection to reloading to ensure only one ael reload is
executing at a time.

ASTERISK-29609 #close

Change-Id: I5ed392ad226f6e4e7696ad742076d3e45c57af35
2021-09-02 14:16:27 -05:00
Kevin Harwell 4274a4a7dd pbx_realtime: wrong type stored on publish of ast_channel_snapshot_type
A prior patch segmented channel snapshots, and changed the underlying
data object type associated with ast_channel_snapshot_type stasis
messages. Prior to Asterisk 18 it was a type ast_channel_snapshot, but
now it type ast_channel_snapshot_update.

When publishing ast_channel_snapshot_type in pbx_realtime the
ast_channel_snapshot was being passed in as the message data
object. When a handler, expecting a data object type of
ast_channel_snapshot_update, dereferenced this value a crash
would occur.

This patch makes it so pbx_realtime now uses the expected type, and
channel snapshot publish method when publishing.

ASTERISK-29168 #close

Change-Id: I9a2cfa0ec285169317f4b9146e4027da8a4fe896
2021-01-06 09:13:13 -06:00
Kevin Harwell 3d1bf3c537 Compiler fixes for gcc 10
This patch fixes a few compile warnings/errors that now occur when using gcc
10+.

Also, the Makefile.rules check to turn off partial inlining in gcc versions
greater or equal to 8.2.1 had a bug where it only it only checked against
versions with at least 3 numbers (ex: 8.2.1 vs 10). This patch now ensures
any version above the specified version is correctly compared.

Change-Id: I54718496eb0c3ce5bd6d427cd279a29e8d2825f9
2020-06-10 09:33:28 -05:00
Jaco Kroon 40e93b0240 dundi: fix NULL dereference.
If a negative (error) return is received from dundi_lookup_internal,
this is not handled correctly when assigning the result to the buffer.
As such, use a signed integer in the assignment and do a proper
comparison.

ASTERISK-21205

Change-Id: I5214ebb6491e2bd14f90c7d3ce229da86888f739
2020-03-25 17:22:20 -05:00
Kirsty Tyerman bcaa01b024 pbx_dundi: added IPv4/IPv6 dual bind support to DUNDi
ASTERISK-28234
Reported-by: Kirsty Tyerman

Change-Id: I5d6e6b52dbe51415046bb3953fd16f5b421bc2e1
2019-06-05 11:56:36 -06:00
George Joseph c5c953c1f1 Fixes for GCC 9
Various fixes for issues caught by gcc 9.  Mostly snprintf
trying to copy to a buffer potentially too small.

ASTERISK-28412

Change-Id: I9e85a60f3c81d46df16cfdd1c329ce63432cf32e
2019-05-10 10:22:55 -06:00
Ben Ford dd1cc7791c build: Fix compiler warnings/errors.
The compiler complained about a couple of variables that weren't
initialized but were being used. Initializing them to NULL resolves the
warnings/errors.

ASTERISK-28362 #close

Change-Id: I6243afc5459b416edff6bbf571b0489f6b852e4b
2019-04-03 09:36:51 -06:00
Sean Bright 2473b791b9 Replace calls to strtok() with strtok_r()
strtok() uses a static buffer, making it not thread safe.

Also add a #define to cause a compile failure if strtok is used.

Change-Id: Icce265153e1e65adafa8849334438ab6d190e541
2019-03-07 16:44:50 -06:00
Joshua Colp 50ac85cb40 stasis: Segment channel snapshot to reduce creation cost.
When a channel snapshot was created it used to be done
from scratch, copying all data (many strings). This incurs
a cost when doing so.

This change segments the channel snapshot into different
components which can be reused if unchanged from the
previous snapshot creation, reducing the cost. In normal
cases this results in some pointers being copied with
reference count being bumped, some integers being set,
and a string or two copied. The other benefit is that it
is now possible to determine if a channel snapshot update
is redundant and thus stop it before a message is published
to stasis.

The specific segments in the channel snapshot were split up
based on whether they are changed together, how often they
are changed, and their general grouping. In practice only
1 (or 0) of the segments actually get changed in normal
operation.

Invalidation is done by setting a flag on the channel when
the segment source is changed, forcing creation of a new
segment when the channel snapshot is created.

ASTERISK-28119

Change-Id: I5d7ef3df963a88ac47bc187d73c5225c315f8423
2018-11-26 12:56:24 -06:00
Corey Farrell 021ce938ca
astobj2: Remove legacy ao2_container_alloc routine.
Replace usage of ao2_container_alloc with ao2_container_alloc_hash or
ao2_container_alloc_list.  Remove ao2_container_alloc macro.

Change-Id: I0907d78bc66efc775672df37c8faad00f2f6c088
2018-11-21 09:56:16 -05:00
Corey Farrell 8e34cb302e
pbx_config: Only the first [globals] section is seen.
If multiple [globals] sections are used (for example via separate
included files), only the first one is processed.  This can result in
lost global variables when using a modular extensions.conf.

ASTERISK-28146 #close

Change-Id: Iaac810c0a7c4d9b1bf8989fcc041cdb910ef08a0
2018-11-08 06:43:10 -05:00
Corey Farrell 639718211a
Resolve warning about duplicate 'dialplan' CLI.
Change-Id: I029db1b4a32ccfb38374d6fe944dc430866f4b30
2018-10-02 14:27:52 -04:00
Chris-Savinovich b779a93d8d pbx_config.c: Fix reloading module if initially declined to load
Added decline if extensions.conf file not available
when loading pbx_config, and also made sure everything
gets properly unregistered and/or destroyed on unload.

Change-Id: Ib00665106043b1be5148ffa7a477396038915854
2018-08-31 17:03:55 -05:00
Jenkins2 9189c266f1 Merge "pbx_dundi: Added IPv6 support for dundi" 2018-08-27 09:38:15 -05:00
Joshua Colp 2dce2c9796 Merge "pbx_dundi: Fix debug frame decode string." 2018-08-21 18:52:46 -05:00
George Joseph 55f72f21b3 Merge "pbx_dundi.c: Handle thread shutdown better." 2018-08-21 07:26:01 -05:00
Kirsty Tyerman 328f772d3b pbx_dundi: Added IPv6 support for dundi
Change includes move to netsock2 library.

ASTERISK-27164
Reported-by: Adam Secombe

Change-Id: Ia9e8dc3d153de7a291dbda4bd87fc827dd2bb846
2018-08-17 16:03:14 -05:00
Richard Mudgett 273e2802aa pbx_dundi.c: Misc memory management fixes when destroying peers
* In destroy_peer(), fixed memory leaks of lookup history strings and
qualify transactions when destroying peers.

* In destroy_peer(), fixed leaving the registerexpire scheduled callback
active when a peer is destroyed on a reload.  The reload marks and sweeps
peers so any peers not explicitly configured get destroyed.  Peers created
dynamically from the '*' peer will not exist until they re-register after
the reload.  These destroyed peers caused memory corruption when the
registerexpire timer expired.

* Made build_peer() not schedule any callbacks on the '*' peer
(empty_eid).  It is a special peer that is cloned to dynamically created
peers so it doesn't actually get involved in any message transactions.

* Made do_register_expire() remove the dundi/dpeers AstDB entry when a
peer registration expires.

* Fix deep_copy_peer() to not copy some things that cannot be copied to
the cloned peer structure.  Timers, message transactions, and lookup
history are specific to a peer instance.

* Made set_config() lock around processing the mappings configuration.

* Reordered unload_module() to handle load_module() declining the load due
to error.

Change-Id: Ib846b2b60d027f3a2c2b3b563d9a83a357dce1d6
2018-08-17 14:25:27 -05:00
Richard Mudgett d4e72ee296 pbx_dundi.c: Handle thread shutdown better.
Change-Id: Id52f99bd6a948fe6dd82acc0a28b2447a224fe87
2018-08-17 14:24:28 -05:00
Richard Mudgett 916abe7cdc pbx_dundi: Fix debug frame decode string.
* Fixed a typo in the name of the REGREQ frame decode string array.
* Fixed off by one range check indexing into the frame decode string
array.
* Removed some unneeded casts associated with the decode string array.

Change-Id: I77435e81cd284bab6209d545919bf236ad7933c2
2018-08-17 14:23:31 -05:00
Kirsty Tyerman 4b9bf4f5e0 pbx_dundi: reordered unloading of module pbx_dundi
Destroy scheduler after peers are pruned to stop dundi crashing when
unloading module.

ASTERISK-26987
Reported-by: Kirsty Tyerman

Change-Id: Ic12e562cd90d8d813a9e97f302045091f59e3c05
2018-06-28 21:59:56 -06:00
Alexander Traud 99aed78078 crypto.h: Repair ./configure --with-ssl=PATH.
ASTERISK-27908

Change-Id: Iac49d9f82faeb8a4611c6805906bd6d650b1b1d8
2018-06-08 13:01:53 +02:00
Corey Farrell b5914d90ac Fix GCC 8 build issues.
This fixes build warnings found by GCC 8.  In some cases format
truncation is intentional so the warning is just suppressed.

ASTERISK-27824 #close

Change-Id: I724f146cbddba8b86619d4c4a9931ee877995c84
2018-05-11 09:48:58 -04:00
Christof Lauber 9c9f314f64 pbx_lua: Support displaying lua error message if no debug table exists
The lua_error_function assumed that lua's debug table and traceback function
are always accessible, which is not the case. This fixes the error message
'Error in the lua error handler' triggred by switch exec() function.
If this happens lua's error message is shown without traceback.

Change-Id: I34ba0a098f1ae06a3af7b4d1b098bd43f42f96c8
2018-04-30 10:31:34 +02:00
Corey Farrell 9cfdb81e91 loader: Add dependency fields to module structures.
* Declare 'requires' and 'enhances' text fields on module info structure.
* Rename 'nonoptreq' to 'optional_modules'.
* Update doxygen comments.

Still need to investigate dependencies among modules I cannot compile.

Change-Id: I3ad9547a0a6442409ff4e352a6d897bef2cc04bf
2018-01-15 13:25:51 -05:00
Alexander Traud 7e9781c25e General: Silence modules on (un)load.
Some (normally optional) modules created notices, warnings, and even errors
in normal situations like (un)load. This cluttered the command-line interface
(CLI) on start and while stopping gracefully. However, when an user went for
the script './contrib/scripts/install_prereq', those modules get compiled-in
because their prerequisites were met at compile time. Furthermore, because of
ASTERISK_27475, the former talkative module 'res_curl' is built as side-effect.

ASTERISK-27553

Change-Id: I9f105f46d72553994e820679bfde3478a551b281
2018-01-06 20:13:07 -06:00
Sean Bright fd0ca1c3f9 Remove as much trailing whitespace as possible.
Change-Id: I873c1c6d00f447269bd841494459efccdd2c19c0
2017-12-22 09:23:22 -05:00
Corey Farrell d51837a1b9 CLI: Address multiple issues.
* 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
2017-12-19 16:43:49 -05:00
Corey Farrell 606ae3484a Add missing menuselect dependencies.
This adds menuselect dependencies for modules that use symbols of other
modules.

ASTERISK-27390

Change-Id: Ia2d2849f5b87a72af7324a82edc3f283eafb5385
2017-11-02 02:57:52 -04:00
Sean Bright bc2c66b594 pbx_spool: Set AST_OUTGOING_ATTEMPT variable on channel
Set a variable on the channel that indicates which attempt number we
are currently performing to allow for attempt-specific behavior.

ASTERISK-26568 #close
Reported by: Roman Shubovich

Change-Id: Iacd7e8d43b0ed5b6cb021c62f41f1a1f5733dd89
2017-03-08 17:31:49 -05:00
Sean Bright 5a74abc53b pbx_spool: Gracefully handle long lines in call files
Per the linked issue, we aren't checking the buffer filled by fgets()
to determine if it contains a newline, so we will fail to correctly
parse the trailing portion of a long line.

This patch increases the buffer size from 256 to 1024, and skips any
line that exceeds that length, logging a warning in the process.

ASTERISK-17067 #close
Reported by: Dave Olszewski

Change-Id: I51bcf270c1b4347ba05b43f18dc2094c76f5d7b0
2017-03-06 15:29:52 -06:00
Sean Bright 15ed7af027 pbx_realtime: Prevent premature extension matching
The patterns provided by pbx_realtime were checked in the order in
which they were returned from the realtime backend. If there was
overlap between multiple patterns, the first one to correctly match was
chosen even though it may not have been the best match.

We now sort the patterns descending by their length and compare in that
order. There may be cases where this still results in a sub-optimal
match, but this patch should improve the overall behavior.

ASTERISK-18271 #close
Reported by: Charlie Smurthwaite

Change-Id: I56d9ac15810eb1775966b669c3028e32cc7bd809
2017-02-22 10:22:54 -06:00
zuul afcdadcd19 Merge "pbx_dundi: DUNDi weight parameter not processed correctly" 2017-02-22 10:19:45 -06:00
Sean Bright fc70ca9499 pbx_dundi: DUNDi weight parameter not processed correctly
The DUNDi weight field is not always converted from network byte order
to host byte order. This can result in incorrect weight values and
incorrect selection of DUNDi destinations.

ASTERISK-18731 #close
Reported by: Peter Racz
Patches:
	dundi_weight.patch (license #6290) patch uploaded by Peter Racz

Change-Id: Iba3e1a700ff539db57211a7bbc26f7b22ea9a1be
2017-02-21 17:10:34 -06:00
Sean Bright ab04a018e4 realtime: Fix ast_load_realtime_multientry handling
ast_load_realtime_multientry() returns an ast_config structure whose
ast_categorys are keyed with the empty strings. Several modules were
giving semantic meaning to the category names causing problems at
runtime.

* app_directory: Treated the category name as the mailbox name, and
  would fail to direct calls to the appropriate extension after an
  entry was chosen.

* app_queue: Queues, queue members, and queue rules were all affected
  and needed to be updated.

* pbx_realtime: Pattern matching would never succeed because the
  extension entered by the user was always compared to the empty
  string.

Change-Id: Ie7e44986344b0b76ea8f6ddb5879f5040c6ca8a7
2017-02-21 13:06:29 -06:00
Sean Bright 0910773077 manager: Restore Originate failure behavior from Asterisk 11
In Asterisk 11, if the 'Originate' AMI command failed to connect the provided
Channel while in extension mode, a 'failed' extension would be looked up and
run. This was, I believe, unintentionally removed in 51b6c49. This patch
restores that behavior.

This also adds an enum for the various 'synchronous' modes in an attempt to
make them meaningful.

ASTERISK-26115 #close
Reported by: Nasir Iqbal

Change-Id: I8afbd06725e99610e02adb529137d4800c05345d
2017-02-10 18:04:41 -05:00
Jonathan R. Rose d96e350256 core/pbx: dialplan show - display filename/line#
Adds the ability for extensions to be registered to include filename and
line number so that dialplan show output can show the filename and line
number of a config file responsible for generating a given extension.

This only affects config modules that are written to use the new extension
registering functions. In this patch, that only includes pbx_config, so
extensions registered in extensions.conf and any included extension will
be shown in this manner. Extensions registered in this manner will show
the filename and line number *instead* of the registrar.

ASTERISK-26658 #close
Reported by: Jonathan R. Rose

Change-Id: Ieccc6abccdff34ed5c7da3511fd24972b8f2dd30
2017-01-04 14:06:20 -06:00
Dennis Guse ead773f801 pbx_lua: On configuration errors report module load failure instead of decline.
Switched from AST_MODULE_LOAD_DECLINE to AST_MODULE_LOAD_FAILURE.
Therefore, if pbx_lua fails to load and pbx_lua is marked as required,
Asterisk exits as expected.
If extensions.lua cannot be opened, AST_MODULE_LOAD_DECLINE is reported.

Change-Id: I8e5a0037e69b41743db60c568541ebb2f52a7a8f
2016-11-23 23:15:35 +01:00
Corey Farrell a6e5bae3ef Remove ASTERISK_REGISTER_FILE.
ASTERISK_REGISTER_FILE no longer has any purpose so this commit removes
all traces of it.

Previously exported symbols removed:
* __ast_register_file
* __ast_unregister_file
* ast_complete_source_filename

This also removes the mtx_prof static variable that was declared when
MTX_PROFILE was enabled.  This variable was only used in lock.c so it
is now initialized in that file only.

ASTERISK-26480 #close

Change-Id: I1074af07d71f9e159c48ef36631aa432c86f9966
2016-10-27 09:53:55 -04:00