summaryrefslogtreecommitdiff
path: root/main/config.c
AgeCommit message (Collapse)Author
2017-12-01config: Speed up config template lookupSean Bright
ast_category_get() has an (undocumented) implementation detail where it tries to match the category name first by an explicit pointer comparison and if that fails falls back to a normal match. When initially building an ast_config during ast_config_load, this pointer comparison can never succeed, but we will end up iterating all categories twice. As the number of categories using a template increases, this dual looping becomes quite expensive. So we pass a flag to category_get_sep() indicating if a pointer match is even possible before trying to do so, saving us a full pass over the list of current categories. In my tests, loading a file with 3 template categories and 12000 additional categories that use those 3 templates (this file configures 4000 PJSIP endpoints with AOR & Auth) takes 1.2 seconds. After this change, that drops to 22ms. Change-Id: I59b95f288e11eb6bb34f31ce4cc772136b275e4a
2017-07-13core: Add PARSE_TIMELEN support to ast_parse_arg and ACO.Corey Farrell
This adds support for parsing timelen values from config files. This includes support for all flags which apply to PARSE_INT32. Support for this parser is added to ACO via the OPT_TIMELEN_T option type. Fixes an issue where extra characters provided to ast_app_parse_timelen were ignored, they now cause an error. Testing is included. ASTERISK-27117 #close Change-Id: I6b333feca7e3f83b4ef5bf2636fc0fd613742554
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-19Fix checks for allocation debugging.Corey Farrell
MALLOC_DEBUG should not be used to check if debugging is actually enabled, __AST_DEBUG_MALLOC should be used instead. MALLOC_DEBUG only indicates that debugging is requested, __AST_DEBUG_MALLOC indicates it is active. Change-Id: I3ce9cdb6ec91b74ee1302941328462231be1ea53
2016-04-25config: Fix ast_config_text_file_save2 writability check for missing filesGeorge Joseph
A patch I did back in 2014 modified ast_config_text_file_save2 to check the writability of the main file and include files before truncating and re-writing them. An unintended side-effect of this was that if a file doesn't exist, the check fails and the write is aborted. This patch causes ast_config_text_file_save2 to check the writability of the parent directory of missing files instead of checking the file itself. This allows missing files to be created again. A unit test was also added to test_config to test saving of config files. The regression was discovered when app_voicemail's passwordlocation=spooldir feature stopped working. ASTERISK-25917 #close Reported-by: Jonathan Rose Change-Id: Ic4dbe58c277a47b674679e49daed5fc6de349f80
2016-04-05config: Allow filters when appending to a categoryGeorge Joseph
In sorcery based config files where there are multiple categories with the same name, you can't use the (+) operator to reliably append to a category because config.c stops looking when it finds the first one with the same name. Example: [1000] type = endpoint [1000] type = aor [1000](+) authenticate_qualify = yes This config will fail because config.c appends authenticate_qualify to the first category it finds, the endpoint, and that's not valid for endpoint. Solution: The capability to find a category that contains a certain variable already exists so the only real change was to parse anything after the '+' that's not a comma, as a filter string. [1000] type = endpoint [1000] type = aor [1000](+type=aor) authenticate_qualify = yes This now works as expected. Although the following example doesn't make any sense for pjsip, you can even specify multiple filters: [1000](+type=aor&qualify_frequency=10) ASTERISK-25868 #close Reported-by: Nick Repin Change-Id: I10773da4c79db36fbf1993961992af63d3441580
2016-03-27sorcery/res_pjsip: Refactor for realtime performanceGeorge Joseph
There were a number of places in the res_pjsip stack that were getting all endpoints or all aors, and then filtering them locally. A good example is pjsip_options which, on startup, retrieves all endpoints, then the aors for those endpoints, then tests the aors to see if the qualify_frequency is > 0. One issue was that it never did anything with the endpoints other than retrieve the aors so we probably could have skipped a step and just retrieved all aors. But nevermind. This worked reasonably well with local config files but with a realtime backend and thousands of objects, this was a nightmare. The issue really boiled down to the fact that while realtime supports predicates that are passed to the database engine, the non-realtime sorcery backends didn't. They do now. The realtime engines have a scheme for doing simple comparisons. They take in an ast_variable (or list) for matching, and the name of each variable can contain an operator. For instance, a name of "qualify_frequency >" and a value of "0" would create a SQL predicate that looks like "where qualify_frequency > '0'". If there's no operator after the name, the engines add an '=' so a simple name of "qualify_frequency" and a value of "10" would return exact matches. The non-realtime backends decide whether to include an object in a result set by calling ast_sorcery_changeset_create on every object in the internal container. However, ast_sorcery_changeset_create only does exact string matches though so a name of "qualify_frequency >" and a value of "0" returns nothing because the literal "qualify_frequency >" doesn't match any name in the objset set. So, the real task was to create a generic string matcher that can take a left value, operator and a right value and perform the match. To that end, strings.c has a new ast_strings_match(left, operator, right) function. Left and right are the strings to operate on and the operator can be a string containing any of the following: = (or NULL or ""), !=, >, >=, <, <=, like or regex. If the operator is like or regex, the right string should be a %-pattern or a regex expression. If both left and right can be converted to float, then a numeric comparison is performed, otherwise a string comparison is performed. To use this new function on ast_variables, 2 new functions were added to config.c. One that compares 2 ast_variables, and one that compares 2 ast_variable lists. The former is useful when you want to compare 2 ast_variables that happen to be in a list but don't want to traverse the list. The latter will traverse the right list and return true if all the variables in it match the left list. Now, the backends' fields_cmp functions call ast_variable_lists_match instead of ast_sorcery_changeset_create and they can now process the same syntax as the realtime engines. The realtime backend just passes the variable list unaltered to the engine. The only gotcha is that there's no common realtime engine support for regex so that's been noted in the api docs for ast_sorcery_retrieve_by_fields. Only one more change to sorcery was done... A new config flag "allow_unqualified_fetch" was added to reg_sorcery_realtime. "no": ignore fetches if no predicate fields were supplied. "error": same as no but emit an error. (good for testing) "yes": allow (the default); "warn": allow but emit a warning. (good for testing) Now on to res_pjsip... pjsip_options was modified to retrieve aors with qualify_frequency > 0 rather than all endpoints then all aors. Not only was this a big improvement in realtime retrieval but even for config files there's an improvement because we're not going through endpoints anymore. res_pjsip_mwi was modified to retieve only endpoints with something in the mailboxes field instead of all endpoints then testing mailboxes. res_pjsip_registrar_expire was completely refactored. It was retrieving all contacts then setting up scheduler entries to check for expiration. Now, it's a single thread (like keepalive) that periodically retrieves only contacts whose expiration time is < now and deletes them. A new contact_expiration_check_interval was added to global with a default of 30 seconds. Ross Beer reports that with this patch, his Asterisk startup time dropped from around an hour to under 30 seconds. There are still objects that can't be filtered at the database like identifies, transports, and registrations. These are not going to be anywhere near as numerous as endpoints, aors, auths, contacts however. Back to allow_unqualified_fetch. If this is set to yes and you have a very large number of objects in the database, the pjsip CLI commands will attempt to retrive ALL of them if not qualified with a LIKE. Worse, if you type "pjsip show endpoint <tab>" guess what's going to happen? :) Having a cache helps but all the objects will have to be retrieved at least once to fill the cache. Setting allow_unqualified_fetch=no prevents the mass retrieve and should be used on endpoints, auths, aors, and contacts. It should NOT be used for identifies, registrations and transports since these MUST be retrieved in bulk. Example sorcery.conf: [res_pjsip] endpoint=config,pjsip.conf,criteria=type=endpoint endpoint=realtime,ps_endpoints,allow_unqualified_fetch=error ASTERISK-25826 #close Reported-by: Ross Beer Tested-by: Ross Beer Change-Id: Id2691e447db90892890036e663aaf907b2dc1c67
2016-01-15main/config: Clean config maps on shutdown.Corey Farrell
ASTERISK-25700 #close Change-Id: I096da84f9c62c6095f68bcf98eac4b7c7868e808
2015-10-12config.c: Fix off-nominal memory leak.Richard Mudgett
Change-Id: I06e346e9a5c63cc5071e7eda537310c4b43bffe0
2015-10-12config.c: Fix potential memory corruption after [section](+).Richard Mudgett
The memory corruption could happen if the [section](+) is the last section in the file with trailing comments. In this case process_text_line() has left *last_cat is set to newcat and newcat is destroyed. Change-Id: I0d1d999f553986f591becd000e7cc6ddfb978d93
2015-10-12config.c: Fix #include after [section](+).Richard Mudgett
An #include right after a [section](+) would associate any variable assignments before a new section in the #include with the wrong section. * Fix section association by setting the current section to the appended section. * Fix '+' and '!' section flag interaction corner case depending upon which flag came first. If the '!' came first then it would be ignored. If the '!' came after then it would affect the appended section. The '!' will now no longer be ignored. ASTERISK-25461 #close Reported by: Sean Pimental Change-Id: Ic9d3191c8758048e2cbce6432f854b32531731c3
2015-07-02sorcery/realtime: Add a bit of debug and warning messages for bad configsMatt Jordan
When a mapping does not exist between a sorcery.conf defined object and a realtime mapping in extconf, currently, the user will receive a slew of ERROR messages that don't really tell what is happening. Some ERROR messages may even be misleading, as they occur after the sorcery API has already given up on the attempt to load and create the sorcery object. This patch adds a bit of debug and a useful WARNING message for when a wizard's open callback fails for a particular object type. In the bad configurations that resulted in this patch, this provided a 'root cause' WARNING message that pointed in the right direction of the configuration problem. Change-Id: I1cc7344f2b015b8b9c85a7e6ebc8cb4753a8f80b
2015-05-15res_pjsip_config_wizard/config: Fix template processingGeorge Joseph
The config wizard was always pulling the first occurrence of a variable from an ast_variable list but this gets the template value from the list instead of any overridden value. This patch creates ast_variable_find_last_in_list() in config.c and updates res_pjsip_config_wizard to use it instead of ast_variable_find_in_list. Now the overridden values, where they exist, are used instead of template variables. Updated test_config to test the new API. ASTERISK-25089 #close Reported-by: George Joseph <george.joseph@fairview5.com> Tested-by: George Joseph <george.joseph@fairview5.com> Change-Id: Ifa7ddefc956a463923ee6839dd1ebe021c299de4
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-03-28clang compiler warnings: Fix -Wunused-function; make inline function staticMatthew Jordan
This patch fixes clang compilers warnings for unused functions. Specifically: * channels/chan_iax2: removed user_ref function * main/dsp.c: removed goertzel_update function * main/config.c: made variable_list_switch static Review: https://reviewboard.asterisk.org/r/4527 ASTERISK-24917 Reported by: dkdegroot patches: rb4527.patch submitted by dkdegroot (License 6600) ........ Merged revisions 433678 from http://svn.asterisk.org/svn/asterisk/branches/11 ........ Merged revisions 433680 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@433681 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-17Various: bugfixes found via chaosScott Griepentrog
Using DEBUG_CHAOS several instances of a null pointer crash, and one uninitialized variable were uncovered and fixed. Also added details on why Asterisk failed to initialize. Review: https://reviewboard.asterisk.org/r/4468/ ........ Merged revisions 433064 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@433065 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-02-06various: cleanup issues found during leak huntScott Griepentrog
In this collection of small patches to prevent Valgrind errors are: fixes for reference leaks in config hooks, evaluating a parameter beyond bounds, and accessing a structure after a lock where it could have been already free'd. Review: https://reviewboard.asterisk.org/r/4407/ ........ Merged revisions 431583 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@431584 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-01-25dynamic realtime: Updates fail to work due to update fields being passed overMatthew Jordan
When a crash was fixed due to usage of the REALTIME function in r423003, a regression was introduced into ast_update2_realtime where the update fields passed to the function would be skipped and the lookup field processed twice. The use of this function is a bit interesting: A variable argument list is used with two sentinel values - the first marks the end of the lookup fields/values; the second marks the end of the update fields/values. Unfortunately, ast_update2_realtime parses over the lookup fields twice, as opposed to parsing over the update fields. This causes the lookups to succeed, but the updates itself to have no effect. Note that the most common instance of this problem occurred in app_voicemail during the updating of a mailbox password. Thanks to the issue reporter, Paddy Grice, for pointing out the problem. Review: https://reviewboard.asterisk.org/r/4356/ ASTERISK-24231 ASTERISK-24626 #close Reported by: Paddy Grice ........ Merged revisions 431072 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@431073 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-01-07config: Add option to NOT preserve effective context when changing a templateGeorge Joseph
Let's say you have a template T with variable VAR1 = ON and you have a context C(T) that doesn't specify VAR1. If you read C, the effective value of VAR1 is ON. Now you change T VAR1 to OFF and call ast_config_text_file_save. The current behavior is that the file gets re-written with T/VAR1=OFF but C/VAR1=ON is added. Personally, I think this is a bug. It's preserving the effective state of C even though I didn't specify C/VAR1 in th first place. I believe the behavior should be that if I didn't specify C/VAR1 originally, then the effective value of C/VAR1 should continue to follow the inherited state. Now, if I DID explicitly specify C/VAR1, the it should be preserved even if the template changes. Even though I think the existing behavior is a bug, it's been that way forever so I'm not changing it. Instead, I've created ast_config_text_file_save2() that takes a bitmask of flags, one of which is to preserve the effective context (the current behavior). The original ast_config_text_file_save calls *2 with the preserve flag. If you want the new behavior, call *2 directly without a flag. I've also updated Manager UpdateConfig with a new parameter 'PreserveEffectiveContext' whose default is 'yes'. If you want the new behavior with UpdateConfig, set 'PreserveEffectiveContext: no'. Tested-by: George Joseph Review: https://reviewboard.asterisk.org/r/4297/ ........ Merged revisions 430295 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@430296 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-12-02config: Create ast_variable_find_in_list()George Joseph
Add const char *ast_variable_find_in_list(const struct ast_variable *list, const char *variable); ast_variable_find() requires a config category to search whereas ast_variable_find_in_list() just needs the root list element which is useful if you don't have a category. Tested-by: George Joseph Review: https://reviewboard.asterisk.org/r/4217/ ........ Merged revisions 428733 from http://svn.asterisk.org/svn/asterisk/branches/12 ........ Merged revisions 428734 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@428735 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-11-05config: Make text_file_save and 'dialplan save' escape semicolons in values.George Joseph
When a config file is read, an unescaped semicolon signals comments which are stripped from the value before it's stored. Escaped semicolons are then unescaped and become part of the value. Both of these behaviors are normal and expected. When the config is serialized either by 'dialplan save' or AMI/UpdateConfig however, the now unescaped semicolons are written as-is. If you actually reload the file just saved, the unescaped semicolons are now treated as start of comments. Since true comments are stripped on read, any semicolons in ast_variable.value must have been escaped originally. This patch re-escapes semicolons in ast_variable.values before they're written to file either by 'dialplan save' or config/ast_config_text_file_save which is called by AMI/UpdateConfig. I also fixed a few pre-existing formatting issues nearby in pbx_config.c Tested-by: George Joseph ASTERISK-20127 #close Review: https://reviewboard.asterisk.org/r/4132/ ........ Merged revisions 427275 from http://svn.asterisk.org/svn/asterisk/branches/12 ........ Merged revisions 427276 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@427277 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-11-04config: BUG: Restore ability for non-templ to be used as base objs in config.George Joseph
My recent refactor of config.c accidentally removed the capability for an object to inherit from a non-template object. This patch restores the capability to inherit from both template and non-template objects. Tested-by: George Joseph Reported-by: Scott Griepentrog ASTERISK-24487 #close Review: https://reviewboard.asterisk.org/r/4147/ ........ Merged revisions 427227 from http://svn.asterisk.org/svn/asterisk/branches/12 ........ Merged revisions 427228 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@427229 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-10-16config: Fix inf loop using ast_category_browse and ast_variable_retrieveGeorge Joseph
Fix infinite loop when calling ast_variable_retrieve inside an ast_category_browse loop when there is more than 1 category with the same name. Tested-by: George Joseph Review: https://reviewboard.asterisk.org/r/4089/ ........ Merged revisions 425713 from http://svn.asterisk.org/svn/asterisk/branches/12 ........ Merged revisions 425714 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@425715 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-10-14config: Fix SEGV in unit test with MALLOC_DEBUGGeorge Joseph
With MALLOC_DEBUG the /main/config config_basic_ops test was causing a SEGV while doing an ast_category_delete in an ast_category_browse loop. Apparently this never worked but was also never tested. I removed the test, added 2 notes to config.h indicating that it's not supported and added a few lines of code to ast_category_delete to prevent the SEGV should someone attempt it in the future. Tested-by: George Joseph Review: https://reviewboard.asterisk.org/r/4078/ ........ Merged revisions 425525 from http://svn.asterisk.org/svn/asterisk/branches/12 ........ Merged revisions 425526 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@425527 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-10-13manager/config: Support templates and non-unique category names via AMIGeorge Joseph
This patch provides the capability to manipulate templates and categories with non-unique names via AMI. Summary of changes: GetConfig and GetConfigJSON: Added "Filter" parameter: A comma separated list of name_regex=value_regex expressions which will cause only categories whose variables match all expressions to be considered. The special variable name TEMPLATES can be used to control whether templates are included. Passing 'include' as the value will include templates along with normal categories. Passing 'restrict' as the value will restrict the operation to ONLY templates. Not specifying a TEMPLATES expression results in the current default behavior which is to not include templates. UpdateConfig: NewCat now includes options for allowing duplicate category names, indicating if the category should be created as a template, and specifying templates the category should inherit from. The rest of the actions now accept a filter string as defined above. If there are non-unique category names, you can now update specific ones based on variable values. To facilitate the new capabilities in manager, corresponding changes had to be made to config, most notably the addition of filter criteria to many of the APIs. In some cases it was easy to change the references to use the new prototype but others would have required touching too many files for this patch so a wrapper with the original prototype was created. Macros couldn't be used in this case because it would break binary compatibility with modules such as res_digium_phone that are linked to real symbols. Tested-by: George Joseph Review: https://reviewboard.asterisk.org/r/4033/ ........ Merged revisions 425383 from http://svn.asterisk.org/svn/asterisk/branches/12 ........ Merged revisions 425384 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@425385 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-09-18config: bug: Fix SEGV in ast_category_insert when matching category isn't foundGeorge Joseph
If you call ast_category_insert with a match category that doesn't exist, the list traverse runs out of 'next' categories and you get a SEGV. This patch adds check for the end-of-list condition and changes the signature to return an int for success/failure indication instead of a void. The only consumer of this function is manager and it was also changed to use the return value. Tested by: George Joseph Review: https://reviewboard.asterisk.org/r/3993/ ........ Merged revisions 423276 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 423277 from http://svn.asterisk.org/svn/asterisk/branches/11 ........ Merged revisions 423278 from http://svn.asterisk.org/svn/asterisk/branches/12 ........ Merged revisions 423279 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@423280 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-09-12Realtime: Fix a bug that caused realtime destroy command to crashJonathan Rose
Also has could affect with anything that goes through ast_destroy_realtime. If a CLI user used the command 'realtime destroy <family>' with only a single column/value pair, Asterisk would crash when trying to create a variable list from a NULL value. ASTERISK-24231 #close Reported by: Niklas Larsson Review: https://reviewboard.asterisk.org/r/3985/ ........ Merged revisions 422984 from http://svn.asterisk.org/svn/asterisk/branches/12 ........ Merged revisions 422985 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@422991 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-09-10config: bug: fix truncation of included config files on permissions errorGeorge Joseph
ast_config_text_file_save() currently truncates include files as they are processed. If a subsequent include file or the main config file has a permissions error that prevents writing, earlier include files are left truncated resulting in a frantic search for backups. This patch causes ast_config_text_file_save to check for write access on all files before it truncates any of them. Will be applied 1.8 > trunk. Tested by: George Joseph Review: https://reviewboard.asterisk.org/r/3986/ ........ Merged revisions 422900 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 422903 from http://svn.asterisk.org/svn/asterisk/branches/11 ........ Merged revisions 422904 from http://svn.asterisk.org/svn/asterisk/branches/12 ........ Merged revisions 422905 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@422906 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-07-11config: inform config hook of change when writing fileScott Griepentrog
When updated configuration is written back to the conf file - for example when a user changes their voicemail pin, make sure that any config hook that wants to know of changes is informed. Review: https://reviewboard.asterisk.org/r/3708/ ........ Merged revisions 418366 from http://svn.asterisk.org/svn/asterisk/branches/11 ........ Merged revisions 418369 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@418370 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-06-06chan_sip: Fix order of variables specified in SIPNotify actionJonathan Rose
Prior to this patch, sequential variables would be ordered in reverse from the order specified in the manager action. Review: https://reviewboard.asterisk.org/r/3588/ ........ Merged revisions 415359 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 415390 from http://svn.asterisk.org/svn/asterisk/branches/11 ........ Merged revisions 415410 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@415411 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-06-05config: Fix indentation and missing curlies in config_text_file_load().Richard Mudgett
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@415288 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-06-05config: Fix config files not reloading when only an included file changes.Richard Mudgett
The twisted logic determining if a config file should be reloaded was mostly broken and disabled. The incorrect test that ASTERISK-23383 fixed actually reenabled the broken logic. The incorrect test was causing the timestamp to always be cleared which caused config files with includes to always be reloaded. * Made wildcard includes always cause a reload. Determining if a file was deleted cannot be determined without restructuring the cache to determine if any files are missing from the last files actually loaded. Also without refactoring config_text_file_load(), the glob loop couldn't check more than one file for changes anyway. * Made remove the cache entry if the file no longer exists when trying to get its timestamp or it is no longer a regular file. This fixes the corner case where the file was loaded, then deleted, then the config reloaded, then the file restored with the same timestamp, and then the config reloaded again. * Made remove the cache entry include list when actually loading the file. This gets rid of any stale includes the file had from the last time the file was loaded. ASTERISK-23683 #close Reported by: tootai Review: https://reviewboard.asterisk.org/r/3575/ ........ Merged revisions 415225 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 415229 from http://svn.asterisk.org/svn/asterisk/branches/11 ........ Merged revisions 415230 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@415231 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-05-30main/config.c: AMI action UpdateConfig EmptyCat clears all categoriesMatthew Jordan
When invoking UpdateConfig AMI action with Action set to EmptyCat, Asterisk will make all categories empty in the config but the one requested with a Cat variable. This is due to a bug in ast_category_empty (main/config.c) that makes an incorrect comparison for a category name. This patch corrects the comparison such that only the requested category is cleared. Review: https://reviewboard.asterisk.org/r/3573/ #ASTERISK-23803 #close Reported by: zvision patches: manager.c.diff uploaded by zvision (License 5755) ........ Merged revisions 414880 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 414881 from http://svn.asterisk.org/svn/asterisk/branches/11 ........ Merged revisions 414882 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@414883 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-05-09Allow Asterisk to compile under GCC 4.10Kinsey Moore
This resolves a large number of compiler warnings from GCC 4.10 which cause the build to fail under dev mode. The vast majority are signed/unsigned mismatches in printf-style format strings. ........ Merged revisions 413586 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 413587 from http://svn.asterisk.org/svn/asterisk/branches/11 ........ Merged revisions 413588 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@413589 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-04-08config: Fix CB_ADD_LEN() to work as originally intended.Richard Mudgett
Fix a long standing bug in CB_ADD_LEN() behaving like CB_ADD(). ASTERISK-23546 #close Reported by: Walter Doekes ........ Merged revisions 411960 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 411961 from http://svn.asterisk.org/svn/asterisk/branches/11 ........ Merged revisions 411962 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@411963 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-03-21Remove a LOG_NOTICE from ast_config_engine_register.Sean Bright
There is enough indication from the CLI that we are loading a realtime engine as it is. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@410982 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-03-14Handle the return values of realtime updates and stores more accurately.Mark Michelson
Realtime backends' update and store callbacks return the number of rows affected, or -1 if there was a failure. There were a couple of issues: * The config API was treating 0 as a successful return, and positive values as a failure. Now the config API treats anything >= 0 as a success. * res_sorcery_realtime was treating 0 as a successful return from the store procedure, and any positive values as a failure. Now sorcery treats anything > 0 as a success. It still considers 0 a "failure" since there is no change to report to observers. Review: https://reviewboard.asterisk.org/r/3341 ........ Merged revisions 410592 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@410593 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-03-06sorcery: Create AST_SORCERY dialplan function.George Joseph
This patch creates the AST_SORCERY dialplan function which allows someone to retrieve any value from a sorcery-based config file. It's similar to AST_CONFIG. The creation of the function itself was fairly straightforward but it required changes to the underlying sorcery infrastructure that rippled into individual sorcery objects. The changes stemmed from inconsistencies in how sorcery created ast_variable objectsets from sorcery objects and the inconsistency in how individual objects used that feature especially when it came to parameters that can be specified multiple times like contact in aor and match in identify. You can read more here... http://lists.digium.com/pipermail/asterisk-dev/2014-February/065202.html So, what this patch does, besides actually creating the AST_SORCERY function, is the following... * Creates ast_variable_list_append which is a helper to append one ast_variable list to another. * Modifies the ast_sorcery_object_field_register functions to accept the already-defined sorcery_fields_handler callback. * Modifies ast_sorcery_objectset_create to accept a parameter indicating return type preference...a single ast_variable with all values concatenated or an ast_variable list with multiple entries. Also fixed a few bugs. * Modifies individual sorcery object implementations to use the new function definition of the ast_sorcery_object_field_register functions. * Modifies location.c and res_pjsip_endpoint_identifier_ip.c to implement sorcery_fields_handler handlers so they return multiple occurrences as an ast_variable_list. * Added a whole bunch of tests to test_sorcery. (closes issue ASTERISK-22537) Review: http://reviewboard.asterisk.org/r/3254/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@410042 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-03-05config: Fix inverted testKinsey Moore
The test of the result of the stat() call was inverted such that its output was only used if the call failed. This inverts the test so that the output of stat() is used correctly. This was causing full reloads on unchanged files. (closes issue ASTERISK-23383) Reported by: David Woolley ........ Merged revisions 409916 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 409917 from http://svn.asterisk.org/svn/asterisk/branches/11 ........ Merged revisions 409918 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@409919 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-03-05Corrected cross-platform stat nanosecond codeDavid M. Lee
When nanosecond time resolution was added for identifying config file changes, it didn't cover all of the myriad of ways that one might obtain nanosecond time resolution off of struct stat. Rather than complicate the #if even further figuring out one system from the next, this patch directly tests for the three struct members I know about today, and #ifdef's accordingly. Review: https://reviewboard.asterisk.org/r/3273/ ........ Merged revisions 409833 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 409834 from http://svn.asterisk.org/svn/asterisk/branches/11 ........ Merged revisions 409835 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@409836 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-02-20pjsip_cli: Fix memory leak in ast_sip_cli_print_sorcery_objectset.George Joseph
Fixed memory leaks in ast_sip_cli_print_sorcery_objectset and ast_variable_list_sort. (closes issue ASTERISK-23266) Review: http://reviewboard.asterisk.org/r/3200/ ........ Merged revisions 408520 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@408521 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-02-19config: Add file size and nanosecond resolution fields to the cached ↵Richard Mudgett
modified config file information. Repeatedly modifying config files and reloading too fast sometimes fails to reload the configuration because the cached modification timestamp has one second resolution. * Added file size and nanosecond resolution fields to the cached config file modification timestamp information. Now if the file size changes or the file system supports nanosecond resolution the modified file has a better chance of being detected for reload. * Added a missing unlock in an off-nominal code path. (closes issue AST-1303) Review: https://reviewboard.asterisk.org/r/3235/ ........ Merged revisions 408387 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 408388 from http://svn.asterisk.org/svn/asterisk/branches/11 ........ Merged revisions 408389 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@408390 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-02-12realtime: Fix ast_update2_realtime() on raspberry pi.Walter Doekes
The old code depended on undefined va_arg behaviour: calling a function twice with the same va_list parameter and expecting it to continue where it left off. The changed code behaves like the manpage says it should. Also added a bunch of early returns to trap errors (e.g. OOM) instead of crashing. The problem was found by Julian Lyndon-Smith. The deviant behaviour on the raspberry PI also uncovered another bug (fixed in r407875) in the res_config_pgsql.so driver. Reported by: jmls Tested by: jmls Review: https://reviewboard.asterisk.org/r/3201/ ........ Merged revisions 407968 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@407970 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-01-27Allow nested #includes in extconfig.confRussell Bryant
extconfig.conf was hard-coded to not allow nested includes for some reason. The code has been this way since a patch was merged for ASTERISK-3333 (revision 4889), which was a significant update to this code ("Merge config updates"). I can't figure out any good reason why this should be limited. This patch just removes the limit and uses the default nesting depth limit. Closes issue ASTERISK-17837 Review: https://reviewboard.asterisk.org/r/3159/ ........ Merged revisions 406643 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 406644 from http://svn.asterisk.org/svn/asterisk/branches/11 ........ Merged revisions 406645 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@406646 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-12-20res_pjsip: Add PJSIP CLI commandsMatthew Jordan
Implements the following cli commands: pjsip list aors pjsip list auths pjsip list channels pjsip list contacts pjsip list endpoints pjsip show aor(s) pjsip show auth(s) pjsip show channels pjsip show endpoint(s) Also... Minor modifications made to the AMI command implementations to facilitate reuse. New function ast_variable_list_sort added to config.c and config.h to implement variable list sorting. (issue ASTERISK-22610) patches: pjsip_cli_v2.patch uploaded by george.joseph (License 6322) ........ Merged revisions 404480 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@404507 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-11-02config: Allow ConfBridge DTMF menus to have '#' as the first digit.Richard Mudgett
ConfBridge allows custom DTMF menus to be created in the confbridge.conf file by assigning a DTMF key sequence to a sequence of actions as follows: DTMF-sequence = action,action... Unfortunately, the normal config file processing code interprets an initial '#' character as starting a directive such as #include. * Add the ability to escape the first non-blank character in a config line so the '#' character can be used without triggering the directive processing code. (closes issue AFS-2) (closes issue ASTERISK-22478) Reported by: Nicolas Tanski Patches: jira_asterisk_22478_v11.patch (license #5621) patch uploaded by rmudgett (modified) Review: https://reviewboard.asterisk.org/r/2969/ ........ Merged revisions 402407 from http://svn.asterisk.org/svn/asterisk/branches/11 ........ Merged revisions 402416 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@402417 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-08-30Fix various memory leaksKevin Harwell
main/config.c - cleanup cache fie includes res/res_security_log.c - unregister logger level channesl/chan_sip.c - cleanup io context and notify_types main/translator.c - cleanup at shutdown main/named_acl.c - cleanup cli commands main/indications.c - ast_get_indication_tone() unref default_tone_zone if used (closes issues ASTERISK-22378) Reported by: Corey Farrell Patches: config_shutdown.patch uploaded by coreyfarrell (license 5909) res_security_log.patch uploaded by coreyfarrell (license 5909) chan_sip-11.patch uploaded by coreyfarrell (license 5909) indications_refleak.patch uploaded by coreyfarrell (license 5909) named_acl-cli_unreg-trunk.patch uploaded by coreyfarrell (license 5909) translate_shutdown.patch uploaded by coreyfarrell (license 5909) ........ Merged revisions 398102 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 398103 from http://svn.asterisk.org/svn/asterisk/branches/11 ........ Merged revisions 398116 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@398124 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-04-27Add support for a realtime sorcery module.Joshua Colp
This change does the following: 1. Adds the sorcery realtime module 2. Adds unit tests for the sorcery realtime module 3. Changes the realtime core to use an ast_variable list instead of variadic arguments 4. Changes all realtime drivers to accept an ast_variable list Review: https://reviewboard.asterisk.org/r/2424/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@386731 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-04-26Clean up memory leak in config file on off nominal paths when glob is allowedMatthew Jordan
If a system allows for its usage, Asterisk will use glob to help parse Asterisk .conf files. The config file loading routine was leaking the memory allocated by the glob() routine when the config file was in an unmodified or invalid state. This patch properly calls globfree in those off nominal paths. (closes issue ASTERISK-21412) Reported by: Corey Farrell patches: config_glob_leak.patch uploaded by Corey Farrell (license 5909) ........ Merged revisions 386672 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 386677 from http://svn.asterisk.org/svn/asterisk/branches/11 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@386685 65c4cc65-6c06-0410-ace0-fbb531ad65f3