Commit Graph

6503 Commits

Author SHA1 Message Date
George Joseph 9688381f05 Merge "http: Add ability to disable /httpstatus URI" 2020-01-23 09:34:48 -06:00
George Joseph 6818c3d1d2 cdr.c: Set event time on party b when leaving a parking bridge
When Alice calls Bob and Bob does a blind transfer to Charlie,
Bob's bridge leave event generates a finalize on both the party_a
and party_b CDRs but while the party_a CDR has the correct end time
set from the event time, party_b's leg did not. This caused that
CDR's end time to be equal to the answered time and resulted in a
billsec of 0.

* We now pass the bridge leave message event time to
cdr_object_party_b_left_bridge_cb() and set it on that CDR before
calling cdr_object_finalize() on it.

NOTE:  This issue affected transfers using chan_sip most of the
time but also occasionally affected chan_pjsip probably due to
message timing.

ASTERISK-28677
Reported by: Maciej Michno

Change-Id: I790720f1e7326f9b8ce8293028743b0ef0fb2cca
2020-01-22 13:13:57 -06:00
Sean Bright 0dce6f746b http: Add ability to disable /httpstatus URI
Add a new configuration option 'enable_status' which allows the
/httpstatus URI handler to be administratively disabled.

We also no longer unconditionally register the /static and /httpstatus
URI handlers, but instead do it based upon configuration.

Behavior change: If enable_static was turned off, the URI handler was
still installed but returned a 403 when it was accessed. Because we
now register/unregister the URI handlers as appropriate, if the
/static URI is disabled we will return a 404 instead.

Additionally:

* Change 'enablestatic' to 'enable_static' but keep the former for
  backwards compatibility.
* Improve some internal variable names

ASTERISK-28710 #close

Change-Id: I647510f796473793b1d3ce1beb32659813be69e1
2020-01-22 10:10:14 -06:00
Sean Bright dfad69ce7c translate.c: Fix silk 24kHz truncation in 'core show translation'
SILK @ 24kHz is not shown in the 'core show translation' output because of an
off-by-one-error. Discovered while looking into ASTERISK~19871.

ASTERISK-28706
Reported by: Sean Bright

Change-Id: Ie1a551a8a484e07b45c8699cc0c90f1061029510
2020-01-20 15:58:24 -06:00
Joshua Colp 64debbd13f Merge "app_voicemail, say: Fix various leading whitespace problems" 2020-01-20 10:07:13 -06:00
Sean Bright 5cbf47714a app_voicemail, say: Fix various leading whitespace problems
In af90afd90c, Japanese language support
was added to app_voicemail and main/say.c, but the leading whitespace
is not consistent with Asterisk coding guidelines. This patch fixes
that.

Whitespace only, no functional change.

ASTERISK~23324
Reported by: Kevin McCoy

Change-Id: I72c725f5930084673749bd7c9cc426a987f08e87
2020-01-16 13:55:32 -06:00
Sean Bright 50d02d6194 pbx.c: Include filesystem cache in free memory calculation
ASTERISK-28695 #close
Reported by: Kevin Flyn

Change-Id: Ief098bb6eb77378daeace8f97ba30701c8de55b8
2020-01-16 12:38:09 -06:00
Joshua Colp a55d403429 Merge "res_pjsip_endpoint_identifier_ip.c: Add port matching support" 2020-01-09 15:08:04 -06:00
Joshua Colp bf0247ae7c Merge "stasis.c: Use correct topic name in stasis_topic_pool_delete_topic" 2020-01-08 09:41:18 -06:00
Sean Bright 312abaa1fe res_pjsip_endpoint_identifier_ip.c: Add port matching support
Adds source port matching support when IP matching is used:

  [example]
  type = identify
  match = 1.2.3.4:5060/32, 1.2.3.4:6000/32, asterisk.org:4444

If the IP matches but the source port does not, we reject and search for
alternatives. SRV lookups are still performed if enabled (srv_lookups = yes),
unless the configured FQDN includes a port number in which case just a host
lookup is performed.

ASTERISK-28639 #close
Reported by: Mitch Claborn

