]> git.ipfire.org Git - thirdparty/asterisk.git/log
thirdparty/asterisk.git
16 months agores_pjsip_session.c: Correctly format SDP connection addresses.
Sean Bright [Sat, 27 Jan 2024 14:46:27 +0000 (09:46 -0500)] 
res_pjsip_session.c: Correctly format SDP connection addresses.

Resolves a regression identified by @justinludwig involving the
rendering of IPv6 addresses in outgoing SDP.

Also updates `media_address` on PJSIP endpoints so that if we are able
to parse the configured value as an IP we store it in a format that we
can directly use later. Based on my reading of the code it appeared
that one could configure `media_address` as:

```
[foo]
type = endpoint
...
media_address = [2001:db8::]
```

And that value would be blindly copied into the outgoing SDP without
regard to its format.

Fixes #541

(cherry picked from commit 9f20b4659fc897b8495c7a4c51dfe4365ab937bd)

16 months agortp_engine.c: Correct sample rate typo for L16/44100.
Sean Bright [Sun, 28 Jan 2024 16:34:25 +0000 (11:34 -0500)] 
rtp_engine.c: Correct sample rate typo for L16/44100.

Fixes #555

(cherry picked from commit 671b47cfda18cf63e776c74fac2e02f00aec58fd)

16 months agomanager.c: Fix erroneous reloads in UpdateConfig.
Naveen Albert [Thu, 25 Jan 2024 17:44:29 +0000 (12:44 -0500)] 
manager.c: Fix erroneous reloads in UpdateConfig.

Currently, a reload will always occur if the
Reload header is provided for the UpdateConfig
action. However, we should not be doing a reload
if the header value has a falsy value, per the
documentation, so this makes the reload behavior
consistent with the existing documentation.

Resolves: #551
(cherry picked from commit 874ee6e9aaadc9a0b5a5915d952c9f61e0967dbf)

16 months agores_calendar_icalendar: Print iCalendar error on parsing failure.
Naveen Albert [Thu, 14 Dec 2023 14:43:14 +0000 (09:43 -0500)] 
res_calendar_icalendar: Print iCalendar error on parsing failure.

If libical fails to parse a calendar, print the error message it provdes.

Resolves: #492
(cherry picked from commit ef891529facf373db73ff9820210235eb29f9bb9)

16 months agoapp_confbridge: Don't emit warnings on valid configurations.
Sean Bright [Sun, 21 Jan 2024 16:40:19 +0000 (11:40 -0500)] 
app_confbridge: Don't emit warnings on valid configurations.

The numeric bridge profile options `internal_sample_rate` and
`maximum_sample_rate` are documented to accept the special values
`auto` and `none`, respectively. While these values currently work,
they also emit warnings when used which could be confusing for users.

In passing, also ensure that we only accept the documented range of
sample rate values between 8000 and 192000.

Fixes #546

(cherry picked from commit 03ad690276ece1fa45dfd4eb49a2546edb8e1e1d)

16 months agoapp_voicemail_odbc: remove macrocontext from voicemail_messages table
Mike Bradeen [Wed, 10 Jan 2024 16:47:24 +0000 (09:47 -0700)] 
app_voicemail_odbc: remove macrocontext from voicemail_messages table

When app_macro was deprecated, the macrocontext column was removed from
the INSERT statement but the binds were not renumbered. This broke the
insert.

This change removes the macrocontext column via alembic and re-numbers
the existing columns in the INSERT.

Fixes: #527
UserNote: The fix requires removing the macrocontext column from the
voicemail_messages table in the voicemail database via alembic upgrade.

UpgradeNote: The fix requires that the voicemail database be upgraded via
alembic. Upgrading to the latest voicemail database via alembic will
remove the macrocontext column from the voicemail_messages table.

(cherry picked from commit a22db8fd60c8b25e2c53279014f91dcd0e29567d)

16 months agochan_dahdi: Allow MWI to be manually toggled on channels.
Naveen Albert [Fri, 10 Nov 2023 14:44:25 +0000 (09:44 -0500)] 
chan_dahdi: Allow MWI to be manually toggled on channels.

This adds a CLI command to manually toggle the MWI status
of a channel, useful for troubleshooting or resetting
MWI devices, similar to the capabilities offered with
SIP messaging to manually control MWI status.

UserNote: The 'dahdi set mwi' now allows MWI on channels
to be manually toggled if needed for troubleshooting.

Resolves: #440
(cherry picked from commit 4b908f364d897b3fbdb52b84f84e06b9575b6e56)

16 months agochan_rtp.c: MulticastRTP missing refcount without codec option
PeterHolik [Mon, 15 Jan 2024 11:28:15 +0000 (12:28 +0100)] 
chan_rtp.c: MulticastRTP missing refcount without codec option

Fixes: #529
(cherry picked from commit 3b46872a8f689898afe3f143b9316a8992dbb16a)

16 months agochan_rtp.c: Change MulticastRTP nameing to avoid memory leak
PeterHolik [Tue, 16 Jan 2024 07:42:05 +0000 (08:42 +0100)] 
chan_rtp.c: Change MulticastRTP nameing to avoid memory leak

Fixes: asterisk#536
(cherry picked from commit 6fe045fd646cc2283b19114756fe31b545cdc0b6)

16 months agofunc_frame_trace: Add CLI command to dump frame queue.
Naveen Albert [Fri, 12 Jan 2024 16:33:00 +0000 (11:33 -0500)] 
func_frame_trace: Add CLI command to dump frame queue.

This adds a simple CLI command that can be used for
analyzing all frames currently queued to a channel.

A couple log messages are also adjusted to be more
useful in tracing bridging problems.

Resolves: #533
(cherry picked from commit 67088b256d9584d3c3ebe66686ac16a7a5aebcdc)

18 months agoUpdate for 21.1.0 21.1.0
Asterisk Development Team [Thu, 25 Jan 2024 16:23:00 +0000 (16:23 +0000)] 
Update for 21.1.0

18 months agoUpdate for 21.1.0-rc2 21.1.0-rc2
Asterisk Development Team [Thu, 18 Jan 2024 16:48:17 +0000 (16:48 +0000)] 
Update for 21.1.0-rc2

18 months agologger: Fix linking regression.
Naveen Albert [Tue, 16 Jan 2024 21:58:22 +0000 (16:58 -0500)] 
logger: Fix linking regression.

Commit 008731b0a4b96c4e6c340fff738cc12364985b64
caused a regression by resulting in logger.xml
being compiled and linked into the asterisk
binary in lieu of logger.c on certain platforms
if Asterisk was compiled in dev mode.

To fix this, we ensure the file has a unique
name without the extension. Most existing .xml
files have been named differently from any
.c files in the same directory or did not
pose this issue.

channels/pjsip/dialplan_functions.xml does not
pose this issue but is also being renamed
to adhere to this policy.

Resolves: #539

18 months agoUpdate for 21.1.0-rc1 21.1.0-rc1
Asterisk Development Team [Fri, 12 Jan 2024 18:32:27 +0000 (18:32 +0000)] 
Update for 21.1.0-rc1

