Commit Graph

33878 Commits

Author SHA1 Message Date
George Joseph
740cdd7ebd 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.
(cherry picked from commit 5c437c5724)
2024-08-08 13:26:34 +00:00
George Joseph
05847ee437 voicemail.conf.sample: Fix ':' comment typo
...and removed an errant trailing space.

Resolves: #819
(cherry picked from commit 0bf5e29c73)
2024-08-08 13:26:34 +00:00
George Joseph
259ba3f66d 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
(cherry picked from commit 72d09fb4f3)
2024-08-08 13:26:34 +00:00
George Joseph
42a2f4ccfa 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 07:11:15 -06:00
Asterisk Development Team
d8a0290d4a Update for certified-20.7-cert1 certified-20.7-cert1 2024-07-18 14:53:18 +00:00
George Joseph
4887f60e96 .github: Pass app_id and app_priv_key to AsteriskMergePR
(cherry picked from commit 8b5dafe39c)
2024-07-18 14:52:51 +00:00
George Joseph
de10a8fae1 .github: Change OnPRMergeApproved to use default token
(cherry picked from commit e28c7bc4b4)
2024-07-18 14:52:51 +00:00
Sean Bright
0c92241e86 logger.h: Include SCOPE_CALL_WITH_INT_RESULT() in non-dev-mode builds.
Fixes #785

(cherry picked from commit 2726265a4a)
2024-07-18 14:52:51 +00:00
George Joseph
b3283912d2 app_voicemail_odbc: Allow audio to be kept on disk
This commit adds a new voicemail.conf option 'odbc_audio_on_disk'
which when set causes the ODBC variant of app_voicemail to leave
the message and greeting audio files on disk and only store the
message metadata in the database.  This option came from a concern
that the database could grow to large and cause remote access
and/or replication to become slow.  In a clustering situation
with this option, all asterisk instances would share the same
database for the metadata and either use a shared filesystem
or other filesystem replication service much more suitable
for synchronizing files.

The changes to app_voicemail to implement this feature were actually
quite small but due to the complexity of the module, the actual
source code changes were greater.  They fall into the following
categories:

* Tracing.  The module is so complex that it was impossible to
figure out the path taken for various scenarios without the addition
of many SCOPE_ENTER, SCOPE_EXIT and ast_trace statements, even in
code that's not related to the functional change.  Making this worse
was the fact that many "if" statements in this module didn't use
braces.  Since the tracing macros add multiple statements, many "if"
statements had to be converted to use braces.

* Excessive use of PATH_MAX.  Previous maintainers of this module
used PATH_MAX to allocate character arrays for filesystem paths
and SQL statements as though they cost nothing.  In fact, PATH_MAX
is defined as 4096 bytes!  Some functions had (and still have)
multiples of these.  One function has 7.  Given that the vast
majority of installations use the default spool directory path
`/var/spool/asterisk/voicemail`, the actual path length is usually
less than 80 bytes.  That's over 4000 bytes wasted.  It was the
same for SQL statement buffers.  A 4K buffer for statement that
only needed 60 bytes.  All of these PATH_MAX allocations in the
ODBC related code were changed to dynamically allocated buffers.
The rest will have to be addressed separately.

* Bug fixes.  During the development of this feature, several
pre-existing ODBC related bugs were discovered and fixed.  They
had to do with leaving orphaned files on disk, not preserving
original message ids when moving messages between folders,
not honoring the "formats" config parameter in certain circumstances,
etc.

UserNote: This commit adds a new voicemail.conf option
'odbc_audio_on_disk' which when set causes the ODBC variant of
app_voicemail_odbc to leave the message and greeting audio files
on disk and only store the message metadata in the database.
Much more information can be found in the voicemail.conf.sample
file.

(cherry picked from commit 59ed64627c)
2024-07-18 14:52:51 +00:00
George Joseph
ad965dc835 security_agreement.c: Always add the Require and Proxy-Require headers
The `Require: mediasec` and `Proxy-Require: mediasec` headers need
to be sent whenever we send `Security-Client` or `Security-Verify`
headers but the logic to do that was only in add_security_headers()
in res_pjsip_outbound_register.  So while we were sending them on
REGISTER requests, we weren't sending them on INVITE requests.

This commit moves the logic to send the two headers out of
res_pjsip_outbound_register:add_security_headers() and into
security_agreement:ast_sip_add_security_headers().  This way
they're always sent when we send `Security-Client` or
`Security-Verify`.