Change-Id: I256d5bd5d478b95f526e2f80ace31b690eebba92
2020-01-08 08:37:53 -06:00
George Joseph ab5b97c0d3 Merge "features.c: Make Bridge application tolerate unspecified channel." 2020-01-07 13:03:50 -06:00
George Joseph 1c9ddad4db stasis.c: Use correct topic name in stasis_topic_pool_delete_topic
When a topic is created for an object, its name is only
<object>:<uniqueid>
For example:
bridge:cb68b3a8-fce7-4738-8a17-d7847562f020

When a topic is added to a pool, its name has the pool's topic
name prepended.  For example:
bridge:all/bridge:cb68b3a8-fce7-4738-8a17-d7847562f020

The topic_pool_entry's name however, is only what was passed
in to stasis_topic_pool_get_topic which is
bridge:cb68b3a8-fce7-4738-8a17-d7847562f020
That's actually correct because the entry is qualified by the
pool that's in.

When you're ready to delete the entry from the pool, you retrieve
the tropic name from the object but since it now has the pool's
topic name prepended, it won't be found in the pool container.

Fix:

* Modified stasis_topic_pool_delete_topic() to skip past the
pool topic's name, if it was prepended to the topic name,
before searching the container for a pool entry.

ASTERISK-28633
Reported by: Joeran Vinzens

Change-Id: I4396aa69dd83e4ab84c5b91b39293cfdbcf483e6
2020-01-06 09:51:42 -06:00
Richard Mudgett 0376f2bba9 features.c: Make Bridge application tolerate unspecified channel.
The Bridge application was inconsistent if the channel to bridge with is
not specified.  If no parameters are given then a warning is issued and
the current channel is hung up.  If options are given but no channel is
specified then a warning is issued and the current channel is not hung up.

* Made the Bridge application give a verbose message instead of a warning
if the channel to bridge with is not specified and made not hang up the
current channel.  As a result dialplan no longer needs to check if a
channel name is passed before calling Bridge and simply needs to check the
BRIDGERESULT channel variable instead.  This is something you likely want
your dialplan to do anyway.

* Fixed up L() option warning message.  It is up to the caller to
determine if the channel is hung up because of the warning.  Dial() hangs
up the current channel while Bridge() does not.

Change-Id: I44349a8dc3912397f28852777de04f19e7bb9c73
2020-01-05 21:18:08 -06:00
Sean Bright 87110c1bdf websocket: Consider pending SSL data when waiting for socket input
When TLS is in use, checking the readiness of the underlying FD is insufficient
for determining if there is data available to be read. So before polling the
FD, check if there is any buffered data in the TLS layer and use that first.

ASTERISK-28562 #close
Reported by: Robert Sutton

Change-Id: I95fcb3e2004700d5cf8e5ee04943f0115b15e10d
2020-01-02 15:51:37 -06:00
Sean Bright fc99ac8c9a db: Initialize condition primitive before use
The db_init() function ultimately calls db_sync() which signals the
condition before it is initialized.

Change-Id: Id4a4e025b637bc4ac7d90557fcb71d56598892ab
2019-12-27 17:32:22 -06:00
George Joseph 7c4fc2e39a Merge "config.c: Skip UTF-8 BOMs if present when reading config files" 2019-12-27 13:12:03 -06:00
Joshua C. Colp dd823e50e4 Merge "main/file.c: Limit media cache usage to remote files." 2019-12-19 18:41:11 -06:00
Sean Bright 40b5cf8f52 config.c: Skip UTF-8 BOMs if present when reading config files
ASTERISK-28667 #close

Change-Id: I4767ed365c98f3e1587b7653321048a31d8a53b2
2019-12-19 04:48:58 -06:00
Kevin Reeves c626ccec12 main/file.c: Limit media cache usage to remote files.
When testing for the existance of a file, the media cache is searched even if
the file has no chance of being in it.  This can cause performance issues
as the media cache size increases.

As a result, calls to applications like Read and Playback using local files
must scan through the media cache before playing.  Under load and with a
large cache, this can delay the playback of those files.

This patch updates the function that checks for the existance of a file to
only consult the media cache database if the requested file is a remote path.
It introduces a new is_remote_path() function in main/file.c.

ASTERISK-28625  #close
Reported-by: kevin@phoneburner.com

