Commit Graph

33959 Commits

Author SHA1 Message Date
Sean Bright
f97ad807ff alembic: Drop redundant voicemail_messages index.
The `voicemail_messages_dir` index is a left prefix of the table's
primary key and therefore unnecessary.
2024-10-01 15:44:47 +00:00
Sean Bright
243f20a78d res_agi.c: Ensure SIGCHLD handler functions are properly balanced.
Calls to `ast_replace_sigchld()` and `ast_unreplace_sigchld()` must be
balanced to ensure that we can capture the exit status of child
processes when we need to. This extends to functions that call
`ast_replace_sigchld()` and `ast_unreplace_sigchld()` such as
`ast_safe_fork()` and `ast_safe_fork_cleanup()`.

The primary change here is ensuring that we do not call
`ast_safe_fork_cleanup()` in `res_agi.c` if we have not previously
called `ast_safe_fork()`.

Additionally we reinforce some of the documentation and add an
assertion to, ideally, catch this sooner were this to happen again.

Fixes #922
2024-10-01 15:01:31 +00:00
Naveen Albert
b8b21b3f00 main, res, tests: Fix compilation errors on FreeBSD.
asterisk.c, manager.c: Increase buffer sizes to avoid truncation warnings.
config.c: Include header file for WIFEXITED/WEXITSTATUS macros.
res_timing_kqueue: Use more portable format specifier.
test_crypto: Use non-linux limits.h header file.