18 months agoRevert "core & res_pjsip: Improve topology change handling."
George Joseph [Fri, 12 Jan 2024 12:47:58 +0000 (05:47 -0700)] 
Revert "core & res_pjsip: Improve topology change handling."

This reverts commit 315eb551dbd18ecd424a2f32179d4c1f6f6edd26.

Over the past year, we've had several reports of "topology storms"
occurring where 2 external facing channels connected by one or more
local channels and bridges will get themselves in a state where
they continually send each other topology change requests.  This
usually manifests itself in no-audio calls and a flood of
"Exceptionally long queue length" messages.  It appears that this
commit is the cause so we're reverting it for now until we can
determine a more appropriate solution.

Resolves: #530
(cherry picked from commit c31cd32b8296c675f66be7a4d39e89b45c3aec2c)

18 months agomenuselect: Use more specific error message.
Naveen Albert [Thu, 4 Jan 2024 18:05:32 +0000 (18:05 +0000)] 
menuselect: Use more specific error message.

Instead of using the same error message for
missing dependencies and conflicts, be specific
about what actually went wrong.

Resolves: #520
(cherry picked from commit 7683259f378a34f1b483f05537a5d093d98ca4d8)

18 months agores_pjsip_nat: Fix potential use of uninitialized transport details
Maximilian Fridrich [Mon, 8 Jan 2024 06:03:10 +0000 (07:03 +0100)] 
res_pjsip_nat: Fix potential use of uninitialized transport details

The ast_sip_request_transport_details must be zero initialized,
otherwise this could lead to a SEGV.

Resolves: #509
(cherry picked from commit 81188ada5fb3299dad3ea8107c31bcde3e39686a)

18 months agoapp_if: Fix faulty EndIf branching.
Naveen Albert [Sat, 23 Dec 2023 16:26:13 +0000 (16:26 +0000)] 
app_if: Fix faulty EndIf branching.

This fixes faulty branching logic for the
EndIf application. Instead of computing
the next priority, which should be done
for false conditionals or ExitIf, we should
simply advance to the next priority.

Resolves: #341
(cherry picked from commit 1bf4493371b8cf515e0094a6a7efe6003ff43dae)

18 months agomanager.c: Fix regression due to using wrong free function.
Naveen Albert [Tue, 26 Dec 2023 17:14:11 +0000 (17:14 +0000)] 
manager.c: Fix regression due to using wrong free function.

Commit 424be345639d75c6cb7d0bd2da5f0f407dbd0bd5 introduced
a regression by calling ast_free on memory allocated by
realpath. This causes Asterisk to abort when executing this
function. Since the memory is allocated by glibc, it should
be freed using ast_std_free.

Resolves: #513
(cherry picked from commit bb364fc61f563384645ff6b98779a7dc27032c31)

18 months agodoc: Remove obsolete CHANGES-staging and UPGRADE-staging directories
George Joseph [Fri, 15 Dec 2023 16:56:54 +0000 (09:56 -0700)] 
doc: Remove obsolete CHANGES-staging and UPGRADE-staging directories

These should have been deleted after the release of 21.0.0
but were missed.

(cherry picked from commit df958a7d631606b7301b72fe5d1a0b52b9fe3e9c)

18 months agoconfig_options.c: Fix truncation of option descriptions.
Naveen Albert [Thu, 9 Nov 2023 15:58:41 +0000 (10:58 -0500)] 
config_options.c: Fix truncation of option descriptions.

This increases the format width of option descriptions
to avoid needless truncation for longer descriptions.

Resolves: #428
(cherry picked from commit d20c3e2f6fbf391f4f769209c43e446ae9603fb4)

18 months agomanager.c: Improve clarity of "manager show connected".
Naveen Albert [Tue, 5 Dec 2023 16:36:47 +0000 (11:36 -0500)] 
manager.c: Improve clarity of "manager show connected".

Improve the "manager show connected" CLI command
to clarify that the last two columns are permissions
related, not counts, and use sufficient widths
to consistently display these values.

ASTERISK-30143 #close
Resolves: #482

(cherry picked from commit 09bd80c627cb636f80607c47f0b6a2bc627ad11c)

18 months agomake_xml_documentation: Really collect LOCAL_MOD_SUBDIRS documentation.
Sean Bright [Fri, 1 Dec 2023 20:30:17 +0000 (15:30 -0500)] 
make_xml_documentation: Really collect LOCAL_MOD_SUBDIRS documentation.