Change-Id: If91137493732d9034dafa381c081c69274a7dcc9
2019-12-18 18:45:24 -06:00
Joshua C. Colp 89b7144fbd confbridge: Add support for specifying maximum sample rate.
ConfBridge has the ability to move between different sample
rates for mixing the conference bridge. Up until now there has
only been the ability to set the conference bridge to mix at
a specific sample rate, or to let it move between sample rates
as necessary. This change adds the ability to configure a
conference bridge with a maximum sample rate so it can move
between sample rates but only up to the configured maximum.

ASTERISK-28658

Change-Id: Idff80896ccfb8a58a816e4ce9ac4ebde785963ee
2019-12-16 09:54:21 -06:00
Jaco Kroon 32160cb456 ACL: ast_apply_acl_nolog - identical to ast_apply_acl but without logging.
Due to use in res_rtp_asterisk there is a need to be able to apply an
ACL without logging any invalid/denies.  It's probably sensible to at
least validate the ACL once directly after load and report invalid ACLs.

Change-Id: I256169229d945ca7c1bbf228fc492d91df345843
Signed-off-by: Jaco Kroon <jaco@uls.co.za>
2019-12-12 02:14:55 -06:00
Friendly Automation fd00a2bd10 Merge "channel.c: Resolve issue with receiving SIP INFO packets for DTMF" 2019-12-06 08:46:26 -06:00
George Joseph c1ad1ea391 Merge "media_cache.c: Various CLI improvements" 2019-12-02 16:01:57 -06:00
George Joseph fd823225a6 channel.c: Resolve issue with receiving SIP INFO packets for DTMF
The problem is essentially the same as in ASTERISK~28245. Besides
the direct media scenario we have an additional scenario where a
special client is involved. This device mutes audio by default in
transmit direction (no rtp frames) and activates audio only by a
foot switch. In this situation dtmf input (pin for conferences,
transfer features codes , etc) using SIP INFO mode is not
understood properly especially when SIP INFO messages are sent
quickly.

This patch ensures that SIP INFO frames are properly queued and
processed in the above scenario. The patch also corrects situations
where successive dtmf events are received quicker than the
signalled event duration (plus minimum gap/pause) allows, i.e. DTMF
events have to be buffered in the ast channel read queue and
emulation has to be processed asynchronously at slower speed.

Reported by: Thomas Arimont
patches:
  trigger_dtmf_emulation.patch submitted by Thomas Arimont (license 5525)

Change-Id: I309bf61dd065c9978c8e48f5b9a936ab47de64c2
2019-12-02 08:39:57 -06:00
Joshua Colp cd3a2a478f Merge "core: Improve MALLOC_DEBUG for frames." 2019-12-02 06:45:24 -06:00
Sean Bright 91c3b5b09d media_cache.c: Various CLI improvements
* Use ast_cli_completion_add() to improve performance when large number of
  cached items are present.

* Only complete one URI for commands that only accept a single URI.

* Change command documentation to wrap at 80 characters to improve
  readability.

Change-Id: Iedb0a2c3541e49561bc231dca2dcc0ebd8612902
2019-11-22 16:38:23 -05:00
George Joseph 7e3a6e158f manager.c: Prevent the Originate action from running the Originate app
If an AMI user without the "system" authorization calls the
Originate AMI command with the Originate application,
the second Originate could run the "System" command.

Action: Originate
Channel: Local/1111
Application: Originate
Data: Local/2222,app,System,touch /tmp/owned

If the "system" authorization isn't set, we now block the
Originate app as well as the System, Exec, etc. apps.

ASTERISK-28580
Reported by: Eliel Sardañons

Change-Id: Ic4c9dedc34c426f03c8c14fce334a71386d8a5fa
2019-11-21 09:41:07 -06:00
Friendly Automation c93518497c Merge "serializer: set high/low alert levels on whole pool" 2019-11-19 10:18:32 -06:00
Alexei Gradinari f2d5ed54ea serializer: set high/low alert levels on whole pool
The current code sets alert levels starting from index 1.
Need to set on whole pool starting from index 0.

Change-Id: I5decbb43160954fb9a512f04302637fc666b6f5d
2019-11-18 11:05:24 -05:00
Kevin Harwell bdd785d31c various files - fix some alerts raised by lgtm code analysis
This patch fixes several issues reported by the lgtm code analysis tool:

https://lgtm.com/projects/g/asterisk/asterisk