Resolves: #789
(cherry picked from commit 35528195b2)
2024-07-18 14:52:51 +00:00
George Joseph
05d82da614 .github: Use ASTERISKTEAM_PAT for PR merging
(cherry picked from commit 51edc5062d)
2024-07-18 14:52:51 +00:00
George Joseph
208f055e5f stasis_channels: Use uniqueid and name to delete old snapshots
Whenver a new channel snapshot is created or when a channel is
destroyed, we need to delete any existing channel snapshot from
the snapshot cache.  Historically, we used the channel->snapshot
pointer to delete any existing snapshots but this has two issues.

First, if something (possibly ast_channel_internal_swap_snapshots)
sets channel->snapshot to NULL while there's still a snapshot in
the cache, we wouldn't be able to delete it and it would be orphaned
when the channel is destroyed.  Since we use the cache to list
channels from the CLI, AMI and ARI, it would appear as though the
channel was still there when it wasn't.

Second, since there are actually two caches, one indexed by the
channel's uniqueid, and another indexed by the channel's name,
deleting from the caches by pointer requires a sequential search of
all of the hash table buckets in BOTH caches to find the matching
snapshots.  Not very efficient.

So, we now delete from the caches using the channel's uniqueid
and name.  This solves both issues.

This doesn't address how channel->snapshot might have been set
to NULL in the first place because although we have concrete
evidence that it's happening, we haven't been able to reproduce it.

Resolves: #783
(cherry picked from commit bb4d470a2d)
2024-07-18 14:52:51 +00:00
George Joseph
16ac05eb4d .github: Replace PR workflows with stubs that call reusables
The PR workflows now are just stubs that call reusable
workflows located in the asterisk-ci-actions repo.

(cherry picked from commit e5a81346b0)
2024-07-18 14:52:51 +00:00
George Joseph
0bafe17648 .github: Refactor NightlyTests to use workflow in asterisk-ci-actions
(cherry picked from commit bafd37ed3e)
2024-07-18 14:52:51 +00:00
George Joseph
277a06d450 .github: Add PAT to PRSubmitActions/Add Reviewers
(cherry picked from commit 8ebd2bedd5)
2024-07-18 14:52:51 +00:00
Sean Bright
bf61eab334 xml.c: Update deprecated libxml2 API usage.
Two functions are deprecated as of libxml2 2.12:

  * xmlSubstituteEntitiesDefault
  * xmlParseMemory

So we update those with supported API.

Additionally, `res_calendar_caldav` has been updated to use libxml2's
xmlreader API instead of the SAX2 API which has always felt a little
hacky (see deleted comment block in `res_calendar_caldav.c`).

The xmlreader API has been around since libxml2 2.5.0 which was
released in 2003.

Fixes #725

(cherry picked from commit b46f447530)
2024-07-18 14:52:51 +00:00
George Joseph
cc5a7e1c19 .github: Add branches to workflow_dispatch for NightlyTests
(cherry picked from commit e65073d4df)
2024-07-18 14:52:51 +00:00
Asterisk Development Team
b020a073bc Update for certified-20.7-cert1-rc2 certified-20.7-cert1-rc2 2024-05-14 15:35:19 +00:00
George Joseph
790f2860ef stir_shaken: Fix memory leak, typo in config, tn canonicalization
* Fixed possible memory leak in tn_config:tn_get_etn() where we
weren't releasing etn if tn or eprofile were null.
* We now canonicalize TNs before using them for lookups or adding
them to Identity headers.
* Fixed a typo in stir_shaken.conf.sample.

Resolves: #716
(cherry picked from commit 200da52128)
2024-05-14 15:35:16 +00:00
Spiridonov Dmitry
801b0ca253 sorcery.c: Fixed crash error when executing "module reload"
Fixed crash error when cli "module reload". The error appears when
compiling with res_prometheus and using the sorcery memory cache for
registrations

(cherry picked from commit 7210a03816)
2024-05-14 15:35:16 +00:00
George Joseph
66d2ab529b logger.h: Add SCOPE_CALL and SCOPE_CALL_WITH_RESULT
If you're tracing a large function that may call another function
multiple times in different circumstances, it can be difficult to
see from the trace output exactly which location that function
was called from.  There's no good way to automatically determine
the calling location.  SCOPE_CALL and SCOPE_CALL_WITH_RESULT
simply print out a trace line before and after the call.