Although `make_xml_documentation`'s `print_dependencies` command was
corrected by the previous fix (#461) for #142, the `create_xml` was
not properly handling `LOCAL_MOD_SUBDIRS` XML documentation.

(cherry picked from commit e001a1b6d3e114d4b605e749dee867cdce6ff88b)

18 months agogeneral: Fix broken links.
Naveen Albert [Thu, 9 Nov 2023 21:26:46 +0000 (16:26 -0500)] 
general: Fix broken links.

This fixes a number of broken links throughout the
tree, mostly caused by wiki.asterisk.org being replaced
with docs.asterisk.org, which should eliminate the
need for sporadic fixes as in f28047db36a70e81fe373a3d19132c43adf3f74b.

Resolves: #430
(cherry picked from commit 3bb34477d4320aba312ab807d2c5efd294f1c417)

18 months agoMergeApproved.yml: Remove unneeded concurrency
George Joseph [Wed, 6 Dec 2023 21:27:01 +0000 (14:27 -0700)] 
MergeApproved.yml:  Remove unneeded concurrency

The concurrency parameter on the MergeAndCherryPick job has
been rmeoved.  It was a hold-over from earlier days.

(cherry picked from commit 751f8649fd3754174ca4a23f399489db811b366f)

18 months agoapp_dial: Add option "j" to preserve initial stream topology of caller
Maximilian Fridrich [Thu, 30 Nov 2023 08:57:56 +0000 (09:57 +0100)] 
app_dial: Add option "j" to preserve initial stream topology of caller

Resolves: #462

UserNote: The option "j" is now available for the Dial application which
uses the initial stream topology of the caller to create the outgoing
channels.

(cherry picked from commit 366dc1e99fe91068c6a9658b4bb8320e10de2878)

18 months agopbx_config.c: Don't crash when unloading module.
Sean Bright [Sat, 2 Dec 2023 16:13:31 +0000 (11:13 -0500)] 
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

(cherry picked from commit 16a42b2aec1327ca6295f6e516b478848d97373c)

18 months agoast_coredumper: Increase reliability
George Joseph [Sun, 12 Nov 2023 00:40:10 +0000 (17:40 -0700)] 
ast_coredumper: Increase reliability

Instead of searching for the asterisk binary and the modules in the
filesystem, we now get their locations, along with libdir, from
the coredump itself...

For the binary, we can use `gdb -c <coredump> ... "info proc exe"`.
gdb can print this even without having the executable and symbols.

Once we have the binary, we can get the location of the modules with
`gdb ... "print ast_config_AST_MODULE_DIR`

If there was no result then either it's not an asterisk coredump
or there were no symbols loaded.  Either way, it's not usable.

For libdir, we now run "strings" on the note0 section of the
coredump (which has the shared library -> memory address xref) and
search for "libasteriskssl|libasteriskpj", then take the dirname.

Since we're now getting everything from the coredump, it has to be
correct as long as we're not crossing namespace boundaries like
running asterisk in a docker container but trying to run
ast_coredumper from the host using a shared file system (which you
shouldn't be doing).

There is still a case for using --asterisk-bin and/or --libdir: If
you've updated asterisk since the coredump was taken, the binary,
libraries and modules won't match the coredump which will render it
useless.  If you can restore or rebuild the original files that
match the coredump and place them in a temporary directory, you can
use --asterisk-bin, --libdir, and a new --moddir option to point to
them and they'll be correctly captured in a tarball created
with --tarball-coredumps.  If you also use --tarball-config, you can
use a new --etcdir option to point to what normally would be the
/etc/asterisk directory.

Also addressed many "shellcheck" findings.

Resolves: #445
(cherry picked from commit aec24536889cefb64292a138a144b070ba083565)

18 months agologger.c: Move LOG_GROUP documentation to dedicated XML file.
Sean Bright [Fri, 1 Dec 2023 17:03:29 +0000 (12:03 -0500)] 
logger.c: Move LOG_GROUP documentation to dedicated XML file.

The `get_documentation` awk script will only extract the first
DOCUMENTATION block that it finds in a given file. This is by design
(9bc2127) to prevent AMI event documentation from being pulled in to
the core.xml documentation file.

Because of this, the `LOG_GROUP` documentation added in 89709e2 was
not being properly extracted and was missing fom the resulting XML
documentation file. This commit moves the `LOG_GROUP` documentation to
a separate `logger.xml` file.

(cherry picked from commit 1d05e34d98f3958aae64bd125ed1039f95f65125)

18 months agores_odbc.c: Allow concurrent access to request odbc connections
Matthew Fredrickson [Thu, 30 Nov 2023 17:57:53 +0000 (11:57 -0600)] 
res_odbc.c: Allow concurrent access to request odbc connections

There are valid scenarios where res_odbc's connection pool might have some dead
or stuck connections while others are healthy (imagine network
elements/firewalls/routers silently timing out connections to a single DB and a
single IP address, or a heterogeneous connection pool connected to potentially
multiple IPs/instances of a replicated DB using a DNS front end for load
balancing and one replica fails).

In order to time out those unhealthy connections without blocking access to
other parts of Asterisk that may attempt access to the connection pool, it would
be beneficial to not lock/block access around the entire pool in
_ast_odbc_request_obj2 while doing potentially blocking operations on connection
pool objects such as the connection_dead() test, odbc_obj_connect(), or by
dereferencing a struct odbc_obj for the last time and triggering a
odbc_obj_disconnect().

This would facilitate much quicker and concurrent timeout of dead connections
via the connection_dead() test, which could block potentially for a long period
of time depending on odbc.ini or other odbc connector specific timeout settings.

This also would make rapid failover (in the clustered DB scenario) much quicker.

This patch changes the locking in _ast_odbc_request_obj2() to not lock around
odbc_obj_connect(), _disconnect(), and connection_dead(), while continuing to
lock around truly shared, non-immutable state like the connection_cnt member and
the connections list on struct odbc_class.

Fixes: #465
(cherry picked from commit e0bf65bde665efca670c8055499fc8fcf894a450)

18 months agores_pjsip_header_funcs.c: Check URI parameter length before copying.
Sean Bright [Mon, 4 Dec 2023 14:33:26 +0000 (09:33 -0500)] 
res_pjsip_header_funcs.c: Check URI parameter length before copying.

Fixes #477

(cherry picked from commit 002d6c2108184aacfcc3626de93ce85bfe83c051)

18 months agoconfig.c: Log #exec include failures.
Sean Bright [Wed, 22 Nov 2023 19:25:19 +0000 (14:25 -0500)] 
config.c: Log #exec include failures.

If the script referenced by `#exec` does not exist, writes anything to
stderr, or exits abnormally or with a non-zero exit status, we log
that to Asterisk's error logging channel.

Additionally, write out a warning if the script produces no output.

Fixes #259

(cherry picked from commit b437cc3267705b01278da404bf9322cadc5be995)

18 months agomake_xml_documentation: Properly handle absolute LOCAL_MOD_SUBDIRS.
Sean Bright [Mon, 27 Nov 2023 16:43:15 +0000 (11:43 -0500)] 
make_xml_documentation: Properly handle absolute LOCAL_MOD_SUBDIRS.

If LOCAL_MOD_SUBDIRS contains absolute paths, do not prefix them with
the path to Asterisk's source tree.

Fixes #142

(cherry picked from commit 5f0b568341eda9b614bff69479fb29f78ba3b424)

18 months agoapp_voicemail.c: Completely resequence mailbox folders.
Sean Bright [Mon, 27 Nov 2023 15:20:02 +0000 (10:20 -0500)] 
app_voicemail.c: Completely resequence mailbox folders.

Resequencing is a process that occurs when we open a voicemail folder
and discover that there are gaps between messages (e.g. `msg0000.txt`
is missing but `msg0001.txt` exists). Resequencing involves shifting
the existing messages down so we end up with a sequential list of
messages.

Currently, this process stops after reaching a threshold based on the
message limit (`maxmsg`) configured on the current folder. However, if
`maxmsg` is lowered when a voicemail folder contains more than
`maxmsg + 10` messages, resequencing will not run completely leaving
the mailbox in an inconsistent state.

We now resequence up to the maximum number of messages permitted by
`app_voicemail` (currently hard-coded at 9999 messages).

Fixes #86

(cherry picked from commit fbe92dce2b10ceca70ca12a5b901c40f308b9393)

18 months agosig_analog: Fix channel leak when mwimonitor is enabled.
Naveen Albert [Fri, 24 Nov 2023 13:06:58 +0000 (08:06 -0500)] 
sig_analog: Fix channel leak when mwimonitor is enabled.

When mwimonitor=yes is enabled for an FXO port,
the do_monitor thread will launch mwi_thread if it thinks
there could be MWI on an FXO channel, due to the noise
threshold being satisfied. This, in turns, calls
analog_ss_thread_start in sig_analog. However, unlike
all other instances where __analog_ss_thread is called
in sig_analog, this call path does not properly set
pvt->ss_astchan to the Asterisk channel, which means
that the Asterisk channel is NULL when __analog_ss_thread
starts executing. As a result, the thread exits and the
channel is never properly cleaned up by calling ast_hangup.

This caused issues with do_monitor on incoming calls,
as it would think the channel was still owned even while
receiving events, leading to an infinite barrage of
warning messages; additionally, the channel would persist
improperly.

To fix this, the assignment is added to the call path
where it is missing (which is only used for mwi_thread).
A warning message is also added since previously there
was no indication that __analog_ss_thread was exiting
abnormally. This resolves both the channel leak and the
condition that led to the warning messages.

Resolves: #458
(cherry picked from commit c930230a737212cf3bcd386a1a7f13849ab093fc)

18 months agores_rtp_asterisk.c: Update for OpenSSL 3+.
Sean Bright [Mon, 20 Nov 2023 19:56:49 +0000 (14:56 -0500)] 
res_rtp_asterisk.c: Update for OpenSSL 3+.

In 5ac5c2b0 we defined `OPENSSL_SUPPRESS_DEPRECATED` to silence
deprecation warnings. This commit switches over to using
non-deprecated API.

(cherry picked from commit 05924e30f96e867a349a4f6b1981c0b3a6b8eceb)

18 months agoalembic: Update list of TLS methods available on ps_transports.
Sean Bright [Tue, 14 Nov 2023 22:49:04 +0000 (17:49 -0500)] 
alembic: Update list of TLS methods available on ps_transports.

Related to #221 and #222.

Also adds `*.ini` to the `.gitignore` file in ast-db-manage for
convenience.

(cherry picked from commit c7838a352a08acdea3883324ce557db796be9815)

18 months agofunc_channel: Expose previously unsettable options.
Naveen Albert [Sat, 11 Nov 2023 14:35:29 +0000 (09:35 -0500)] 
func_channel: Expose previously unsettable options.

Certain channel options are not set anywhere or
exposed in any way to users, making them unusable.
This exposes some of these options which make sense
for users to manipulate at runtime.

Resolves: #442
(cherry picked from commit 9211fb5e9727f1e955dfda280575f43c2766adf6)

18 months agoapp.c: Allow ampersands in playback lists to be escaped.
Sean Bright [Tue, 7 Nov 2023 20:03:53 +0000 (15:03 -0500)] 
app.c: Allow ampersands in playback lists to be escaped.

Any function or application that accepts a `&`-separated list of
filenames can now include a literal `&` in a filename by wrapping the
entire filename in single quotes, e.g.:

```
exten = _X.,n,Playback('https://example.com/sound.cgi?a=b&c=d'&hello-world)
```

Fixes #172

UpgradeNote: Ampersands in URLs passed to the `Playback()`,
`Background()`, `SpeechBackground()`, `Read()`, `Authenticate()`, or
`Queue()` applications as filename arguments can now be escaped by
single quoting the filename. Additionally, this is also possible when
using the `CONFBRIDGE` dialplan function, or configuring various
features in `confbridge.conf` and `queues.conf`.

(cherry picked from commit 33213c1979ad046d19de48ad8c1357ee70b2464e)

18 months agouri.c: Simplify ast_uri_make_host_with_port()
Sean Bright [Thu, 9 Nov 2023 23:06:22 +0000 (18:06 -0500)] 
uri.c: Simplify ast_uri_make_host_with_port()

(cherry picked from commit e2e18b366c06f3cdfccf6fcfe03027676f316290)

18 months agofunc_curl.c: Remove CURLOPT() plaintext documentation.
Sean Bright [Tue, 14 Nov 2023 01:06:13 +0000 (20:06 -0500)] 
func_curl.c: Remove CURLOPT() plaintext documentation.

I assume this was missed when initially converting to XML
documentation and we've been kicking the can down the road since.

(cherry picked from commit d3c411cd05c0d98729fef751860467941c4097b6)

18 months agores_http_websocket.c: Set hostname on client for certificate validation.
Sean Bright [Thu, 9 Nov 2023 22:59:19 +0000 (17:59 -0500)] 
res_http_websocket.c: Set hostname on client for certificate validation.

Additionally add a `assert()` to in the TLS client setup code to
ensure that hostname is set when it is supposed to be.

Fixes #433

(cherry picked from commit 40a9f5a88c96bfcfac28a7eb210a562f2490fe3d)

18 months agolive_ast: Add astcachedir to generated asterisk.conf.
Sean Bright [Thu, 9 Nov 2023 14:11:33 +0000 (09:11 -0500)] 
live_ast: Add astcachedir to generated asterisk.conf.

`astcachedir` (added in b0842713) was not added to `live_ast` so
continued to point to the system `/var/cache` directory instead of the
one in the live environment.

(cherry picked from commit 1e426b6f1c52069c0ae5daeb03236f4bc1c41371)

18 months agoSECURITY.md: Update with correct documentation URL
George Joseph [Thu, 9 Nov 2023 18:45:08 +0000 (11:45 -0700)] 
SECURITY.md: Update with correct documentation URL

(cherry picked from commit 6ffb295c6961ecf7f41b9f3d1339b8a2320a7275)

18 months agofunc_lock: Add missing see-also refs to documentation.
Naveen Albert [Thu, 9 Nov 2023 15:01:18 +0000 (10:01 -0500)] 
func_lock: Add missing see-also refs to documentation.

Resolves: #423
(cherry picked from commit 3be75073a93cf6eaffcb199b923a75fc3c778f57)

18 months agoapp_followme.c: Grab reference on nativeformats before using it
Matthew Fredrickson [Thu, 26 Oct 2023 02:14:48 +0000 (21:14 -0500)] 
app_followme.c: Grab reference on nativeformats before using it

Fixes a crash due to a lack of proper reference on the nativeformats
object before passing it into ast_request().  Also found potentially
similar use case bugs in app_chanisavail.c, bridge.c, and bridge_basic.c

Fixes: #388
(cherry picked from commit b5c31b55c9812036a41d21de8fc89a2bc6500865)

18 months agoconfigs: Improve documentation for bandwidth in iax.conf.
Naveen Albert [Thu, 9 Nov 2023 15:12:15 +0000 (10:12 -0500)] 
configs: Improve documentation for bandwidth in iax.conf.

This improves the documentation for the bandwidth setting
in iax.conf by making it clearer what the ramifications
of this setting are. It also changes the sample default
from low to high, since only high is compatible with good
codecs that people will want to use in the vast majority
of cases, and this is a common gotcha that trips up new users.

Resolves: #425
(cherry picked from commit 582c4645f3339f9147a2b5f2a29a814dd76f4b1d)

18 months agologger: Add channel-based filtering.
Naveen Albert [Wed, 9 Aug 2023 22:12:55 +0000 (22:12 +0000)] 
logger: Add channel-based filtering.

This adds the ability to filter console
logging by channel or groups of channels.
This can be useful on busy systems where
an administrator would like to analyze certain
calls in detail. A dialplan function is also
included for the purpose of assigning a channel
to a group (e.g. by tenant, or some other metric).

ASTERISK-30483 #close

Resolves: #242

UserNote: The console log can now be filtered by
channels or groups of channels, using the
logger filter CLI commands.

(cherry picked from commit a6439d372334a5c77318521e710f0bd7be1135a9)

18 months agochan_iax2.c: Don't send unsanitized data to the logger.
Sean Bright [Wed, 8 Nov 2023 13:47:42 +0000 (08:47 -0500)] 
chan_iax2.c: Don't send unsanitized data to the logger.

This resolves an issue where non-printable characters could be sent to
the console/log files.

(cherry picked from commit da4e6e7ddb679904bc55d06b2328c842407a4219)

18 months agocodec_ilbc: Disable system ilbc if version >= 3.0.0
George Joseph [Tue, 7 Nov 2023 23:24:37 +0000 (16:24 -0700)] 
codec_ilbc: Disable system ilbc if version >= 3.0.0

Fedora 37 started shipping ilbc 3.0.4 which we don't yet support.
configure.ac now checks the system for "libilbc < 3" instead of
just "libilbc".  If true, the system version of ilbc will be used.
If not, the version included at codecs/ilbc will be used.

Resolves: #84
(cherry picked from commit 5a770ad13f5969b1b5d026960af5820b30fa0137)

18 months agoresource_channels.c: Explicit codec request when creating UnicastRTP.
Sean Bright [Mon, 6 Nov 2023 23:10:02 +0000 (18:10 -0500)] 
resource_channels.c: Explicit codec request when creating UnicastRTP.

Fixes #394

(cherry picked from commit 64603c4807c1e3ba846ed4c36032a4376bdd3a82)

18 months agodoc: Update IP Quality of Service links.
Sean Bright [Tue, 7 Nov 2023 13:39:09 +0000 (08:39 -0500)] 
doc: Update IP Quality of Service links.

Fixes #328

(cherry picked from commit e4eeda650246f910b62096e5bf8c2ece5e327d5d)

18 months agochan_pjsip: Add PJSIPHangup dialplan app and manager action
George Joseph [Tue, 31 Oct 2023 21:08:14 +0000 (15:08 -0600)] 
chan_pjsip: Add PJSIPHangup dialplan app and manager action

See UserNote below.

Exposed the existing Hangup AMI action in manager.c so we can use
all of it's channel search and AMI protocol handling without
duplicating that code in dialplan_functions.c.

Added a lookup function to res_pjsip.c that takes in the
string represenation of the pjsip_status_code enum and returns
the actual status code.  I.E.  ast_sip_str2rc("DECLINE") returns
603.  This allows the caller to specify PJSIPHangup(decline) in
the dialplan, just like Hangup(call_rejected).

Also extracted the XML documentation to its own file since it was
almost as large as the code itself.

UserNote: A new dialplan app PJSIPHangup and AMI action allows you
to hang up an unanswered incoming PJSIP call with a specific SIP
response code in the 400 -> 699 range.

(cherry picked from commit af7e89ebf82f9d23e1f81c7cc6ec20b4ffdf70e6)

18 months agochan_iax2.c: Ensure all IEs are displayed when dumping frame contents.
Sean Bright [Mon, 6 Nov 2023 16:45:33 +0000 (11:45 -0500)] 
chan_iax2.c: Ensure all IEs are displayed when dumping frame contents.

When IAX2 debugging was enabled (`iax2 set debug on`), if the last IE
in a frame was one that may not have any data - such as the CALLTOKEN
IE in an NEW request - it was not getting displayed.

(cherry picked from commit 19507ae160f796363a7332276c5d5628e2e84b0e)

18 months agochan_dahdi: Warn if nonexistent cadence is requested.
Naveen Albert [Thu, 2 Nov 2023 20:51:22 +0000 (16:51 -0400)] 
chan_dahdi: Warn if nonexistent cadence is requested.

If attempting to ring a channel using a nonexistent cadence,
emit a warning, before falling back to the default cadence.

Resolves: #409
(cherry picked from commit cdcdca519930158b527c72e620a66981fec1a2b6)

18 months agostasis: Update the snapshot after setting the redirect
Holger Hans Peter Freyther [Sat, 21 Oct 2023 09:39:50 +0000 (17:39 +0800)] 
stasis: Update the snapshot after setting the redirect

The previous commit added the caller_rdnis attribute. Make it
avialble during a possible ChanngelHangupRequest.

(cherry picked from commit 9fd2655d5a565642ccaa26284bbc4c82c998a6b0)

18 months agoari: Provide the caller ID RDNIS for the channels
Holger Hans Peter Freyther [Sat, 14 Oct 2023 07:48:10 +0000 (15:48 +0800)] 
ari: Provide the caller ID RDNIS for the channels

Provide the caller ID RDNIS when available. This will allow an
application to follow the redirect.

(cherry picked from commit da0b1ac1c1c9236fafea74fbba6d0f9d8dd2992c)

18 months agomain/utils: Implement ast_get_tid() for OpenBSD
Brad Smith [Thu, 2 Nov 2023 00:22:58 +0000 (20:22 -0400)] 
main/utils: Implement ast_get_tid() for OpenBSD

Implement the ast_get_tid() function for OpenBSD. OpenBSD supports
getting the TID via getthrid().

(cherry picked from commit 29a3e5660bd8cbe6985ccb3a5571bdc150e42497)

18 months agores_rtp_asterisk.c: Fix runtime issue with LibreSSL
Brad Smith [Thu, 2 Nov 2023 06:26:09 +0000 (02:26 -0400)] 
res_rtp_asterisk.c: Fix runtime issue with LibreSSL

The module will fail to load. Use proper function DTLS_method() with LibreSSL.

(cherry picked from commit 1d9c5faeb399305e62c310d432ca9553b6704b8d)

18 months agoapp_directory: Add ADSI support to Directory.
Naveen Albert [Wed, 27 Sep 2023 12:49:07 +0000 (08:49 -0400)] 
app_directory: Add ADSI support to Directory.

This adds optional ADSI support to the Directory
application, which allows callers with ADSI CPE
to navigate the Directory system significantly
faster than is possible using the audio prompts.
Callers can see the directory name (and optionally
extension) on their screenphone and confirm or
reject a match immediately rather than waiting
for it to be spelled out, enhancing usability.

Resolves: #356
(cherry picked from commit 4a356e984c7aa1d10f2770e9f0ece43198672330)

18 months agocore_local: Fix local channel parsing with slashes.
Naveen Albert [Wed, 9 Aug 2023 22:57:41 +0000 (22:57 +0000)] 
core_local: Fix local channel parsing with slashes.

Currently, trying to call a Local channel with a slash
in the extension will fail due to the parsing of characters
after such a slash as being dial modifiers. Additionally,
core_local is inconsistent and incomplete with
its parsing of Local dial strings in that sometimes it
uses the first slash and at other times it uses the last.

For instance, something like DAHDI/5 or PJSIP/device
is a perfectly usable extension in the dialplan, but Local
channels in particular prevent these from being called.

This creates inconsistent behavior for users, since using
a slash in an extension is perfectly acceptable, and using
a Goto to accomplish this works fine, but if specified
through a Local channel, the parsing prevents this.

This fixes this by explicitly parsing options from the
last slash in the extension, rather than the first one,
which doesn't cause an issue for extensions with slashes.

ASTERISK-30013 #close

Resolves: #248
(cherry picked from commit 65f83311b7904acca9d061290a85e9219c68f3a9)

18 months agoRemove files that are no longer updated
Mark Murawski [Mon, 30 Oct 2023 15:38:22 +0000 (11:38 -0400)] 
Remove files that are no longer updated

Fixes: #360
(cherry picked from commit 6ebd820e269ec139e4a3ad8b5670df04a22c72df)

18 months agoapp_voicemail: Add AMI event for mailbox PIN changes.
Naveen Albert [Mon, 30 Oct 2023 13:27:20 +0000 (09:27 -0400)] 
app_voicemail: Add AMI event for mailbox PIN changes.

This adds an AMI event that is emitted whenever a
mailbox password is successfully changed, allowing
AMI consumers to process these.

UserNote: The VoicemailPasswordChange event is
now emitted whenever a mailbox password is updated,
containing the mailbox information and the new
password.

Resolves: #398
(cherry picked from commit 95bc661542c18a32f854d6ab9428ba1e750cec57)

18 months agoapp_queue.c: Emit unpause reason with PauseQueueMember event.
Sean Bright [Mon, 30 Oct 2023 14:13:56 +0000 (10:13 -0400)] 
app_queue.c: Emit unpause reason with PauseQueueMember event.

Fixes #395

(cherry picked from commit baf3ce25f52337f987585cde7e7e93a9f05b7861)

18 months agobridge_simple: Suppress unchanged topology change requests
George Joseph [Mon, 30 Oct 2023 18:01:04 +0000 (12:01 -0600)] 
bridge_simple: Suppress unchanged topology change requests

In simple_bridge_join, we were sending topology change requests
even when the new and old topologies were the same.  In some
circumstances, this can cause unnecessary re-invites and even
a re-invite flood.  We now suppress those.

Resolves: #384
(cherry picked from commit 57d31d97dcc80d3aeb839807e81198a97cf4a362)

18 months agores_pjsip: Include cipher limit in config error message.
Naveen Albert [Mon, 30 Oct 2023 11:09:54 +0000 (07:09 -0400)] 
res_pjsip: Include cipher limit in config error message.

If too many ciphers are specified in the PJSIP config,
include the maximum number of ciphers that may be
specified in the user-facing error message.

Resolves: #396
(cherry picked from commit d4185ca025961eda0426ff7e5eae66ec963efc59)

18 months agores_speech: allow speech to translate input channel
Mike Bradeen [Thu, 7 Sep 2023 17:21:32 +0000 (11:21 -0600)] 
res_speech: allow speech to translate input channel

* Allow res_speech to translate the input channel if the
  format is translatable to a format suppored by the
  speech provider.

Resolves: #129

UserNote: res_speech now supports translation of an input channel
to a format supported by the speech provider, provided a translation
path is available between the source format and provider capabilites.

(cherry picked from commit e8fbdca40bf6ddec0073a28cd58b62209a66bfd1)

18 months agores_rtp_asterisk.c: Fix memory leak in ephemeral certificate creation.
Sean Bright [Wed, 25 Oct 2023 22:19:13 +0000 (18:19 -0400)] 
res_rtp_asterisk.c: Fix memory leak in ephemeral certificate creation.

Fixes #386

(cherry picked from commit 74a5c452de6f78e3182c65603cb8c27fe1287b92)

18 months agores_pjsip_dtmf_info.c: Add 'INFO' to Allow header.
Sean Bright [Tue, 17 Oct 2023 15:33:41 +0000 (11:33 -0400)] 
res_pjsip_dtmf_info.c: Add 'INFO' to Allow header.

Fixes #376

(cherry picked from commit 3af55f14fa351f9e9349289939f7a68df3696c9d)

18 months agoapi.wiki.mustache: Fix indentation in generated markdown
George Joseph [Wed, 25 Oct 2023 11:06:26 +0000 (05:06 -0600)] 
api.wiki.mustache: Fix indentation in generated markdown

The '*' list indicator for default values and allowable values for
path, query and POST parameters need to be indented 4 spaces
instead of 2.

Should resolve issue 38 in the documentation repo.

(cherry picked from commit 443f94b43826470e7b0c92881a1af1c4ec586bc9)

18 months agopjsip_configuration.c: Disable DTLS renegotiation if WebRTC is enabled.
Sean Bright [Mon, 23 Oct 2023 19:53:08 +0000 (15:53 -0400)] 
pjsip_configuration.c: Disable DTLS renegotiation if WebRTC is enabled.

Per RFC8827:

    Implementations MUST NOT implement DTLS renegotiation and MUST
    reject it with a "no_renegotiation" alert if offered.

So we disable it when webrtc=yes is set.

Fixes #378

UpgradeNote: The dtls_rekey will be disabled if webrtc support is
requested on an endpoint. A warning will also be emitted.

(cherry picked from commit c7afd5357c9e1ec5d779d04391b52e77f2513b59)

18 months agoconfigs: Fix typo in pjsip.conf.sample.
Samuel Olaechea [Thu, 12 Oct 2023 22:15:37 +0000 (18:15 -0400)] 
configs: Fix typo in pjsip.conf.sample.

(cherry picked from commit 4c507d31b93a76c9bd194c10028c900064f37f2b)

18 months agores_pjsip_exten_state,res_pjsip_mwi: Allow unload on shutdown
George Joseph [Thu, 19 Oct 2023 13:40:26 +0000 (07:40 -0600)] 
res_pjsip_exten_state,res_pjsip_mwi: Allow unload on shutdown

Commit f66f77f last year prevents the res_pjsip_exten_state and
res_pjsip_mwi modules from unloading due to possible pjproject
asserts if the modules are reloaded. A side effect of the
implementation is that the taskprocessors these modules use aren't
being released. When asterisk is doing a graceful shutdown, it
waits AST_TASKPROCESSOR_SHUTDOWN_MAX_WAIT seconds for all
taskprocessors to stop but since those 2 modules don't release
theirs, the shutdown hangs for that amount of time.

This change allows the modules to be unloaded and their resources to
be released when ast_shutdown_final is true.

Resolves: #379
(cherry picked from commit b9ee6644406b6290e4a23eb54d99d69ce48b966b)

18 months agores_pjsip: Expanding PJSIP endpoint ID and relevant resource length to 255 characters
sungtae kim [Fri, 22 Sep 2023 17:32:43 +0000 (02:32 +0900)] 
res_pjsip: Expanding PJSIP endpoint ID and relevant resource length to 255 characters

This commit introduces an extension to the endpoint and relevant
resource sizes for PJSIP, transitioning from its current 40-character
constraint to a more versatile 255-character capacity. This enhancement
significantly overcomes limitations related to domain qualification and
practical usage, ultimately delivering improved functionality. In
addition, it includes adjustments to accommodate the expanded realm size
within the ARI, specifically enhancing the maximum realm length.

Resolves: #345

UserNote: With this update, the PJSIP realm lengths have been extended
to support up to 255 characters.

UpgradeNote: As part of this update, the maximum allowable length
for PJSIP endpoints and relevant resources has been increased from
40 to 255 characters. To take advantage of this enhancement, it is
recommended to run the necessary procedures (e.g., Alembic) to
update your schemas.

(cherry picked from commit 9b70b18dec3e9d788a907867925a5c613cc10e70)

18 months ago.github: PRSubmitActions: Fix adding reviewers to PR
George Joseph [Thu, 19 Oct 2023 15:54:43 +0000 (09:54 -0600)] 
.github: PRSubmitActions: Fix adding reviewers to PR

(cherry picked from commit 79c58451419f182c6fad475f313967d1de325fee)

18 months ago.github: New PR Submit workflows
George Joseph [Tue, 17 Oct 2023 12:59:43 +0000 (06:59 -0600)] 
.github: New PR Submit workflows

The workflows that get triggered when PRs are submitted or updated
have been replaced with ones that are more secure and have
a higher level of parallelism.

(cherry picked from commit 6389654b2199dcd9eaf7f8dbff87a43c3ec736d4)

18 months ago.github: New PR Submit workflows
George Joseph [Tue, 17 Oct 2023 12:59:43 +0000 (06:59 -0600)] 
.github: New PR Submit workflows

The workflows that get triggered when PRs are submitted or updated
have been replaced with ones that are more secure and have
a higher level of parallelism.

(cherry picked from commit d06bb7f2fe2830661f77f28d609e035b2a4d6e60)

18 months agores_stasis: signal when new command is queued
Mike Bradeen [Mon, 2 Oct 2023 18:35:32 +0000 (12:35 -0600)] 
res_stasis: signal when new command is queued

res_statsis's app loop sleeps for up to .2s waiting on input
to a channel before re-checking the command queue. This can
cause delays between channel setup and bridge.

This change is to send a SIGURG on the sleeping thread when
a new command is enqueued. This exits the sleeping thread out
of the ast_waitfor() call triggering the new command being
processed on the channel immediately.

Resolves: #362

UserNote: Call setup times should be significantly improved
when using ARI.

(cherry picked from commit 7ea0e3bfdaa23aa3d2e9d88b2bf4016179233335)

18 months agoari/stasis: Indicate progress before playback on a bridge
Holger Hans Peter Freyther [Mon, 2 Oct 2023 12:03:03 +0000 (20:03 +0800)] 
ari/stasis: Indicate progress before playback on a bridge

Make it possible to start a playback and the calling party
to receive audio on a bridge before the call is connected.

Model the implementation after play_on_channel and deliver a
AST_CONTROL_PROGRESS before starting the playback.

For a PJSIP channel this will result in sending a SIP 183
Session Progress.

(cherry picked from commit 624c7ac88326e75ae60975d2bbcf5e9d4d03d1ba)

18 months agofunc_curl.c: Ensure channel is locked when manipulating datastores.
Sean Bright [Mon, 9 Oct 2023 13:32:57 +0000 (09:32 -0400)] 
func_curl.c: Ensure channel is locked when manipulating datastores.

(cherry picked from commit 8c1491dda97f4973a3fd0bf8866ce8aa31a38125)

18 months ago.github: Fix job prereqs in PROpenedUpdated
George Joseph [Mon, 9 Oct 2023 13:22:49 +0000 (07:22 -0600)] 
.github: Fix job prereqs in PROpenedUpdated

(cherry picked from commit 9e9037a8aa3015d5f06d1fa93f83a89ae8ad7ff3)

18 months ago.github: Block PR tests until approved
George Joseph [Thu, 5 Oct 2023 16:23:13 +0000 (10:23 -0600)] 
.github: Block PR tests until approved

(cherry picked from commit 29e202085d86507afa4f181d4f2270a798faede4)

18 months ago.github: Use generic releaser
George Joseph [Tue, 15 Aug 2023 19:04:38 +0000 (13:04 -0600)] 
.github: Use generic releaser

(cherry picked from commit ceddfbe7b8b1d7d527249ef38864fea665f8a758)

18 months agologger.h: Add ability to change the prefix on SCOPE_TRACE output
George Joseph [Thu, 5 Oct 2023 14:18:17 +0000 (08:18 -0600)] 
logger.h: Add ability to change the prefix on SCOPE_TRACE output

You can now define the _TRACE_PREFIX_ macro to change the
default trace line prefix of "file:line function" to
something else.  Full documentation in logger.h.

(cherry picked from commit f599114ee3749a309f775834be45c4ccdda03e20)

18 months agoAdd libjwt to third-party
George Joseph [Thu, 21 Sep 2023 17:12:31 +0000 (11:12 -0600)] 
Add libjwt to third-party

The current STIR/SHAKEN implementation is not currently usable due
to encryption issues. Rather than trying to futz with OpenSSL and
the the current code, we can take advantage of the existing
capabilities of libjwt but we first need to add it to the
third-party infrastructure already in place for jansson and
pjproject.

A few tweaks were also made to the third-party infrastructure as
a whole.  The jansson "dest" install directory was renamed "dist"
to better match convention, and the third-party Makefile was updated
to clean all product directories not just the ones currently in
use.

Resolves: #349
(cherry picked from commit d7a6116681c28b7c8ccc5733dffbebbbf75f273c)

18 months agores_pjsip: update qualify_timeout documentation with DNS note
Mike Bradeen [Tue, 26 Sep 2023 19:19:27 +0000 (13:19 -0600)] 
res_pjsip: update qualify_timeout documentation with DNS note

The documentation on qualify_timeout does not explicitly state that the timeout
includes any time required to perform any needed DNS queries on the endpoint.

If the OPTIONS response is delayed due to the DNS query, it can still render an
endpoint as Unreachable if the net time is enough for qualify_timeout to expire.

Resolves: #352
(cherry picked from commit 323a51fd6c0ff18c16702138e5e8aff3529ebf57)

18 months agochan_dahdi: Clarify scope of callgroup/pickupgroup.
Naveen Albert [Mon, 4 Sep 2023 11:58:23 +0000 (07:58 -0400)] 
chan_dahdi: Clarify scope of callgroup/pickupgroup.

Internally, chan_dahdi only applies callgroup and
pickupgroup to FXO signalled channels, but this is
not documented anywhere. This is now documented in
the sample config, and a warning is emitted if a
user tries configuring these settings for channel
types that do not support these settings, since they
will not have any effect.

Resolves: #294
(cherry picked from commit 5b89e40541ccf40cb3703cc00ef5fa9815f896ca)

18 months agofunc_json: Fix crashes for some types
Bastian Triller [Thu, 21 Sep 2023 06:24:37 +0000 (08:24 +0200)] 
func_json: Fix crashes for some types

This commit fixes crashes in JSON_DECODE() for types null, true, false
and real numbers.

In addition it ensures that a path is not deeper than 32 levels.

Also allow root object to be an array.

Add unit tests for above cases.

(cherry picked from commit 1cbbf36929b47bb6b9c125f630d6bcd03618fcde)

18 months agores_speech_aeap: add aeap error handling
Mike Bradeen [Thu, 21 Sep 2023 18:54:45 +0000 (12:54 -0600)] 
res_speech_aeap: add aeap error handling

res_speech_aeap previously did not register an error handler
with aeap, so it was not notified of a disconnect. This resulted
in SpeechBackground never exiting upon a websocket disconnect.

Resolves: #303
(cherry picked from commit e921f5e010accdb1065c4eb6139fd099b8dba93e)

18 months agoapp_voicemail: Disable ADSI if unavailable.
Naveen Albert [Wed, 27 Sep 2023 12:28:50 +0000 (08:28 -0400)] 
app_voicemail: Disable ADSI if unavailable.

If ADSI is available on a channel, app_voicemail will repeatedly
try to use ADSI, even if there is no CPE that supports it. This
leads to many unnecessary delays during the session. If ADSI is
available but ADSI setup fails, we now disable it to prevent
further attempts to use ADSI during the session.

Resolves: #354
(cherry picked from commit 75620616f46d054aa6a7bbff1753b05c7abc642a)

18 months agocodec_builtin: Use multiples of 20 for maximum_ms
Eduardo [Fri, 28 Jul 2023 18:01:46 +0000 (15:01 -0300)] 
codec_builtin: Use multiples of 20 for maximum_ms

Some providers require a multiple of 20 for the maxptime or fail to complete calls,
e.g. Vivo in Brazil. To increase compatibility, only multiples of 20 are now used.

Resolves: #260
(cherry picked from commit ca1ed84820f84416278f770f773aa1fa2b5efc03)

18 months agolock.c: Separate DETECT_DEADLOCKS from DEBUG_THREADS
George Joseph [Wed, 13 Sep 2023 15:18:04 +0000 (09:18 -0600)] 
lock.c: Separate DETECT_DEADLOCKS from DEBUG_THREADS

Previously, DETECT_DEADLOCKS depended on DEBUG_THREADS.
Unfortunately, DEBUG_THREADS adds a lot of lock tracking overhead
to all of the lock lifecycle calls whereas DETECT_DEADLOCKS just
causes the lock calls to loop over trylock in 200us intervals until
the lock is obtained and spits out log messages if it takes more
than 5 seconds.  From a code perspective, the only reason they were
tied together was for logging.  So... The ifdefs in lock.c were
refactored to allow DETECT_DEADLOCKS to be enabled without
also enabling DEBUG_THREADS.

Resolves: #321

UserNote: You no longer need to select DEBUG_THREADS to use
DETECT_DEADLOCKS.  This removes a significant amount of overhead
if you just want to detect possible deadlocks vs needing full
lock tracing.

(cherry picked from commit e1050b4add81f3c4ab7e2eb1511747bef1a9321b)

18 months agoasterisk.c: Use the euid's home directory to read/write cli history
George Joseph [Fri, 15 Sep 2023 17:19:18 +0000 (11:19 -0600)] 
asterisk.c: Use the euid's home directory to read/write cli history

The CLI .asterisk_history file is read from/written to the directory
specified by the HOME environment variable. If the root user starts
asterisk with the -U/-G options, or with runuser/rungroup set in
asterisk.conf, the asterisk process is started as root but then it
calls setuid/setgid to set the new user/group. This does NOT reset
the HOME environment variable to the new user's home directory
though so it's still left as "/root". In this case, the new user
will almost certainly NOT have access to read from or write to the
history file.

* Added function process_histfile() which calls
  getpwuid(geteuid()) and uses pw->dir as the home directory
  instead of the HOME environment variable.
* ast_el_read_default_histfile() and ast_el_write_default_histfile()
  have been modified to use the new process_histfile()
  function.

Resolves: #337
(cherry picked from commit fc516f5781bbf14ba3c4d3f27d614d6ca564a6cd)

18 months agores_pjsip_transport_websocket: Prevent transport from being destroyed before message...
Tinet-mucw [Wed, 13 Sep 2023 09:12:12 +0000 (17:12 +0800)] 
res_pjsip_transport_websocket: Prevent transport from being destroyed before message finishes.

From the gdb information, ast_websocket_read reads a message successfully,
then transport_read is called in the serializer. During execution of pjsip_transport_down,
ws_session->stream->fd is closed; ast_websocket_read encounters an error and exits the while loop.
After executing transport_shutdown, the transport's reference count becomes 0, causing a crash when sending SIP messages.
This was due to pjsip_transport_dec_ref executing earlier than pjsip_rx_data_clone, leading to this issue.
In websocket_cb executeing pjsip_transport_add_ref, this we now ensure the transport is not destroyed while in the loop.

Resolves: asterisk#299
(cherry picked from commit a38add11e687b230d555d81084eca7d74d464f67)

18 months agocel: add publish user event helper
Mike Bradeen [Thu, 14 Sep 2023 17:00:19 +0000 (11:00 -0600)] 
cel: add publish user event helper

Add a wrapper function around ast_cel_publish_event that
packs event and extras into a blob before publishing

Resolves:#330
(cherry picked from commit 4592f97c366ba35515f3a80b9988cebd08ae9fce)

18 months agochan_console: Fix deadlock caused by unclean thread exit.
Naveen Albert [Sat, 9 Sep 2023 15:24:37 +0000 (11:24 -0400)] 
chan_console: Fix deadlock caused by unclean thread exit.

To terminate a console channel, stop_stream causes pthread_cancel
to make stream_monitor exit. However, commit 5b8fea93d106332bc0faa4b7fa8a6ea71e546cac
added locking to this function which results in deadlock due to
the stream_monitor thread being killed while it's holding the pvt lock.

To resolve this, a flag is now set and read to indicate abort, so
the use of pthread_cancel and pthread_kill can be avoided altogether.

Resolves: #308
(cherry picked from commit 3b027d1e476a444ec28883417a718ac123362dc1)

18 months agofile.c: Add ability to search custom dir for sounds
George Joseph [Mon, 11 Sep 2023 14:27:41 +0000 (08:27 -0600)] 
file.c: Add ability to search custom dir for sounds

To better co-exist with sounds files that may be managed by
packages, custom sound files may now be placed in
AST_DATA_DIR/sounds/custom instead of the standard
AST_DATA_DIR/sounds/<lang> directory.  If the new
"sounds_search_custom_dir" option in asterisk.conf is set
to "true", asterisk will search the custom directory for sounds
files before searching the standard directory.  For performance
reasons, the "sounds_search_custom_dir" defaults to "false".

Resolves: #315

UserNote: A new option "sounds_search_custom_dir" has been added to
asterisk.conf that allows asterisk to search
AST_DATA_DIR/sounds/custom for sounds files before searching the
standard AST_DATA_DIR/sounds/<lang> directory.

(cherry picked from commit 0e0f99db1d62b7642a51d2552256eece5d435bc8)

18 months agochan_iax2: Improve authentication debugging.
Naveen Albert [Wed, 30 Aug 2023 13:12:38 +0000 (09:12 -0400)] 
chan_iax2: Improve authentication debugging.

Improves and adds some logging to make it easier
for users to debug authentication issues.

Resolves: #286
(cherry picked from commit f93138bcad6f8f43611d210714d79cef4cefd75a)

18 months agores_rtp_asterisk: fix wrong counter management in ioqueue objects
Vitezslav Novy [Tue, 5 Sep 2023 11:51:26 +0000 (13:51 +0200)] 
res_rtp_asterisk: fix wrong counter management in ioqueue objects

In function  rtp_ioqueue_thread_remove counter in ioqueue object is not decreased
which prevents unused ICE TURN threads from being removed.

Resolves: #301
(cherry picked from commit 56244a7371fb8c113e7e6b932b8a2dd3b81a2dcc)

18 months agores_pjsip_pubsub: Add body_type to test_handler for unit tests
George Joseph [Fri, 15 Sep 2023 16:17:11 +0000 (10:17 -0600)] 
res_pjsip_pubsub: Add body_type to test_handler for unit tests

The ast_sip_subscription_handler "test_handler" used for the unit
tests didn't set "body_type" so the NULL value was causing
a SEGV in build_subscription_tree().  It's now set to "".

Resolves: #335
(cherry picked from commit 71d75373f9df6b971ac069abfbf39be42a1caf70)