Not all reported issues were addressed in this patch. This patch mostly fixes
confirmed reported errors, potential problematic code points, and a few other
"low hanging" warnings or recommendations found in core supported modules.
These include, but are not limited to the following:

* innapropriate stack allocation in loops
* buffer overflows
* variable declaration "hiding" another variable declaration
* comparisons results that are always the same
* ambiguously signed bit-field members
* missing header guards

Change-Id: Id4a881686605d26c94ab5409bc70fcc21efacc25
2019-11-18 08:30:45 -06:00
Corey Farrell 8a1f30af04
core: Improve MALLOC_DEBUG for frames.
* Pass caller information to frame allocation functions.
* Disable caching as it interfers with MALLOC_DEBUG reporting.
* Stop using ast_calloc_cache.

Change-Id: Id343cd80a3db941d2daefde2a060750fea8cd260
2019-11-08 10:20:13 -05:00
Friendly Automation 391aafb971 Merge "pbx: deadlock when outgoing dialed channel hangs up too quickly" 2019-10-14 07:16:25 -05:00
Kevin Harwell bf6f27388d pbx: deadlock when outgoing dialed channel hangs up too quickly
Here's the basic scenario that occurred when executing an AMI fast originate
while at the same time something else locks the channels container, and also
wants a lock on the dialed channel:

1. pbx_outgoing_attempt obtains a lock on a dialed channel
2. concurrently another thread obtains a lock on the channels container, and
   subsequently requests a lock on the dialed channel. It waits on #1. For
   instance, "core show channel <dialed channel"
3. the outgoing call does not fail, but ends before the pbx_outgoing_attempt
   function exits
4. pbx_outgoing_attempt function exits, the outgoing structure destructs, and
   attempts to hang up the dialed channel
5. hang up tries to obtain the channels container lock, but can't due to #2.
6. Asterisk is deadlocked.

The solution was to allow the pbx_outgoing_exec function to "steal" ownership
of the dialed channel, and handle hanging it up. The channel now is either hung
up prior to it being potentially locked by the initiating thread, or if locked
the hang up takes place in a different thread, thus alleviating the deadlock.

ASTERISK-28561
patches:
  iliketrains.diff submitted by Joshua Colp (license 5000)

Change-Id: I51b42b92dde8f2215b69bb509e28667ee3a3853a
2019-10-09 16:07:18 -05:00
Kevin Harwell c0efe19cec serializer: move/add asterisk serializer pool functionality
Serializer pools have previously existed in Asterisk. However, for the most
part the code has been duplicated across modules. This patch abstracts the
code into an 'ast_serializer_pool' object. As well the code is now centralized
in serializer.c/h.

In addition serializer pools can now optionally be monitored by a shutdown
group. This will prevent the pool from being destroyed until all serializers
have completed.

Change-Id: Ib1e906144b90ffd4d5ed9826f0b719ca9c6d2971
2019-10-07 16:54:16 -05:00
Friendly Automation d73482e6d1 Merge "stasis_state: Create internal stasis_state_proxy object." 2019-10-04 06:56:30 -05:00
Joshua Colp 729b286d59 stasis: Pass bumped topic_all reference to proxy_dtor.
This avoids use of the global variable and ensures topic_all remains
active until all topics are freed.

ASTERISK-28553
patches:
  ASTERISK-28553.patch by coreyfarrell (license 5909)

Change-Id: I9a8cd8977f3c3a6aa00783f8336d2cfb9c2820f1
2019-10-01 09:06:07 -05:00
George Joseph 57da20ddac Merge "taskprocessor.c: Added "like" support to 'core show taskprocessors'" 2019-09-27 08:56:51 -05:00
Sean Bright 702019fc80 pbx: Prevent Realtime switch crash on invalid priority
pbx_extension_helper takes two 'context' arguments. One (con) is a
pointer directly to a 'struct ast_context' and the other (context) is
the name of the context. In all cases, one of these arguments is NULL
and the other is non-NULL.

Functions that are ultimately called by pbx_extension_helper expect that
'context' will be non-NULL, so we set it unconditionally on entry into
this function.

ASTERISK-28534 #close