The difference between SCOPE_CALL and SCOPE_CALL_WITH_RESULT is
that SCOPE_CALL ignores the function's return value (if any) where
SCOPE_CALL_WITH_RESULT allows you to specify the type of the
function's return value so it can be assigned to a variable.
SCOPE_CALL_WITH_INT_RESULT is just a wrapper for SCOPE_CALL_WITH_RESULT
and the "int" return type.

(cherry picked from commit 951be188ba)
2024-05-14 15:35:16 +00:00
George Joseph
57b93ba7a3 res_stir_shaken: Fix compilation for CentOS7 (openssl 1.0.2)
* OpenSSL 1.0.2 doesn't support X509_get0_pubkey so we now use
  X509_get_pubkey.  The difference is that X509_get_pubkey requires
  the caller to free the EVP_PKEY themselves so we now let
  RAII_VAR do that.
* OpenSSL 1.0.2 doesn't support upreffing an X509_STORE so we now
  wrap it in an ao2 object.
* OpenSSL 1.0.2 doesn't support X509_STORE_get0_objects to get all
  the certs from an X509_STORE and there's no easy way to polyfill
  it so the CLI commands that list profiles will show a "not
  supported" message instead of listing the certs in a store.

Resolves: #676
(cherry picked from commit 7bbc7b5a3a)
2024-05-14 15:35:16 +00:00
Martin Nystroem
b496feae38 res_ari.c: Add additional output to ARI requests when debug is enabled
When ARI debug is enabled the logs will now output http method and the uri.

Fixes: #666
(cherry picked from commit 29106567e7)
2024-05-14 15:35:16 +00:00
Sean Bright
a2276abdc5 alembic: Fix compatibility with SQLAlchemy 2.0+.
SQLAlchemy 2.0 changed the way that commits/rollbacks are handled
causing the final `UPDATE` to our `alembic_version_<whatever>` tables
to be rolled back instead of committed.

We now use one connection to determine which
`alembic_version_<whatever>` table to use and another to run the
actual migrations. This prevents the erroneous rollback.

This change is compatible with both SQLAlchemy 1.4 and 2.0.

(cherry picked from commit 42fbf5c22f)
2024-05-14 15:35:16 +00:00
Naveen Albert
1cfe5e02a4 pbx_variables.c: Prevent SEGV due to stack overflow.
It is possible for dialplan to result in an infinite
recursion of variable substitution, which eventually
leads to stack overflow. If we detect this, abort
substitution and log an error for the user to fix
the broken dialplan.

Resolves: #480

UpgradeNote: The maximum amount of dialplan recursion
using variable substitution (such as by using EVAL_EXTEN)
is capped at 15.

(cherry picked from commit f9f36ca702)
2024-05-14 15:35:16 +00:00
Sean Bright
4ecf3ea66a res_pjsip: Fix alembic downgrade for boolean columns.
When downgrading, ensure that we don't touch columns that didn't
actually change during upgrade.

(cherry picked from commit e1f7778b4c)
2024-05-14 15:35:16 +00:00
Sean Bright
ce4cdffe51 alembic: Quote new MySQL keyword 'qualify.'
Fixes #651

(cherry picked from commit 1b45f481f0)
2024-05-14 15:35:16 +00:00
Ivan Poddubny
f5107404c5 asterisk.c: Fix sending incorrect messages to systemd notify
Send "RELOADING=1" instead of "RELOAD=1" to follow the format
expected by systemd (see sd_notify(3) man page).

Do not send STOPPING=1 in remote console mode:
attempting to execute "asterisk -rx" by the main process leads to
a warning if NotifyAccess=main (the default) or to a forced termination
if NotifyAccess=all.

(cherry picked from commit d7e638f2c3)
2024-05-14 15:35:16 +00:00
George Joseph
60c3f0273c tcptls/iostream: Add support for setting SNI on client TLS connections
If the hostname field of the ast_tcptls_session_args structure is
set (which it is for websocket client connections), that hostname
will now automatically be used in an SNI TLS extension in the client
hello.

Resolves: #713

UserNote: Secure websocket client connections now send SNI in
the TLS client hello.

(cherry picked from commit 5b9da1213c)
2024-05-14 15:35:16 +00:00
George Joseph
fabed0f5e1 make_buildopts_h: Always include DETECT_DEADLOCKS
Since DETECT_DEADLOCKS is now split from DEBUG_THREADS, it must
always be included in buildopts.h instead of only when
ADD_CFLAGS_TO_BUILDOPTS_H is defined.  A SEGV will result otherwise.

