summaryrefslogtreecommitdiff
path: root/main
AgeCommit message (Collapse)Author
2017-03-22Merge "autochan/mixmonitor/chanspy: Fix unsafe channel locking and ↵Joshua Colp
references." into 14
2017-03-20thread safety: Don't use getprotobyname()Sean Bright
POSIX does not require getprotobyname() to be thread safe and some implementations use static memory which causes issues when multiple threads are used. Further, our usage of it today is just to ultimately get IPPROTO_TCP for calls to setsockopt(). So instead we just use IPPROTO_TCP directly. Change-Id: I2e14e58674808f7ce99b2f5e900d0f90d0d8da48
2017-03-15Merge "pbx.c: Fix crash from malformed exten pattern." into 14zuul
2017-03-15autochan/mixmonitor/chanspy: Fix unsafe channel locking and references.Richard Mudgett
Dereferencing struct ast_autochan.chan without first calling ast_autochan_channel_lock() is unsafe because the pointer could change at any time due to a masquerade. Unfortunately, ast_autochan_channel_lock() itself uses struct ast_autochan.chan unsafely and can result in a deadlock if the original channel happens to get destroyed after a masquerade in addition to the pointer getting changed. The problem is more likely to happen with v11 and earlier because masquerades are used to optimize out local channels on those versions. However, it could still happen on newer versions if the channel is executing a dialplan application when the channel is transferred or redirected. In this situation a masquerade still must be used. * Added a lock to struct ast_autochan to safely be able to use ast_autochan.chan while trying to get the channel lock in ast_autochan_channel_lock(). The locking order is the channel lock then the autochan lock. Locking in the other direction requires deadlock avoidance. * Fix unsafe ast_autochan.chan usages in app_mixmonitor.c. * Fix unsafe ast_autochan.chan usages in app_chanspy.c. * app_chanspy.c: Removed unused autochan parameter from next_channel(). ASTERISK-26867 Change-Id: Id29dd22bc0f369b44e23ca423d2f3657187cc592
2017-03-14pbx.c: Fix crash from malformed exten pattern.Richard Mudgett
Forgetting to indicate an exten is a pattern can cause a crash if the "pattern" has a character set range. e.g., "9999[3-5]" The crash is due to a buffer overwrite because the '-' exten eye-candy wasn't removed as expected and overran the allocated space. The buffer overwrite is fixed two ways in this patch. 1) Fix ext_strncpy() to distinguish between pattern and non-pattern extens. Now '-' characters are removed when they are eye-candy and not when they are part of a pattern character set. Since the function is private to pbx.c, the return value now returns the number of bytes written to the destination buffer instead of the strlen() of the final buffer so the callers that care don't need to add one. 2) Fix callers to ext_strncpy() to supply the correct available buffer size of the destination buffer. ASTERISK-26668 Change-Id: I555d97411140e47e0522684062d174fbe32aa84a
2017-03-14main/stasis_cache: Demote the ERROR message when removing a nonexistent itemMatt Jordan
This patch demotes the ERROR message that is displayed when a nonexistent item is removed from the Stasis cache. The genesis of this demotion is due to chan_sip's realtime peers and their interaction with Asterisk's core ast_endpoint code, but ostensibly it could happen from other channel drivers as well. Since Mark Michelson already did an excellent job of explaining on this issue, it is quoted here for posterity: "Internally, when a realtime peer is retrieved, Asterisk creates an ast_endpoint structure. When that peer is destroyed, the ast_endpoint is destroyed as well. Part of the destruction of the ast_endpoint involves clearing the Stasis cache of all information about that endpoint. The problem here is that the act of creating the ast_endpoint is not enough to actually put any information in the Stasis cache. Instead, something has to happen, such as a state change, in order for the Stasis cache to have any information about that endpoint. When a device registers, chan_sip creates an ast_endpoint structure, processes the REGISTER, and then destroys the ast_endpoint. When the ast_endpoint is destroyed, there is nothing to destroy in the Stasis cache, so an error message is emitted. When you use rtcachefriends, ast_endpoint structures persist for the lifetime of the module and so you do not see this error message." ASTERISK-25237 #close Change-Id: I53cebc6b4a897a1ab9564182b75c177780feff70
2017-03-08media_cache: Prefer ast_file_is_readable() over access()Sean Bright
Change-Id: Icc0dc6e61b2e68d5cdcb74b016b2726a388c7def
2017-03-06Saynumber is trying to get "and" from "digits/" subfolderDaniel Journo
* say.c Changed 'digits/and' to 'vm-and' for en_GB ASTERISK-26598 #close Change-Id: If1b713e5daea6f952b339f139178d292a6c4fcfe
2017-03-02core: Cleanup ast_get_hint() usage.Richard Mudgett
* manager.c:manager_state_cb() Fix potential use of uninitialized hint[] if a hint does not exist for the requested extension. Ran into this when developing a testsuite test. The AMI event ExtensionStatus came out with the hint header value containing garbage. The AMI event PresenceStatus also had the same issue. * manager.c:action_extensionstate() no need to completely initialize the hint[]. Only initialize the first element. * pbx.c:ast_add_hint() Remove unnecessary assignment. * chan_sip.c: Eliminate an unneeded hint[] local variable. We only care about the return value of ast_get_hint() there. Change-Id: Ia9a8786f01f93f1f917200f0a50bead0319af97b
2017-03-01Merge "media_cache: Mark cache entry stale if cache file is removed" into 14Joshua Colp
2017-02-28media_cache: Mark cache entry stale if cache file is removedSean Bright
In the event that a cache file is removed out from under us, we should treat the cache entry as stale and force a refresh. ASTERISK-26774 #close Reported by: Igor Gamayunov Change-Id: I3b1bd0c999d59d18664ef73a29823bc5b431dc52
2017-02-27build: Warn if asterisk is installed in both 32 and 64 bit sys dirsGeorge Joseph
... and clean them both up on uninstall. We've fixed the issue where 'make install' was installing to /usr/lib on 64-bit systems that use /usr/lib64. Now we need to clean up the remnants in /usr/lib. * 'make install' now prints a warning if DESTDIR/ASTLIBDIR contains 'lib64' and libasterisk* shared libraries or modules are also found in DESTDIR/ASTLIBDIR with 'lib64' transformed to 'lib'. * 'make uninstall' ALWAYS cleans up both DESTDIR/ASTLIBDIR and DESTDIR/ASTLIBDIR with 'lib64' transformed to 'lib'. ASTERISK-26705 Change-Id: I6edddeb3c07a51e7c7ba7cac3c05e4bf3ec3f01f
2017-02-23build: Execute ldconfig to build cache. (take two)George Joseph
On some platforms a multiarch approach is used for libraries. The build system does not take this into account and still places libraries into the lib directory if no --libdir is specified to configure. On initial startup this results in libasteriskssl.so not being found, as it is not in the multiarch lib directory. To make matters worse, options were being passed to ldconfig on both Linux and FreeBSD that actually prevented the rebuild of the cache. * Fedora has a /usr/share/config.site that automatically tells autoconf to use /usr/lib64 but CentOS does not. This logic was copied to configure.ac and modified so systems like Ubuntu, which still use /usr/lib for 64-bit systems, aren't affected. Now that we have them in the correct directory... In order for the system loader to find libasteriskssl and libasteriskpj, one of 3 things has to happen... - The linker cache must be rebuilt including the directory where the libasterisk* libraries were installed. Only root can rebuild the cache. This was busted. - We have to link the asterisk binary with an rpath pointing to the directrory where the libasterisk* libraries were installed. This makes things very complicated and will happen over the collective dead bodies of everyone who's had to package a distribution with an rpath. - Finally, you can start asterisk with LD_LIBRARY_PATH set to the directrory where the libasterisk* libraries were installed. There are no other options. So... * The invokation of ldconfig has been moved from main/Makefile to ASTTOPDIR/Makefile, the options have been removed, and DESTDIR/ASTLIBDIR appended. If you aren't root, you will be warned after the "Asterisk Installation Compete" banner that you must re-run 'make install' as root, manually run 'ldconfig DESTDIR/ASTLIBDIR' as root, or run asterisk with LD_LIBRARY_PATH. ASTERISK-26705 Change-Id: I2a64b7c33a7d3e9bde20f47e3d3ab771977af982
2017-02-22Revert "build: Execute ldconfig to build cache."Joshua Colp
This reverts commit e852d5b848de9bb55dc3363013aa18ebd736ebb9. Change-Id: Ie1ffc470c656e8bfa14f890b58c8ecc187e50197
2017-02-21build: Execute ldconfig to build cache.Joshua Colp
On some platforms a multiarch approach is used for libraries. The build system does not take this into account and still places libraries into the lib directory if no --libdir is specified to configure. On initial startup this results in libasteriskssl.so not being found, as it is not in the multiarch lib directory. This change does the minimally invasive thing and executes ldconfig so that the libraries in the lib directory are found and their location cached. By doing so Asterisk starts up fine. If DESTDIR is specified, however, the old logic is executed as the install process may not have permission to alter the ldconfig cache. ASTERISK-26705 Change-Id: If4eca46ac510c6fea5568256280ffdb3888d7bb4
2017-02-20Merge "tcptls.c: Add some missing allocation failure checks." into 14zuul
2017-02-20Revert "build: Execute ldconfig to build cache."Joshua Colp
This reverts commit bba48a56620afd6c92760eba8a046513fbb227ab. Change-Id: I2df70dde1ffc1b5f195af9e923147cb898af217e
2017-02-17tcptls.c: Add some missing allocation failure checks.Richard Mudgett
Change-Id: I0ddf01cd3c10d3b6666d7bf68d4e206a37f4fbdb
2017-02-16build: Execute ldconfig to build cache.Joshua Colp
On some platforms a multiarch approach is used for libraries. The build system does not take this into account and still places libraries into the lib directory if no --libdir is specified to configure. On initial startup this results in libasteriskssl.so not being found, as it is not in the multiarch lib directory. This change does the minimally invasive thing and executes ldconfig so that the libraries in the lib directory are found and their location cached. By doing so Asterisk starts up fine. ASTERISK-26705 Change-Id: I6d30b6427e9d5e69470e11327c7ff203fa7da519
2017-02-16http: Ensure capath is defined on all http creationsJoshua Elson
ASTERISK-26794 #close Change-Id: I9cbc3b6b6a8aab590f5ccde9c262a98e4d5253a1
2017-02-14libasteriskssl: do nothing with OpenSSL >= 1.1Tzafrir Cohen
OpenSSL 1.1 requires no explicit initialization. The hacks in the library are not needed. They also happen to fail running Asterisk. ASTERISK-26109 #close Change-Id: I3b3efd5d80234a4c45a8ee58dcfe25b15d9ad100
2017-02-14tcptls: use TLS_client_method with OpenSSL 1.1Tzafrir Cohen
OpenSSL 1.1 introduced TLS_client_method() and deprecated the previous version-specific methods (such as TLSv1_client_method(). Other than being simpler to use and more correct (gain support for TLS newer that TLS1, in our case), the older ones produce a deprecation warning that fails the build in dev-mode. ASTERISK-26109 #close Change-Id: I257b1c8afd09dcb0d96cda3a41cb9f7a15d0ba07
2017-02-14openssl 1.1 support: use OPENSSL_VERSION_NUMBERTzafrir Cohen
Use OPENSSL_VERSION_NUMBER instead of OPENSSL_API_COMPAT to detect the openssl 1.1 API. ASTERISK-26109 #close Change-Id: I4e448f55ef516aedf6ad154037c35577a421a458
2017-02-14Merge "cli: Fix various CLI documentation and completion issues" into 14zuul
2017-02-14Merge "channel: Protect flags in ast_waitfor_nandfds operation." into 14zuul
2017-02-13Merge "core: Cleanup some channel snapshot staging anomalies." into 14zuul
2017-02-13cli: Fix various CLI documentation and completion issuesSean Bright
* app_minivm: Use built-in completion facilities to complete optional arguments. * app_voicemail: Use built-in completion facilities to complete optional arguments. * app_confbridge: Add missing colons after 'Usage' text. * chan_alsa: Use built-in completion facilities to complete optional arguments. * chan_sip: Use built-in completion facilities to complete optional arguments. Add completions for 'load' for 'sip show user', 'sip show peer', and 'sip qualify peer.' * chan_skinny: Correct and extend completions for 'skinny reset' and 'skinny show line.' * func_odbc: Correct completions for 'odbc read' and 'odbc write' * main/astmm: Use built-in completion facilities to complete arguments for 'memory' commands. * main/bridge: Correct completions for 'bridge kick.' * main/ccss: Use built-in completion facilities to complete arguments for 'cc cancel' command. * main/cli: Add 'all' completion for 'channel request hangup.' Correct completions for 'core set debug channel.' Correct completions for 'core show calls.' * main/pbx_app: Remove redundant completions for 'core show applications.' * main/pbx_hangup_handler: Remove unused completions for 'core show hanguphandlers all.' * res_sorcery_memory_cache: Add completion for 'reload' argument of 'sorcery memory cache stale' and properly implement. Change-Id: Iee58c7392f6fec34ad9d596109117af87697bbca
2017-02-13channel: Protect flags in ast_waitfor_nandfds operation.Joshua Colp
The ast_waitfor_nandfds operation will manipulate the flags of channels passed in. This was previously done without the channel lock being held. This could result in incorrect values existing for the flags if another thread manipulated the flags at the same time. This change locks the channel during flag manipulation. ASTERISK-26788 Change-Id: I2c5c8edec17c9bdad4a93291576838cb552ca5ed
2017-02-10manager: Restore Originate failure behavior from Asterisk 11Sean Bright
In Asterisk 11, if the 'Originate' AMI command failed to connect the provided Channel while in extension mode, a 'failed' extension would be looked up and run. This was, I believe, unintentionally removed in 51b6c49. This patch restores that behavior. This also adds an enum for the various 'synchronous' modes in an attempt to make them meaningful. ASTERISK-26115 #close Reported by: Nasir Iqbal Change-Id: I8afbd06725e99610e02adb529137d4800c05345d
2017-02-10core: Cleanup some channel snapshot staging anomalies.Richard Mudgett
We shouldn't unlock the channel after starting a snapshot staging because another thread may interfere and do its own snapshot staging. * app_dial.c:dial_exec_full() made hold the channel lock while setting up the outgoing channel staging. Made hold the channel lock after the called party answers while updating the caller channel staging. * chan_sip.c:sip_new() completed the channel staging on off-nominal exit. Also we need to use ast_hangup() instead of ast_channel_unref() at that location. * channel.c:__ast_channel_alloc_ap() added a comment about not needing to complete the channel snapshot staging on off-nominal exit paths. * rtp_engine.c:ast_rtp_instance_set_stats_vars() made hold the channel locks while staging the channels for the stats channel variables. Change-Id: Iefb6336893163f6447bad65568722ad5d5d8212a
2017-02-07srv: Fix crash when ast_srv_lookup is used and 0 records are returned.Joshua Colp
When performing an SRV lookup using the ast_srv_lookup function it did not properly handle the situation where 0 records are returned. If this happened it would wrongly assume that at least one record was present. This change fixes the code so it will exit early if an error occurs or if 0 records are returned. ASTERISK-26772 patches: srv_lookup.patch submitted by nappsoft (license 6822) Change-Id: I09b19081c74e0ad11c12bf54a257243b1bcb2351
2017-02-03res_ari: fix memory leak for channelvarsSebastien Duthil
In ari.conf, when setting the option channelvars, every Stasis channel snapshot would create a list of variable/value that would not be freed when the snapshot is freed, resulting in a often-recurring memory leak. ASTERISK-26767 #close Change-Id: Ia37dd9d68063d7f879193df02ede293e5ded716d
2017-02-02channel.c: Fix unbalanced read queue deadlocking local channels.Richard Mudgett
Using the timerfd timing module can cause channel freezing, lingering, or deadlock issues. The problem is because this is the only timing module that uses an associated alert-pipe. When the alert-pipe becomes unbalanced with respect to the number of frames in the read queue bad things can happen. If the alert-pipe has fewer alerts queued than the read queue then nothing might wake up the thread to handle received frames from the channel driver. For local channels this is the only way to wake up the thread to handle received frames. Being unbalanced in the other direction is less of an issue as it will cause unnecessary reads into the channel driver. ASTERISK-26716 is an example of this deadlock which was indirectly fixed by the change that found the need for this patch. * In channel.c:__ast_queue_frame(): Adding frame lists to the read queue did not add the same number of alerts to the alert-pipe. Correspondingly, when there is an exceptionally long queue event, any removed frames did not also remove the corresponding number of alerts from the alert-pipe. ASTERISK-26632 #close Change-Id: Ia98137c5bf6e9d6d202ce0eb36441851875863f6
2017-02-02res_agi: Prevent an AGI from eating frames it should not. (Re-do)Richard Mudgett
A dialplan intercept routine is equivalent to an interrupt routine. As such, the routine must be done quickly and you do not have access to the media stream. These restrictions are necessary because the media stream is the responsibility of some other code and interfering with or delaying that processing is bad. A possible future dialplan processing architecture change may allow the interception routine to run in a different thread from the main thread handling the media and remove the execution time restriction. * Made res_agi.c:run_agi() running an AGI in an interception routine run in DeadAGI mode. No touchy channel frames. ASTERISK-25951 ASTERISK-26343 ASTERISK-26716 Change-Id: I638f147ca7a7f2590d7194a8ef4090eb191e4e43
2017-02-02Frame deferral: Revert API refactoring.Richard Mudgett
There are several issues with deferring frames that are caused by the refactoring. 1) The code deferring frames mishandles adding a deferred frame to the deferred queue. As a result the deferred queue can only be one frame long. 2) Deferrable frames can come directly from the channel driver as well as the read queue. These frames need to be added to the deferred queue. 3) Whoever is deferring frames is really only doing the __ast_read() to collect deferred frames and doesn't care about the returned frames except to detect a hangup event. When frame deferral is completed we must make the normal frame processing see the hangup as a frame anyway. As such, there is no need to have varying hangup frame deferral methods. We also need to be aware of the AST_SOFTHANGUP_ASYNCGOTO hangup that isn't real. That fake hangup is to cause the PBX thread to break out of loops to go execute a new dialplan location. 4) To properly deal with deferrable frames from the channel driver as pointed out by (2) above, means that it is possible to process a dialplan interception routine while frames are deferred because of the AST_CONTROL_READ_ACTION control frame. Deferring frames is not implemented as a re-entrant operation so you could have the unsupported case of two sections of code thinking they have control of the media stream. A worse problem is because of the bad implementation of the AMI PlayDTMF action. It can cause two threads to be deferring frames on the same channel at the same time. (ASTERISK_25940) * Rather than fix all these problems simply revert the API refactoring as there is going to be only autoservice and safe_sleep deferring frames anyway. ASTERISK-26343 ASTERISK-26716 #close Change-Id: I45069c779aa3a35b6c863f65245a6df2c7865496
2017-02-01audiohooks: Muting a hook can mute underlying framesSean Bright
If an audiohook is placed on a channel that does not require transcoding, muting that hook will cause the underlying frames to be muted as well. The original patch is from David Woolley but I have modified slightly. ASTERISK-21094 #close Reported by: David Woolley Patches: ASTERISK-21094-Patch-1.8-1.txt (license #5737) patch uploaded by David Woolley Change-Id: Ib2b68c6283e227cbeb5fa478b2d0f625dae338ed
2017-01-30Merge "ast_careful_fwrite to support EPIPE gracefully" into 14Joshua Colp
2017-01-29Merge "libastssl/pj: libastssl/pj should have an so_version" into 14zuul
2017-01-27debug_utilities: Add ast_logescalatorGeorge Joseph
The escalator works by creating a set of startup commands in cli.conf that set up logger channels and issue the debug commands for the subsystems specified. If asterisk is running when it is executed, the same commands will be issued to the running instance. The original cli.conf is saved before any changes are made and can be restored by executing '$prog --reset'. The log output will be stored in... $astlogdir/message.$uniqueid $astlogdir/debug.$uniqueid $astlogdir/dtmf.$uniqueid $astlogdir/fax.$uniqueid $astlogdir/security.$uniqueid $astlogdir/pjsip_history.$uniqueid $astlogdir/sip_history.$uniqueid Some minor tweaks were made to chan_sip, and res_pjsip_history so their history output could be send to a log channel as packets are captured. A minor tweak was also made to manager so events are output to verbose when "manager set debug on" is issued. Change-Id: I799f8e5013b86dc5282961b27383d134bf09e543
2017-01-27libastssl/pj: libastssl/pj should have an so_versionTorrey Searle
Issue introduced in b59956a87. In the non-darwin case libastssl/pj should be versioned. This causes the symbol file for this lib to not be generated. Change-Id: Ib07ae8c40252813c488e2c1ac6204fd42816dd4c (cherry picked from commit 54b027916a71f2b83b2050cef5ef704ea5de39b2)
2017-01-26ast_careful_fwrite to support EPIPE gracefullykkm
When a reading end of the network socket is closed by an AMI manager, the EPIPE is signaled when writing to our end, resulting in the spurious log error message ast_careful_fwrite: fwrite() returned error: Broken pipe Previously EPIPE was handled in ast_carefulwrite() a few lines above, but not in this function. ASTERISK-26753 Change-Id: I6a67335cd6526608bb9b78f796c626b1677664b8
2017-01-26Merge "PJPROJECT logging: Fix detection of max supported log level." into 14zuul
2017-01-26Merge "ari: Implement 'debug all' and request/response logging" into 14zuul
2017-01-26Merge "T.140: Fix format ref and memory leaks." into 14George Joseph
2017-01-26Merge "frame.c: Fix off-nominal format ref leaks." into 14George Joseph
2017-01-26Merge "astobj2.c: Add excessive ref count trap." into 14George Joseph
2017-01-25T.140: Fix format ref and memory leaks.Richard Mudgett
* channel.c:ast_sendtext(): Fix T.140 SendText memory leak. * format_compatibility.c: T.140 RED and T.140 were swapped. * res_rtp_asterisk.c:rtp_red_init(): Fix ast_format_t140_red ref leak. * res_rtp_asterisk.c:rtp_red_init(): Fix data race after starting periodic scheduled red_write(). * res_rtp_asterisk.c: Some other minor misc tweaks. Change-Id: Ifa27a2e0f8a966b1cf628607c86fc4374b0b88cb
2017-01-24astobj2.c: Add excessive ref count trap.Richard Mudgett
Change-Id: I32e6a589cf9009450e4ff7cb85c07c9d9ef7fe4a
2017-01-24main/app.c: Memory corruption from early format destruction.Richard Mudgett
* make_silence() created a malloced silence slin frame without adding a slin format ref. When the frame is destroyed it will unref the slin format that never had a ref added. Memory corruption is expected to follow. * Simplified and fixed counting the number of samples in a frame list for make_silence(). * Eliminated an unnecessary RAII_VAR associated with the make_silence() frame. Change-Id: I47de3f9b92635b7f8b4d72309444d6c0aee6f747
2017-01-24frame.c: Fix off-nominal format ref leaks.Richard Mudgett
* ast_frisolate() could leak frame format refs on allocation failures. * Similified code in ast_frisolate() and code used by ast_frisolate(). Change-Id: I79566d4d36b3d7801bf0c8294fcd3e9a86a2ed6d