Resolves: #916
2024-10-01 14:22:49 +00:00
George Joseph
7db8ae296c res_rtp_asterisk: Fix dtls timer issues causing FRACKs and SEGVs
In dtls_srtp_handle_timeout(), when DTLSv1_get_timeout() returned
success but with a timeout of 0, we were stopping the timer and
decrementing the refcount on instance but not resetting the
timeout_timer to -1.  When dtls_srtp_stop_timeout_timer()
was later called, it was atempting to stop a stale timer and could
decrement the refcount on instance again which would then cause
the instance destructor to run early.  This would result in either
a FRACK or a SEGV when ast_rtp_stop(0 was called.

According to the OpenSSL docs, we shouldn't have been stopping the
timer when DTLSv1_get_timeout() returned success and the new timeout
was 0 anyway.  We should have been calling DTLSv1_handle_timeout()
again immediately so we now reschedule the timer callback for
1ms (almost immediately).

Additionally, instead of scheduling the timer callback at a fixed
interval returned by the initial call to DTLSv1_get_timeout()
(usually 999 ms), we now reschedule the next callback based on
the last call to DTLSv1_get_timeout().

Resolves: #487
2024-10-01 14:22:44 +00:00
Ben Ford
e8d3869e75 manager.c: Restrict ModuleLoad to the configured modules directory.
When using the ModuleLoad AMI action, it was possible to traverse
upwards through the directories to files outside of the configured
modules directory. We decided it would be best to restrict access to
modules exclusively in the configured directory. You will now get an
error when the specified module is outside of this limitation.

Fixes: #897

UserNote: The ModuleLoad AMI action now restricts modules to the
configured modules directory.
2024-09-30 16:28:41 +00:00
jiangxc
2d676c7560 res_agi.c: Prevent possible double free during SPEECH RECOGNIZE
When using the speech recognition module, crashes can occur
sporadically due to a "double free or corruption (out)" error. Now, in
the section where the audio stream is being captured in a loop, each
time after releasing fr, it is set to NULL to prevent repeated
deallocation.

Fixes #772
2024-09-30 16:23:41 +00:00
Sean Bright
084c04f711 cdr_custom: Allow absolute filenames.
A follow up to #893 that brings the same functionality to
cdr_custom. Also update the sample configuration files to note support
for absolute paths.
2024-09-30 15:32:40 +00:00
Naveen Albert
7c982de5c6 astfd.c: Avoid calling fclose with NULL argument.
Don't pass through a NULL argument to fclose, which is undefined
behavior, and instead return -1 and set errno appropriately. This
also avoids a compiler warning with glibc 2.38 and newer, as glibc
commit 71d9e0fe766a3c22a730995b9d024960970670af
added the nonnull attribute to this argument.

Resolves: #900
2024-09-25 18:27:17 +00:00
Peter Jannesen
f3e74d34ce channel: Preserve CHANNEL(userfield) on masquerade.
In certain circumstances a channel may undergo an operation
referred to as a masquerade. If this occurs the CHANNEL(userfield)
value was not preserved causing it to get lost. This change makes
it so that this field is now preserved.

Fixes: #882
2024-09-25 17:03:28 +00:00
Peter Jannesen
0ed7f5800d cel_custom: Allow absolute filenames.
If a filename starts with a '/' in cel_custom [mappings] assume it is
a absolute file path and not relative filename/path to
AST_LOG_DIR/cel_custom/
2024-09-25 17:02:37 +00:00
Naveen Albert
9423710a5e app_voicemail: Fix ill-formatted pager emails with custom subject.
Add missing end-of-headers newline to pager emails with custom
subjects, since this was missing from this code path.

Resolves: #902
2024-09-25 17:00:59 +00:00
Sean Bright
3243316dac res_pjsip_pubsub: Persist subscription 'generator_data' in sorcery
Fixes #895
2024-09-25 16:51:15 +00:00
George Joseph
8155b0e50f stir_shaken: Fix propagation of attest_level and a few other values
attest_level, send_mky and check_tn_cert_public_url weren't
propagating correctly from the attestation object to the profile
and tn.

* In the case of attest_level, the enum needed to be changed
so the "0" value (the default) was "NOT_SET" instead of "A".  This
now allows the merging of the attestation object, profile and tn
to detect when a value isn't set and use the higher level value.

* For send_mky and check_tn_cert_public_url, the tn default was
forced to "NO" which always overrode the profile and attestation
objects.  Their defaults are now "NOT_SET" so the propagation
happens correctly.

* Just to remove some redundant code in tn_config.c, a bunch of calls to
generate_sorcery_enum_from_str() and generate_sorcery_enum_to_str() were
replaced with a single call to generate_acfg_common_sorcery_handlers().

Resolves: #904
2024-09-25 16:35:30 +00:00
George Joseph
48acf00eab Fix application references to Background
The app is actually named "BackGround" but several references
in XML documentation were spelled "Background" with the lower
case "g".  This was causing documentation links to return
"not found" messages.
2024-09-25 16:32:21 +00:00
George Joseph
ce35f5684b manager.conf.sample: Fix mathcing typo 2024-09-25 12:59:15 +00:00
George Joseph
92c0bd4b50 manager: Enhance event filtering for performance
UserNote: You can now perform more granular filtering on events
in manager.conf using expressions like
`eventfilter(name(Newchannel),header(Channel),method(starts_with)) = PJSIP/`
This is much more efficient than
`eventfilter = Event: Newchannel.*Channel: PJSIP/`
Full syntax guide is in configs/samples/manager.conf.sample.
2024-09-23 14:45:38 +00:00
George Joseph
a26e79dfe2 manager.c: Split XML documentation to manager_doc.xml 2024-09-23 14:45:38 +00:00
George Joseph
94237f684a .github: Fix realtime param on Weekly and Nightly tests and...
Rename the "Cleanup" job in the cherry-pick and recheck jobs
to "Summary".
2024-09-23 08:26:05 -06:00
George Joseph
60ad3efc9d .github: Add WeeklyTests and make Nightlies Monday-Saturday
...and add "realtime" option.
2024-09-20 09:28:43 -06:00
George Joseph
cc06c95ed2 db.c: Remove limit on family/key length
Consumers like media_cache have been running into issues with
the previous astdb "/family/key" limit of 253 bytes when needing
to store things like long URIs.  An Amazon S3 URI is a good example
of this.  Now, instead of using a static 256 byte buffer for
"/family/key", we use ast_asprintf() to dynamically create it.

Both test_db.c and test_media_cache.c were also updated to use
keys/URIs over the old 253 character limit.

Resolves: #881

UserNote: The `ast_db_*()` APIs have had the 253 byte limit on
"/family/key" removed and will now accept families and keys with a
total length of up to SQLITE_MAX_LENGTH (currently 1e9!).  This
affects the `DB*` dialplan applications, dialplan functions,
manager actions and `databse` CLI commands.  Since the
media_cache also uses the `ast_db_*()` APIs, you can now store
resources with URIs longer than 253 bytes.
2024-09-20 14:06:27 +00:00
George Joseph
24d641f40a .github: Changes required to use cached builds and shorten names 2024-09-18 08:06:26 -06:00
George Joseph
c33ff71708 res_stir_shaken: Remove stale include for jansson.h in verification.c
verification.c had an include for jansson.h left over from previous
versions of the module.  Since res_stir_shaken no longer has a
dependency on jansson, the bundled version wasn't added to GCC's
include path so if you didn't also have a jansson development package
installed, the compile would fail.  Removing the stale include
was the only thing needed.

Resolves: #889
2024-09-18 01:32:42 +00:00
George Joseph
03d0d1eba4 res_stir_shaken.c: Fix crash when stir_shaken.conf is invalid
* If the call to ast_config_load() returns CONFIG_STATUS_FILEINVALID,
check_for_old_config() now returns LOAD_DECLINE instead of continuing
on with a bad pointer.

* If CONFIG_STATUS_FILEMISSING is returned, check_for_old_config()
assumes the config is being loaded from realtime and now returns
LOAD_SUCCESS.  If it's actually not being loaded from realtime,
sorcery will catch that later on.

* Also refactored the error handling in load_module() a bit.

Resolves: #884
2024-09-17 16:15:24 +00:00
George Joseph
7773327546 res_stir_shaken: Check for disabled before param validation
For both attestation and verification, we now check whether they've
been disabled either globally or by the profile before validating
things like callerid, orig_tn, dest_tn, etc.  This prevents useless
error messages.

Resolves: #879
2024-09-11 21:14:04 +00:00
Tinet-mucw
a721f99eb0 app_chanspy.c: resolving the issue writing frame to whisper audiohook.
ChanSpy(${channel}, qEoSw): because flags set o, ast_audiohook_set_frame_feed_direction(audiohook, AST_AUDIOHOOK_DIRECTION_READ); this will effect whisper audiohook and spy audiohook, this makes writing frame to whisper audiohook impossible. So add function start_whispering to starting whisper audiohook.

Resolves: #876
2024-09-11 11:39:48 +00:00
Alexei Gradinari
b9b0cffc29 autoservice: Do not sleep if autoservice_stop is called within autoservice thread
It's possible that ast_autoservice_stop is called within the autoservice thread.
In this case the autoservice thread is stuck in an endless sleep.

To avoid endless sleep ast_autoservice_stop must check that it's not called
within the autoservice thread.

Fixes: #763
2024-09-09 23:17:16 +00:00
George Joseph
3265d66e98 res_resolver_unbound: Test for NULL ub_result in unbound_resolver_callback
The ub_result pointer passed to unbound_resolver_callback by
libunbound can be NULL if the query was for something malformed
like `.1` or `[.1]`.  If it is, we now set a 'ns_r_formerr' result
and return instead of crashing with a SEGV.  This causes pjproject
to simply cancel the transaction with a "No answer record in the DNS
response" error.  The existing "off nominal" unit test was also
updated to check this condition.

Although not necessary for this fix, we also made
ast_dns_resolver_completed() tolerant of a NULL result.

Resolves: GHSA-v428-g3cw-7hv9
2024-09-05 16:32:23 +00:00
George Joseph
d6157aff5b app_voicemail: Use ast_asprintf to create mailbox SQL query
...instead of trying to calculate the length of the buffer needed
manually.
2024-09-04 15:59:56 +00:00
Mike Bradeen
ac673dd14e res_pjsip_sdp_rtp: Use negotiated DTMF Payload types on bitrate mismatch
When Asterisk sends an offer to Bob that includes 48K and 8K codecs with
matching 4733 offers, Bob may want to use the 48K audio codec but can not
accept 48K digits and so negotiates for a mixed set.

Asterisk will now check Bob's offer to make sure Bob has indicated this is
acceptible and if not, will use Bob's preference.

Fixes: #847
2024-09-03 15:29:35 +00:00
Tinet-mucw
e98127d540 app_chanspy.c: resolving the issue with audiohook direction read
ChanSpy(${channel}, qEoS): When chanspy spy the direction read, reading frame is often failed when reading direction read audiohook. because chanspy only read audiohook direction read; write_factory_ms will greater than 100ms soon, then ast_slinfactory_flush will being called, then direction read will fail.

Resolves: #861
2024-09-03 14:16:13 +00:00
George Joseph
ca60f7db8f security_agreements.c: Refactor the to_str functions and fix a few other bugs
* A static array of security mechanism type names was created.

* ast_sip_str_to_security_mechanism_type() was refactored to do
  a lookup in the new array instead of using fixed "if/else if"
  statments.

* security_mechanism_to_str() and ast_sip_security_mechanisms_to_str()
  were refactored to use ast_str instead of a fixed length buffer
  to store the result.

* ast_sip_security_mechanism_type_to_str was removed in favor of
  just referencing the new type name array.  Despite starting with
  "ast_sip_", it was a static function so removing it doesn't affect
  ABI.

* Speaking of "ast_sip_", several other static functions that
  started with "ast_sip_" were renamed to avoid confusion about
  their public availability.

* A few VECTOR free loops were replaced with AST_VECTOR_RESET().

* Fixed a meomry leak in pjsip_configuration.c endpoint_destructor
  caused by not calling ast_sip_security_mechanisms_vector_destroy().

* Fixed a memory leak in res_pjsip_outbound_registration.c
  add_security_headers() caused by not specifying OBJ_NODATA in
  an ao2_callback.

* Fixed a few ao2_callback return code misuses.

Resolves: #845
2024-09-03 14:06:08 +00:00
Alexei Gradinari
95fadcf6db res_pjsip_sdp_rtp fix leaking astobj2 ast_format
PR #700 added a preferred_format for the struct ast_rtp_codecs,
but when set the preferred_format it leaks an astobj2 ast_format.
In the next code
ast_rtp_codecs_set_preferred_format(&codecs, ast_format_cap_get_format(joint, 0));
both functions ast_rtp_codecs_set_preferred_format
and ast_format_cap_get_format increases the ao2 reference count.

Fixes: #856
2024-09-03 14:03:08 +00:00
George Joseph
7b0478f17f stir_shaken.conf.sample: Fix bad references to private_key_path
They should be private_key_file.

Resolves: #854
2024-08-26 13:09:10 +00:00
Sean Bright
ab9c476dd2 res_pjsip_logger.c: Fix 'OPTIONS' tab completion.
Fixes #843
2024-08-20 13:35:07 +00:00
Sean Bright
c5fbf5dcae alembic: Make 'revises' header comment match reality. 2024-08-20 13:02:14 +00:00
Cade Parker
4f5bb1e650 chan_mobile: decrease CHANNEL_FRAME_SIZE to prevent delay
On modern Bluetooth devices or lower-powered asterisk servers, decreasing the channel frame size significantly improves latency and delay on outbound calls with only a mild sacrifice to the quality of the call (the frame size before was massive overkill to begin with)
2024-08-12 21:21:27 +00:00
Mike Bradeen
e7ca7aa881 res_pjsip_notify: add dialplan application
Add dialplan application PJSIPNOTIFY to send either pre-configured
NOTIFY messages from pjsip_notify.conf or with headers defined in
dialplan.

Also adds the ability to send pre-configured NOTIFY commands to a
channel via the CLI.

Resolves: #799

UserNote: A new dialplan application PJSIPNotify is now available
which can send SIP NOTIFY requests from the dialplan.

The pjsip send notify CLI command has also been enhanced to allow
sending NOTIFY messages to a specific channel. Syntax:

pjsip send notify <option> channel <channel>
2024-08-12 21:20:30 +00:00
George Joseph
63004f2c02 manager.c: Fix FRACK when doing CoreShowChannelMap in DEVMODE
If you run an AMI CoreShowChannelMap on a channel that isn't in a
bridge and you're in DEVMODE, you can get a FRACK because the
bridge id is empty.  We now simply return an empty list for that
request.
2024-08-12 18:26:03 +00:00
Ben Ford
3841fa814e channel: Add multi-tenant identifier.
This patch introduces a new identifier for channels: tenantid. It's
a stringfield on the channel that can be used for general purposes. It
will be inherited by other channels the same way that linkedid is.

You can set tenantid in a few ways. The first is to set it in the
dialplan with the Set and CHANNEL functions:

exten => example,1,Set(CHANNEL(tenantid)=My tenant ID)

It can also be accessed via CHANNEL:

exten => example,2,NoOp(CHANNEL(tenantid))

Another method is to use the new tenantid option for pjsip endpoints in
pjsip.conf:

[my_endpoint]
type=endpoint
tenantid=My tenant ID

This is considered the best approach since you will be able to see the
tenant ID as early as the Newchannel event.

It can also be set using set_var in pjsip.conf on the endpoint like
setting other channel variable:

set_var=CHANNEL(tenantid)=My tenant ID

Note that set_var will not show tenant ID on the Newchannel event,
however.

Tenant ID has also been added to CDR. It's read-only and can be accessed
via CDR(tenantid). You can also get the tenant ID of the last channel
communicated with via CDR(peertenantid).

Tenant ID will also show up in CEL records if it has been set, and the
version number has been bumped accordingly.

Fixes: #740

UserNote: tenantid has been added to channels. It can be read in
dialplan via CHANNEL(tenantid), and it can be set using
Set(CHANNEL(tenantid)=My tenant ID). In pjsip.conf, it is recommended to
use the new tenantid option for pjsip endpoints (e.g., tenantid=My
tenant ID) so that it will show up in Newchannel events. You can set it
like any other channel variable using set_var in pjsip.conf as well, but
note that this will NOT show up in Newchannel events. Tenant ID is also
available in CDR and can be accessed with CDR(tenantid). The peer tenant
ID can also be accessed with CDR(peertenantid). CEL includes tenant ID
as well if it has been set.

UpgradeNote: A new versioned struct (ast_channel_initializers) has been
added that gets passed to __ast_channel_alloc_ap. The new function
ast_channel_alloc_with_initializers should be used when creating
channels that require the use of this struct. Currently the only value
in the struct is for tenantid, but now more fields can be added to the
struct as necessary rather than the __ast_channel_alloc_ap function. A
new option (tenantid) has been added to endpoints in pjsip.conf as well.
CEL has had its version bumped to include tenant ID.
2024-08-12 15:21:33 +00:00
Jaco Kroon
b45c04a7c4 configure: Use . file rather than source file.
source is a bash concept, so when /bin/sh points to another shell the
existing construct won't work.

Reference: https://bugs.gentoo.org/927055
Signed-off-by: Jaco Kroon <jaco@uls.co.za>
2024-08-08 14:19:27 +00:00
George Joseph
c10601c7ce manager.c: Add entries to Originate blacklist
Added Reload and DBdeltree to the list of dialplan application that
can't be executed via the Originate manager action without also
having write SYSTEM permissions.

Added CURL, DB*, FILE, ODBC and REALTIME* to the list of dialplan
functions that can't be executed via the Originate manager action
without also having write SYSTEM permissions.

If the Queue application is attempted to be run by the Originate
manager action and an AGI parameter is specified in the app data,
it'll be rejected unless the manager user has either the AGI or
SYSTEM permissions.

Resolves: #GHSA-c4cg-9275-6w44
2024-08-08 12:57:19 +00:00
Mike Bradeen
bdee743cd4 res_stasis: fix intermittent delays on adding channel to bridge
Previously, on command execution, the control thread was awoken by
sending a SIGURG. It was found that this still resulted in some
instances where the thread was not immediately awoken.

This change instead sends a null frame to awaken the control thread,
which awakens the thread more consistently.

Resolves: #801
2024-08-06 18:04:43 +00:00
Tinet-mucw
6cf6856080 res_pjsip_sdp_rtp.c: Fix DTMF Handling in Re-INVITE with dtmf_mode set to auto
When the endpoint dtmf_mode is set to auto, a SIP request is sent to the UAC, and the SIP SDP from the UAC does not include the telephone-event. Later, the UAC sends an INVITE, and the SIP SDP includes the telephone-event. In this case, DTMF should be sent by RFC2833 rather than using inband signaling.

Resolves: asterisk#826
2024-08-06 18:02:26 +00:00
George Joseph
d189b5a4d7 .github: Allow testing an Asterisk PR against a testsuite PR 2024-07-26 13:00:08 -06:00
George Joseph
cf09da519e .github: Add params to Releaser for FPBX issue creation 2024-07-26 07:30:42 -06:00
George Joseph
b10ea03792 rtp_engine.c: Prevent segfault in ast_rtp_codecs_payloads_unset()
There can be empty slots in payload_mapping_tx corresponding to
dynamic payload types that haven't been seen before so we now
check for NULL before attempting to use 'type' in the call to
ast_format_cmp.

Note: Currently only chan_sip calls ast_rtp_codecs_payloads_unset()

Resolves: #822
2024-07-25 14:14:09 +00:00
George Joseph
2fb3215f03 stir_shaken: CRL fixes and a new CLI command
* Fixed a bug in crypto_show_cli_store that was causing asterisk
to crash if there were certificate revocation lists in the
verification certificate store.  We're also now prefixing
certificates with "Cert:" and CRLs with "CRL:" to distinguish them
in the list.

* Added 'untrusted_cert_file' and 'untrusted_cert_path' options
to both verification and profile objects.  If you have CRLs that
are signed by a different CA than the incoming X5U certificate
(indirect CRL), you'll need to provide the certificate of the
CRL signer here.  Thse will show up as 'Untrusted" when showing
the verification or profile objects.

* Fixed loading of crl_path.  The OpenSSL API we were using to
load CRLs won't actually load them from a directory, only a file.
We now scan the directory ourselves and load the files one-by-one.

* Fixed the verification flags being set on the certificate store.
  - Removed the CRL_CHECK_ALL flag as this was causing all certificates
    to be checked for CRL extensions and failing to verify the cert if
    there was none.  This basically caused all certs to fail when a CRL
    was provided via crl_file or crl_path.
  - Added the EXTENDED_CRL_SUPPORT flag as it is required to handle
    indirect CRLs.

* Added a new CLI command...
`stir_shaken verify certificate_file <certificate_file> [ <profile> ]`
which will assist troubleshooting certificate problems by allowing
the user to manually verify a certificate file against either the
global verification certificate store or the store for a specific
profile.

* Updated the XML documentation and the sample config file.

Resolves: #809
2024-07-24 22:01:29 +00:00
George Joseph
d11dc5247b res_pjsip_config_wizard.c: Refactor load process
The way we have been initializing the config wizard prevented it
from registering its objects if res_pjsip happened to load
before it.

* We now use the object_type_registered sorcery observer to kick
things off instead of the wizard_mapped observer.

* The load_module function now checks if res_pjsip has been loaded
already and if it was it fires the proper observers so the objects
load correctly.

Resolves: #816

UserNote: The res_pjsip_config_wizard.so module can now be reloaded.
2024-07-24 19:21:06 +00:00
George Joseph
ef10fb4e6e voicemail.conf.sample: Fix ':' comment typo
...and removed an errant trailing space.

Resolves: #819
2024-07-24 18:02:05 +00:00
George Joseph
1272c28a0d bridge_softmix: Fix queueing VIDUPDATE control frames
softmix_bridge_write_control() now calls ast_bridge_queue_everyone_else()
with the bridge_channel so the VIDUPDATE control frame isn't echoed back.

softmix_bridge_write_control() was setting bridge_channel to NULL
when calling ast_bridge_queue_everyone_else() for VIDUPDATE control
frames.  This was causing the frame to be echoed back to the
channel it came from.  In certain cases, like when two channels or
bridges are being recorded, this can cause a ping-pong effect that
floods the system with VIDUPDATE control frames.

Resolves: #780
2024-07-19 16:47:02 +00:00