Resolves: #719
(cherry picked from commit 7d69eafb5c)
2024-05-14 15:35:16 +00:00
Sean Bright
6a629bee13 alembic: Correct NULLability of PJSIP id columns.
Fixes #695

(cherry picked from commit a3a0139b93)
2024-05-14 15:35:16 +00:00
George Joseph
c10eb8a93a rtp_engine and stun: call ast_register_atexit instead of ast_register_cleanup
rtp_engine.c and stun.c were calling ast_register_cleanup which
is skipped if any loadable module can't be cleanly unloaded
when asterisk shuts down.  Since this will always be the case,
their cleanup functions never get run.  In a practical sense
this makes no difference since asterisk is shutting down but if
you're in development mode and trying to use the leak sanitizer,
the leaks from both of those modules clutter up the output.

(cherry picked from commit 3767e14d15)
2024-05-14 15:35:16 +00:00
George Joseph
4f2c1e4336 manager.c: Add missing parameters to Login documentation
* Added the AuthType and Key parameters for MD5 authentication.

* Added the Events parameter.

Resolves: #689
(cherry picked from commit d47641cbcf)
2024-05-14 15:35:16 +00:00
George Joseph
0b6ad07bca Fix incorrect application and function documentation references
There were a few references in the embedded documentation XML
where the case didn't match or where the referenced app or function
simply didn't exist any more.  These were causing 404 responses
in docs.asterisk.org.

(cherry picked from commit be6dee18dc)
2024-05-14 15:35:16 +00:00
Asterisk Development Team
d9d47b5535 Update for certified-20.7-cert1-rc1 certified-20.7-cert1-rc1 2024-03-18 18:14:07 +00:00
George Joseph
315d296b97 Initial commit for certified-20.7
(cherry picked from commit f631eda4fd)
2024-03-18 18:14:03 +00:00
Asterisk Development Team
af5acc405d Update for 20.7.0 20.7.0 certified-20.7-cert1-pre1 2024-03-18 13:21:48 +00:00
Asterisk Development Team
9b6c74e82a Update for 20.7.0-rc2 20.7.0-rc2 2024-03-11 17:17:22 +00:00
George Joseph
d7597e5148 res_pjsip_stir_shaken.c: Add checks for missing parameters
* Added checks for missing session, session->channel and rdata
  in stir_shaken_incoming_request.

* Added checks for missing session, session->channel and tdata
  in stir_shaken_outgoing_request.

Resolves: #645
2024-03-11 11:07:00 -06:00
Asterisk Development Team
959babc472 Update for 20.7.0-rc1 20.7.0-rc1 2024-03-07 14:17:30 +00:00
Naveen Albert
40fd161575 app_dial: Add dial time for progress/ringing.
Add a timeout option to control the amount of time
to wait if no early media is received before giving
up. This allows aborting early if the destination
is not being responsive.

Resolves: #588

UserNote: The timeout argument to Dial now allows
specifying the maximum amount of time to dial if
early media is not received.

(cherry picked from commit e4adc962ca)
2024-03-07 14:17:23 +00:00
Naveen Albert
5ade71ec9a app_voicemail: Properly reinitialize config after unit tests.
Most app_voicemail unit tests were not properly cleaning up
after themselves after running. This led to test mailboxes
lingering around in the system. It also meant that if any
unit tests in app_voicemail that create mailboxes were executed
and the module was not unloaded/loaded again prior to running
the test_voicemail_vm_info unit test, Asterisk would segfault
due to an attempt to copy a NULL string.

The load_config test did actually have logic to reinitialize
the config after the test. However, this did not work in practice
since load_config() would not reload the config since voicemail.conf
had not changed during the test; thus, additional logic has been
added to ensure that voicemail.conf is truly reloaded, after any
unit tests which modify the users list.

This prevents the SEGV due to invalid mailboxes lingering around,
and also ensures that the system state is restored to what it was
prior to the tests running.

Resolves: #629
(cherry picked from commit 082966bdad)
2024-03-07 14:17:23 +00:00
Shaaah
395bcab787 app_queue.c : fix "queue add member" usage string
Fixing bracket placement in the "queue add member" cli usage string.

(cherry picked from commit c6ff7a6a51)
2024-03-07 14:17:23 +00:00
Naveen Albert
3469e515de app_voicemail: Allow preventing mark messages as urgent.
This adds an option to allow preventing callers from leaving
messages marked as 'urgent'.

Resolves: #619

UserNote: The leaveurgent mailbox option can now be used to
control whether callers may leave messages marked as 'Urgent'.

