summaryrefslogtreecommitdiff
path: root/main/manager.c
AgeCommit message (Collapse)Author
2018-03-20Merge "manager: Use ast_cli_completion_add for completion generators."Joshua Colp
2018-03-19manager: Use ast_cli_completion_add for completion generators.Corey Farrell
Change-Id: I658141c6ec490a3e866b02d2afea757928ceaabf
2018-03-14loader: Convert reload_classes to built-in modules.Corey Farrell
* acl (named_acl.c) * cdr * cel * ccss * dnsmgr * dsp * enum * extconfig (config.c) * features * http * indications * logger * manager * plc * sounds * udptl These modules are now loaded at appropriate time by the module loader. Unlike loadable modules these use AST_MODULE_LOAD_FAILURE on error so the module loader will abort startup on failure of these modules. Some of these modules are still initialized or shutdown from outside the module loader. logger.c is initialized very early and shutdown very late, manager.c is initialized by the module loader but is shutdown by the Asterisk core (too much uses it without holding references). Change-Id: I371a9a45064f20026c492623ea8062d02a1ab97f
2018-02-21manager.c: Fix lseek() parameter order.Richard Mudgett
ASTERISK-27659 Change-Id: I04a2705d2cb7df250769967bc59e2b397a49b797
2018-02-05Merge "manager.c: Fixed "(null):" header in AMI AsyncAGIEnd event"Jenkins2
2018-02-01manager.c: Fixed "(null):" header in AMI AsyncAGIEnd eventSungtae Kim
* Changed to create ami_event string only when the given blob is not json_null(). * Fixed bad expression. ASTERISK-27621 Change-Id: Ice58c16361f9d9e8648261c9ed5d6c8245fb0d8f
2018-02-01manager.c: Fix potential memory leak and corruption.Richard Mudgett
ast_str_append_event_header() could potentially leak and corrupt memory if the ast_str needed to expand to add the AMI event header. * Fixed to return error if the ast_str_append() failed. Change-Id: I92f36b855540743b208d76e274152ee2d758176d
2018-01-03loader: Create ast_module_running_ref.Corey Farrell
This function returns NULL if the module in question is not running. I did not change ast_module_ref as most callers do not check the result and they always call ast_module_unref. Make use of this function when running registered items from: * app_stack API's * bridge technologies * CLI commands * File formats * Manager Actions * RTP engines * Sorcery Wizards * Timing Interfaces * Translators * AGI Commands * Fax Technologies ASTERISK-20346 #close Change-Id: Ia16fd28e188b2fc0b9d18b8a5d9cacc31df73fcc
2017-12-28manager.c: Update AMI Status event documentationRichard Mudgett
The AMI Status event had linkedid listed twice and was missing the effective connected line name and number headers. NOTE: The linkedid and other standard channel snapshot fields in the XML documentation are part of the <channel_snapshot/> XML template defined in doc/appdocsxml.xslt. Change-Id: I004c4c4f9e7b40ef55035c831702721bec82496c
2017-12-19CLI: Address multiple issues.Corey Farrell
* listen uses the variable `s` for the result from ast_poll() then overwrites it with the result of accept(). Create a separate variable poll_result to avoid confusion since ast_poll does not return a file descriptor. * Resolve fd leak that would occur if setsockopt failed in listen. * Reserve an extra byte while processing completion results from remote daemon. This fixes a bug where completion processing used strstr() on a string that was not '\0' terminated. This was no risk to the Asterisk daemon, the bug was only reachable the remote console process. * Resolve leak in handle_showchan when the channel is not found. * Multiple leaks and a deadlock in pbx_config CLI completion. * Fix leaks in "manager show command". Change-Id: I8f633ceb1714867ae30ef4e421858f77c14485a9
2017-10-25Build System: Fix --disable-xmldoc option.Corey Farrell
The configure option to disable XML documentation does not currently work. This patch makes it effective, but also causes an ABI change by removing the ast_xmldoc_* symbols. Disabling xmldoc also prevents docs from being automatically generated, but they can still be manually generated with 'make doc/core-en_US.xml'. ASTERISK-26639 Change-Id: Ifac562340c09f80c83e0203de098fcac93bf8c44
2017-10-12features, manager : Add CancelAtxfer AMI actionThomas Sevestre
Add action to cancel feature attended transfer with AMI interface ASTERISK-27215 #close Change-Id: Iab8a81362b5a1757e2608f70b014ef863200cb42
2017-08-16manager: hook event is not being raisedKevin Harwell
When the iostream code went in it introduced a conditional that made it so the hook event was not being raised even if a hook is present. This patch adds a check to see if a hook is present in astman_append. If so then call into the send_string function, which in turn raises the even for specified hook. Also updated the ami hooks unit test, so the test could be automated. ASTERISK-27200 #close Change-Id: Iff37f02f9708195d8f23e68f959d6eab720e1e36
2017-08-01Fix compiler warnings on Fedora 26 / GCC 7.Corey Farrell
GCC 7 has added capability to produce warnings, this fixes most of those warnings. The specific warnings are disabled in a few places: * app_voicemail.c: truncation of paths more than 4096 chars in many places. * chan_mgcp.c: callid truncated to 80 chars. * cdr.c: two userfields are combined to cdr copy, fix would break ABI. * tcptls.c: ignore use of deprecated method SSLv3_client_method(). ASTERISK-27156 #close Change-Id: I65f280e7d3cfad279d16f41823a4d6fddcbc4c88
2017-05-26manager: Clear the flag on the other channel.Joshua Colp
During the channel flag audit an incorrect change was done. The flag should be cleared on the second channel. ASTERISK-26469 Change-Id: I770c5a389550a2fb5a6ade942fccbb2e1d9199c8
2017-05-16asterisk: Audit locking of channel when manipulating flags.Joshua Colp
When manipulating flags on a channel the channel has to be locked to guarantee that nothing else is also manipulating the flags. This change introduces locking where necessary to guarantee this. It also adds helper functions that manipulate channel flags and lock to reduce repeated code. ASTERISK-26789 Change-Id: I489280662dba0f4c50981bfc5b5a7073fef2db10
2017-05-09Prevent Undefined Capath CrashJoshua Elson
It is possible to initialize a valid config without a capath or cafile definition. This will cause a crash on a reload. This fix ensures capath is always allocated. ASTERISK-26983 #close Change-Id: I63ff715d9d9023427543a5b8a4ba7b0d82533c12
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-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-02-17Remove extra ast_iostream_close() calls.Mark Michelson
When AMI encounters an error at the beginning of a session, it would explicitly call ast_iostream_close() on its tcptls session's iostream. It then would jump to a label where it would shut down the tcptls session instance. The tcptls session instance would again attempt to close the iostream. Under normal circumstances, this might go by unnoticed. However, when MALLOC_DEBUG is enabled, all fields on the iostream get set to 0xdeaddead when the iostream is freed. Thus a second call to ast_iostream_close() after the iostream has been freed would reslt in an attempt to call SSL_shutdown on 0xdeaddead, which would crash and burn horribly. The fix here is to not directly close the iostream from the dangerous scenarios. The specific scenarios are: * Exceeding the configured authlimit * Failing to build a mansession on a new connection Change-Id: I908f98d516afd5a263bd36b072221008a4731acd
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-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
2016-11-15Implement internal abstraction for iostreamsTimo Teräs
fopencookie/funclose is a non-standard API and should not be used in portable software. Additionally, the way FILE's fd is used in non-blocking mode is undefined behaviour and cannot be relied on. This introduces internal abstraction for io streams, that allows implementing the desired virtualization of read/write operations with necessary timeout handling. ASTERISK-24515 #close ASTERISK-24517 #close Change-Id: Id916aef418b665ced6a7489aef74908b6e376e85
2016-10-27Remove ASTERISK_REGISTER_FILE.Corey Farrell
ASTERISK_REGISTER_FILE no longer has any purpose so this commit removes all traces of it. Previously exported symbols removed: * __ast_register_file * __ast_unregister_file * ast_complete_source_filename This also removes the mtx_prof static variable that was declared when MTX_PROFILE was enabled. This variable was only used in lock.c so it is now initialized in that file only. ASTERISK-26480 #close Change-Id: I1074af07d71f9e159c48ef36631aa432c86f9966
2016-08-16Merge "manager: Add <see-also> tags to relate AoC events and actions"Joshua Colp
2016-08-15Merge "manager: Add <see-also> tags to relate UserEvent actions/apps/events"zuul
2016-08-15manager: Add <see-also> tags to relate interrelated events/actions togetherMatt Jordan
Change-Id: Idbac539205aa732bf786c4f765577d8e9ff28ba4
2016-08-15manager: Add <see-also> tags to relate AoC events and actionsMatt Jordan
Change-Id: Iea89a36222712148c1775c05ed0ad1049d67a70e
2016-08-15manager: Add <see-also> tags to relate UserEvent actions/apps/eventsMatt Jordan
Change-Id: I80f8a981f62f50e74609c69c49edcaca6c95efa4
2016-06-09stasis: Add setting subscription congestion levels.Richard Mudgett
Stasis subscriptions and message routers create taskprocessors to process the event messages. API calls are needed to be able to set the congestion levels of these taskprocessors for selected subscriptions and message routers. * Updated CDR, CEL, and manager's stasis subscription congestion levels based upon stress testing. Increased the congestion levels to reduce the potential for bursty call setup/teardown activity from triggering the taskprocessor overload alert. CDRs in particular need an extra high congestion level because they can take awhile to process the stasis messages. ASTERISK-26088 Reported by: Richard Mudgett Change-Id: Id0a716394b4eee746dd158acc63d703902450244
2016-06-02core/manager: Add uptime field to FullyBootedNiklas Larsson
Add Uptime and LastReload to event FullyBooted. ASTERISK-26058 #close Reported by: Niklas Larsson Change-Id: I909b330801c0990d78df9b272ab0adc95aecb15e
2016-04-22Manager: Short circuit AMI message processing.Richard Mudgett
Improve AMI message processing performance if there are no consumers listening for the messages. We now skip creating the AMI event message text strings. Change-Id: I7b22fc5ec4e500d00635c1a467aa8ea68a1bb2b3
2016-04-22manager.c: Eliminate most RAII_VAR usage.Richard Mudgett
* Made ast_manager_event_blob_create() not allocate the ao2 event object with a lock as it is not needed. Change-Id: I8e11bfedd22c21316012e0b9dd79f5918f644b7c
2016-04-07pbx.h: Make ast_state_cb_type take more const.Richard Mudgett
This eliminates some casts that I made a note saying v10 and above would no longer need them. Better late than never :) Change-Id: I346cdb3032b6478ceb40eb6fe732978b54035572
2016-03-24Restrict CLI/AMI commands on shutdown.Mark Michelson
During stress testing, we have frequently seen crashes occur because a CLI or AMI command attempts to access information that is in the process of being destroyed. When addressing how to fix this issue, we initially considered fixing individual crashes we observed. However, the changes required to fix those problems would introduce considerable overhead to the nominal case. This is not reasonable in order to prevent a crash from occurring while Asterisk is already shutting down. Instead, this change makes it so AMI and CLI commands cannot be executed if Asterisk is being shut down. For AMI, this is absolute. For CLI, though, certain commands can be registered so that they may be run during Asterisk shutdown. ASTERISK-25825 #close Change-Id: I8887e215ac352fadf7f4c1e082da9089b1421990
2016-02-01build_system: Fix some warnings highlighted by clangGeorge Joseph
Fix some warnings found with clang. Change-Id: I5195b6189b148c2ee3ed4a19d015a6d4ef3e77bd
2016-01-10manager: Cleanup manager_channelvars during shutdown.Corey Farrell
ASTERISK-25680 #close Change-Id: I3251d781cbc3f48a6a7e1b969ac4983f552b2446
2015-12-15AMI: Fixed OriginateResponse messagepchero
When the asterisk sending OriginateResponse message, it doesn't set the "Uniqueid". And it didn't support correct response message for Application originate. ASTERISK-25624 #close Change-Id: I26f54f677ccfb0b7cfd4967a844a1657fd69b74d
2015-11-09ast_format_cap_get_names: To display all formats, the buffer was increased.Alexander Traud
ASTERISK-25533 #close Change-Id: Ie1a9d1a6511b3f1a56b93d04475fbf8a4e40010a
2015-10-21Add missing failure checks to ast_str_set_va() callers.Richard Mudgett
Change-Id: I0c2cdcd53727bdc6634095c61294807255bd278f
2015-10-03manager: Fix GetConfigJSON returning invalid JSONIvan Poddubny
When GetConfigJSON was introduced back in 1.6, it returned each section as an array of strings: ["key=value", "key2=value2"]. Afterwards, it was changed a few times and became ["key": "value", "key2": "value2"], which is not a correct JSON. This patch fixes that by constructing a JSON object {} instead of an array []. Also, the keys "istemplate" and "tempates" that are used to indicate templates and their inherited categories are now wrapped in quotes. ASTERISK-25391 #close Reported by: Bojan Nemčić Change-Id: Ibbe93c6a227dff14d4a54b0d152341857bcf6ad8
2015-05-06main/manager.c: Bugfix sort action_manager by alphabeticallyRodrigo Ramírez Norambuena
Fix the alphabetic order added on ast_manager_register_struct. The order for struct manager_action added is not working, this change fixes the problem. Change-Id: I149da0cd06c3c4445d7516cc303358e9f26f8b4b
2015-05-06manager: Fix build due to missing variable usage.Joshua Colp
Change-Id: I26d4d2cb9cee924632ff59ef0b30a7e6a1e2b00d
2015-04-30Restrict functionality when ACLs are misconfigured.Mark Michelson
This patch has two main purposes: 1) Improve warning messages when ACLs are configured improperly. 2) Prevent misconfigured ACLs from allowing potentially unwanted traffic. To acomplish point (2) in most cases, whatever configuration object that the ACL belonged to was not allowed to load. The one exception is res_pjsip_acl. In that case, ACLs are their own configuration object. Furthermore, the module loading code has no indication that a ACL configuration had a failure. So the tactic taken here is to create an ACL that just blocks everything. ASTERISK-24969 Reported by Corey Farrell Change-Id: I2ebcb6959cefad03cea4d81401be946203fcacae
2015-04-20New AMI Command Output FormatGareth Palmer
This change modifies how the the output from a CLI command is sent to a client over AMI. Output from the CLI command is now sent as a series of zero-or-more Output: headers. Additionally, commands that fail to execute (eg: no such command, invalid syntax etc.) now cause an Error response instead of Success. If the command executed successfully, but the manager unable to provide the output the reason will be included in the Message: header. Otherwise it will contain 'Command output follows'. Depends on a new version of starpy (> 1.0.2) that supports the new output format. See pull-request https://github.com/asterisk/starpy/pull/34 ASTERISK-24730 Change-Id: I6718d95490f0a6b3f171c1a5cdad9207f9a44888
2015-04-13AMI: Fix improper handling of lines that are exactly 1025 bytes long.Corey Farrell
When AMI receives a line that is 1025 bytes long, it sends two error messages. Copy the last byte in the buffer to the first postiion, set the length to 1. ASTERISK-20524 #close Reported by: David M. Lee Change-Id: Ifda403e2713b59582c715229814fd64a0733c5ea
2015-04-13git migration: Refactor the ASTERISK_FILE_VERSION macroMatt Jordan
Git does not support the ability to replace a token with a version string during check-in. While it does have support for replacing a token on clone, this is somewhat sub-optimal: the token is replaced with the object hash, which is not particularly easy for human consumption. What's more, in practice, the source file version was often not terribly useful. Generally, when triaging bugs, the overall version of Asterisk is far more useful than an individual SVN version of a file. As a result, this patch removes Asterisk's support for showing source file versions. Specifically, it does the following: * Rename ASTERISK_FILE_VERSION macro to ASTERISK_REGISTER_FILE, and remove passing the version in with the macro. Other facilities than 'core show file version' make use of the file names, such as setting a debug level only on a specific file. As such, the act of registering source files with the Asterisk core still has use. The macro rename now reflects the new macro purpose. * main/asterisk: - Refactor the file_version structure to reflect that it no longer tracks a version field. - Remove the "core show file version" CLI command. Without the file version, it is no longer useful. - Remove the ast_file_version_find function. The file version is no longer tracked. - Rename ast_register_file_version/ast_unregister_file_version to ast_register_file/ast_unregister_file, respectively. * main/manager: Remove value from the Version key of the ModuleCheck Action. The actual key itself has not been removed, as doing so would absolutely constitute a backwards incompatible change. However, since the file version is no longer tracked, there is no need to attempt to include it in the Version key. * UPGRADE: Add notes for: - Modification to the ModuleCheck AMI Action - Removal of the "core show file version" CLI command Change-Id: I6cf0ff280e1668bf4957dc21f32a5ff43444a40e
2015-04-06build: Fixes for gcc 5 compilationGeorge Joseph
These are fixes for compilation under gcc 5.0... chan_sip.c: In parse_request needed to make 'lim' unsigned. inline_api.h: Needed to add a check for '__GNUC_STDC_INLINE__' to detect C99 inline semantics (same as clang). ccss.c: In ast_cc_set_parm, needed to fix weird comparison. dsp.c: Needed to work around a possible compiler bug. It was throwing an array-bounds error but neither sgriepentrog, rmudgett nor I could figure out why. manager.c: In action_atxfer, needed to correct an array allocation. This patch will go to 11, 13, trunk. Review: https://reviewboard.asterisk.org/r/4581/ Reported-by: Jeffrey Ollie Tested-by: George Joseph ASTERISK-24932 #close ........ Merged revisions 434113 from http://svn.asterisk.org/svn/asterisk/branches/11 ........ Merged revisions 434114 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@434115 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-03-26Replace most uses of ast_register_atexit with ast_register_cleanup.Corey Farrell
Since 'core stop now' and 'core restart now' do not stop modules, it is unsafe for most of the core to run cleanups. Originally all cleanups used ast_register_atexit, and were only changed when it was shown to be unsafe. ast_register_atexit is now used only when absolutely required to prevent corruption and close child processes. Exceptions that need to use ast_register_atexit: * CDR: Flush records. * res_musiconhold: Kill external applications. * AstDB: Close the DB. * canary_exit: Kill canary process. ASTERISK-24142 #close Reported by: David Brillert ASTERISK-24683 #close Reported by: Peter Katzmann ASTERISK-24805 #close Reported by: Badalian Vyacheslav ASTERISK-24881 #close Reported by: Corey Farrell Review: https://reviewboard.asterisk.org/r/4500/ Review: https://reviewboard.asterisk.org/r/4501/ ........ Merged revisions 433495 from http://svn.asterisk.org/svn/asterisk/branches/11 ........ Merged revisions 433497 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@433498 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-03-23Fix compilations errors on 64-bit OpenBSD systemsMatthew Jordan
In versiong 5.5, OpenBSD went to 64-bit time values. This requires a cast to (long) when printing members of certain time structs. Review: https://reviewboard.asterisk.org/r/4507 ASTERISK-24879 #close Reported by: snuffy Tested by: snuffy patches: openbsd-time64.diff uploaded by snuffy (License 5024) ........ Merged revisions 433268 from http://svn.asterisk.org/svn/asterisk/branches/11 ........ Merged revisions 433269 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@433270 65c4cc65-6c06-0410-ace0-fbb531ad65f3