Change-Id: Ifbbc5e71440afd80efd441f7a9d72e8b10b6f47d
2019-09-26 04:48:25 -05:00
Ben Ford 4c3655ecfd taskprocessor.c: Added "like" support to 'core show taskprocessors'
Added "like" support for 'core show taskprocessors'. Now you
can specify a specific set of taskprocessors (or just one) by
adding the keyword "like" to the above command, followed by
your search criteria.

Change-Id: I021e740201e9ba487204b5451e46feb0e3222464
2019-09-25 14:01:49 -05:00
George Joseph f156391176 Merge "core: Fix ABI mismatch of ao2_global_obj." 2019-09-25 08:16:39 -05:00
George Joseph 2d4abb9906 Merge "taskprocessor.c: Add CLI commands to reset taskprocessor stats." 2019-09-25 07:04:47 -05:00
George Joseph f2367e56c0 Merge "core: Add AO2_ALLOC_OPT_NO_REF_DEBUG option." 2019-09-25 06:04:18 -05:00
Corey Farrell f7045cefd9 stasis_state: Create internal stasis_state_proxy object.
This improves the way which stasis_state reference counting works.
Since manager->states holds onto the proxy object instead of the real
object this allows stasis_state objects to be freed when appropriate
without use of a special state_remove function.  Additionally each
distinct eid associated with the state holds a reference to the state to
prevent early release and potentially allow easier debug of leaks.

Change-Id: I400e0db4b9afa3d5cb4ac7dad60907897e73f9a9
2019-09-24 14:33:33 -05:00
Ben Ford 4de1e6d0e6 taskprocessor.c: Add CLI commands to reset taskprocessor stats.
Added two new CLI commands to reset stats for taskprocessors. You can
reset stats for a single, specific taskprocessor ('core reset
taskprocessor <taskprocessor>'), or you can reset all taskprocessors
('core reset taskprocessors'). These commands will reset the counter for
the number of tasks processed as well as the max queue size.

Change-Id: Iaf17fc4ae29396ab0c6ac92408fc7bdc2f12362d
2019-09-24 10:42:23 -05:00
George Joseph e034e7f51d Merge "astmm.c: Display backtrace with memory show allocations" 2019-09-24 08:27:26 -05:00
Friendly Automation ffbad8ed83 Merge "stasis: refcounter.py can incorrectly report skewed objects." 2019-09-23 14:07:27 -05:00
Corey Farrell 725e991faf
core: Add AO2_ALLOC_OPT_NO_REF_DEBUG option.
Previous to this patch passing a NULL tag to ao2_alloc or ao2_ref based
functions would result in the reference not being logged under
REF_DEBUG.  This could sometimes cause inaccurate logging if NULL was
accidentally passed to a reference action.  Now reference logging is
only disabled by option passed to the allocation method.

Change-Id: I3c17d867d901d53f9fcd512bef4d52e342637b54
2019-09-23 13:34:14 -04:00
George Joseph e82f2f6e82 astmm.c: Display backtrace with memory show allocations
You can currently capture backtraces of memory allocations but they
only get displayed when you stop asterisk and the atexit hooks
are enabled.  Now, if memory backtrace is on and you issue a
"memory show allocations" CLI command for a specific file, then
a backtrace will show for each allocation that occurred after
you turned "memory backtrace on".  The backtrace display is shown
only when a specific file's allocations are displayed to prevent
a massive CLI dump of every file's allocations.

Change-Id: Ic657afc1fc6ec7205e16eb36a97a611d235a2b4f
2019-09-23 07:25:33 -05:00
Corey Farrell a4142c8437
core: Fix ABI mismatch of ao2_global_obj.
astobj2.c declares DEBUG_THREADS_LOOSE_ABI to avoid overhead of debug
threads tracking information in the internal structures of astobj2.
Unfortunately this means that ao2_global_obj contains the statically
allocated debug threads tracking fields which are used by initialization
and cleanup but main/astobj2.c believed those fields and associated
space did not exist.

Change-Id: Icef41ad97d88a8c1d1515e034ec8133cab3b1527
2019-09-23 07:35:48 -04:00
Corey Farrell ca608d2575 stasis: refcounter.py can incorrectly report skewed objects.
It is possible for topic->name to be NULL, this causes the allocation
reference to not be logged.  Use the name variable instead which has
been verified to be a non-empty.

Change-Id: I3d0031d03c8356e4808f00cdf2d5428712575883
2019-09-20 08:31:38 -05:00