(cherry picked from commit 3c42b141d7)
2024-03-07 14:17:23 +00:00
Sean Bright
f8da5a2ba3 res_pjsip: Use consistent type for boolean columns.
This migrates the relevant schema objects from the `('yes', 'no')`
definition to the `('0', '1', 'off', 'on', 'false', 'true', 'yes', 'no')`
one.

Fixes #617

(cherry picked from commit 93e40968c3)
2024-03-07 14:17:23 +00:00
George Joseph
f02ac33364 .github: Remove timeout-minutes from gatetests
(cherry picked from commit 9f182e9f58)
2024-03-07 14:17:23 +00:00
George Joseph
44563b5043 attestation_config.c: Use ast_free instead of ast_std_free
In as_check_common_config, we were calling ast_std_free on
raw_key but raw_key was allocated with ast_malloc so it
should be freed with ast_free.

Resolves: #636
(cherry picked from commit 267348bee3)
2024-03-07 14:17:23 +00:00
George Joseph
efc2124594 Makefile: Add stir_shaken/cache to directories created on install
The default location for the stir_shaken cache is
/var/lib/asterisk/keys/stir_shaken/cache but we were only creating
/var/lib/asterisk/keys/stir_shaken on istall.  We now create
the cache sub-directory.

Resolves: #634
(cherry picked from commit df0221b53d)
2024-03-07 14:17:23 +00:00
George Joseph
be5fd6180c .github: Pass only single GATETEST_COMMAND to AsteriskGateComposite
(cherry picked from commit eed8288d0c)
2024-03-07 14:17:23 +00:00
George Joseph
fd27df9479 Stir/Shaken Refactor
Why do we need a refactor?

The original stir/shaken implementation was started over 3 years ago
when little was understood about practical implementation.  The
result was an implementation that wouldn't actually interoperate
with any other stir-shaken implementations.

There were also a number of stir-shaken features and RFC
requirements that were never implemented such as TNAuthList
certificate validation, sending Reason headers in SIP responses
when verification failed but we wished to continue the call, and
the ability to send Media Key(mky) grants in the Identity header
when the call involved DTLS.

Finally, there were some performance concerns around outgoing
calls and selection of the correct certificate and private key.
The configuration was keyed by an arbitrary name which meant that
for every outgoing call, we had to scan the entire list of
configured TNs to find the correct cert to use.  With only a few
TNs configured, this wasn't an issue but if you have a thousand,
it could be.

What's changed?

* Configuration objects have been refactored to be clearer about
  their uses and to fix issues.
    * The "general" object was renamed to "verification" since it
      contains parameters specific to the incoming verification
      process.  It also never handled ca_path and crl_path
      correctly.
    * A new "attestation" object was added that controls the
      outgoing attestation process.  It sets default certificates,
      keys, etc.
    * The "certificate" object was renamed to "tn" and had it's key
      change to telephone number since outgoing call attestation
      needs to look up certificates by telephone number.
    * The "profile" object had more parameters added to it that can
      override default parameters specified in the "attestation"
      and "verification" objects.
    * The "store" object was removed altogther as it was never
      implemented.

* We now use libjwt to create outgoing Identity headers and to
  parse and validate signatures on incoming Identiy headers.  Our
  previous custom implementation was much of the source of the
  interoperability issues.

* General code cleanup and refactor.
    * Moved things to better places.
    * Separated some of the complex functions to smaller ones.
    * Using context objects rather than passing tons of parameters
      in function calls.
    * Removed some complexity and unneeded encapsuation from the
      config objects.

Resolves: #351
Resolves: #46

UserNote: Asterisk's stir-shaken feature has been refactored to
correct interoperability, RFC compliance, and performance issues.
See https://docs.asterisk.org/Deployment/STIR-SHAKEN for more
information.

UpgradeNote: The stir-shaken refactor is a breaking change but since
it's not working now we don't think it matters. The
stir_shaken.conf file has changed significantly which means that
existing ones WILL need to be changed.  The stir_shaken.conf.sample
file in configs/samples/ has quite a bit more information.  This is
also an ABI breaking change since some of the existing objects
needed to be changed or removed, and new ones added.  Additionally,
if res_stir_shaken is enabled in menuselect, you'll need to either
have the development package for libjwt v1.15.3 installed or use
the --with-libjwt-bundled option with ./configure.

(cherry picked from commit e6c7f1aee0)
2024-03-07 14:17:23 +00:00