Commit Graph

36 Commits

Author SHA1 Message Date
Sean Bright fd0ca1c3f9 Remove as much trailing whitespace as possible.
Change-Id: I873c1c6d00f447269bd841494459efccdd2c19c0
2017-12-22 09:23:22 -05:00
Sean Bright 6e6c96d713 realtime: Centralize some common realtime backend code
All of the realtime backends create artificial ast_categorys to pass
back into the core as query results. These categories have no filename
or line number information associated with them and the backends differ
slightly on how they create them. So create a couple helper macros to
help make things more consistent.

Also updated the call sites to remove redundant error messages about
memory allocation failure.

Note that res_config_ldap sets the category filename to the 'table name'
but that is not read by anything in the core, so I've dropped it.

Change-Id: I3a1fd91e0c807dea1ce3b643b0a6fe5be9002897
2017-02-21 10:53:17 -06:00
Sean Bright e93f2a5142 realtime: Fix LIKE escaping in SQL backends
The realtime framework allows for components to look up values using a
LIKE clause with similar syntax to SQL's. pbx_realtime uses this
functionality to search for pattern matching extensions that start with
an underscore (_).

When passing an underscore to SQL's LIKE clause, it will be interpreted
as a wildcard matching a single character and therefore needs to be
escaped. It is (for better or for worse) the responsibility of the
component that is querying realtime to escape it with a backslash before
passing it in. Some RDBMs support escape characters by default, but the
SQL92 standard explicitly says that there are no escape characters
unless they are specified with an ESCAPE clause, e.g.

	SELECT * FROM table WHERE column LIKE '\_%' ESCAPE '\'

This patch instructs 3 backends - res_config_mysql, res_config_pgsql,
and res_config_sqlite3 - to use the ESCAPE clause where appropriate.

Looking through documentation and source tarballs, I was able to
determine that the ESCAPE clause is supported in:

MySQL 5.0.15   (released 2005-10-22 - earliest version available from
                archives)
PostgreSQL 7.1 (released 2001-04-13)
SQLite 3.1.0   (released 2005-01-21)

The versions of the relevant libraries that we depend on to access MySQL
and PostgreSQL will not work on versions that old, and I've added an
explicit check in res_config_sqlite3 to only use the ESCAPE clause when
we have a sufficiently new version of SQLite3.

res_config_odbc already handles the escape characters appropriately, so
no changes were required there.

ASTERISK-15858 #close
Reported by: Humberto Figuera

ASTERISK-26057 #close
Reported by: Stepan

Change-Id: I93117fbb874189ae819f4a31222df7c82cd20efa
2017-02-16 12:59:50 -06:00
Corey Farrell a6e5bae3ef Remove ASTERISK_REGISTER_FILE.
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-10-27 09:53:55 -04:00
George Joseph 3b3d06884c res_config_mysql: Fix several issues related to recent table changes
Unlike any of the other database drivers, res_config_mysql checks that
the table definition matches the requirements for every insert and
update statement.  Since all requirements are forced to 'char', any
column that isn't a char, like ps_contacts' expiration_time,
qualify_timeout, etc., will throw a warning.  It's kinda harmless but
very misleading.  Since no other driver does those checks on insert
or update, they've been removed from res_config_mysql.  Also, all
the logic that actually attempted to ALTER the table to fix the issue
has been removed.  With the move to alembic, the auto-alter
functionality is not only unnecessary, it's also dangerous.

The other issue is that res_config_mysql calls the mysql_insert_id
function inside store_mysql.  Presumably the intention was to return
the number of rows inserted DESPITE A NOTE IN THE CODE THAT THE VALUE
IS NON_PORTABLE AND MAY CHANGE.  That value is then returned to
config realtime as the number of rows inserted.  Guess what?  The value
changed.  It now only returns the number of rows inserted if there's an
auto increment column on the table, which ps_contacts doesn't have.
Otherwise it returns 0.  So now, the insert worked but we tell config
realtime and sorcery that no rows were inserted.  That call to
mysql_insert_id was removed and we now always return 1 if the insert
succeeded.  We're only inserting 1 row at a time anyway.  If the insert
fails, we still return -1.

ASTERISK-26362 #close
Reported-by: Carlos Chavez

Change-Id: I83ce633efdb477b03c8399946994ee16fefceaf4
2016-10-12 16:49:01 -05:00
George Joseph 40da6434c1 build_system: Fix some warnings highlighted by clang
Fix some warnings found with clang.

Change-Id: I5195b6189b148c2ee3ed4a19d015a6d4ef3e77bd
2016-02-01 19:22:40 -06:00
Joshua Colp 35ff01823b Merge "AST_MODULE_INFO: Format corrections to the usages of AST_MODULE_INFO macro." 2015-05-14 05:03:43 -05:00
Rodrigo Ramírez Norambuena eec010829a AST_MODULE_INFO: Format corrections to the usages of AST_MODULE_INFO macro.
Change-Id: Icf88f9f861c6b2a16e5f626ff25795218a6f2723
2015-05-13 16:34:23 -05:00
Alexandre Fournier 1503d0c14c res_config_mysql: Fix broken column type checking
MySQL configuration engine contains a bug in require_mysql(). This
function is used for column type checking in tables. This bug only
affects DATETIME, DATE and FLOAT types.

It came from mixing the first condition (switch-case-like
if/then/else), to check the expected column type, with the second
condition, to check the actual column type against the expected column
type. Both conditions must be checked separately in order to avoid the
execution of the wrong block.

ASTERISK-18252 #comment This patch might fix the issue
Reported by: Gareth Blades

ASTERISK-25041 #close
Reported by: Alexandre Fournier
Tested by: Alexandre Fournier

Change-Id: I0b8bf7e68ab938be8e6525a249260cb648cb0bfa
2015-05-09 01:01:26 +02:00
Matt Jordan 4a58261694 git migration: Refactor the ASTERISK_FILE_VERSION macro
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-13 03:48:57 -04:00
Mark Michelson dcf1ad14da Add module support level to ast_module_info structure. Print it in CLI "module show" .
ASTERISK-23919 #close
Reported by Malcolm Davenport

Review: https://reviewboard.asterisk.org/r/3802



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@419592 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-07-25 16:47:17 +00:00
Michael L. Young 4e86602921 res_config_mysql: Fix Setting The Column Name Incorrectly
When support for a realtime sorcery module was added in revision 386731, the
wrong property was accidentally used for setting the column name to be updated
in the database table.  This patch fixes the typo.

(closes issue ASTERISK-23177)
Reported by: Denis
Tested by: Denis
Patches:
    asterisk-23177-use-field-name.diff by Michael L. Young (license 5026)
........

Merged revisions 406311 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@406312 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-01-23 22:56:54 +00:00
Joshua Colp 02be50b1ac Add support for a realtime sorcery module.
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-27 12:01:29 +00:00
Michael L. Young ba7ee9bfc9 Fix Sorting Order For Parking Lots Stored In Static Realtime
When retrieving the parking lots from a MySQL database table, the current order
is "filename, cat_metric desc, var_metric asc, category".  If there are multiple
parking lots with the same cat_metric but different categories, everything is
being sorted on cat_metric first resulting in errors when loading the parking
lots.

This patch fixes the problem by sorting on the category field first, then the
cat_metric field.

(closes issue ASTERISK-21035)
Reported by: Alex Epshteyn
Patches:
  asterisk-21035-orderby.diff Michael L. Young (license 5026)
........

Merged revisions 382942 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 382943 from http://svn.asterisk.org/svn/asterisk/branches/11


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@382954 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-03-12 21:19:39 +00:00
Matthew Jordan 9ad3e219c4 Clean up use of va_end/va_args in res_config_mysql
There were several problems using variadic argument macros in res_config_mysql.
 * Improper use of va_end. Multiple calls to va_end were possible resulting in
   an unbalanced matching of va_start/va_end.
 * Calls to va_arg after a possible encounter of a SENTINEL value.

This patch corrects those errors.

(closes issue ASTERISK-19451)
Reported by: wdoekes
patches:
  ASTERISK-19451-1.8--2.diff uploaded by wdoekes (License 5674)
........

Merged revisions 382021 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 382022 from http://svn.asterisk.org/svn/asterisk/branches/11


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@382023 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-02-25 12:51:24 +00:00
Richard Mudgett ebcc4e3da1 Remove unnecessary channel module references.
* Removed call to ast_module_user_hangup_all() in res_config_mysql.c since
it is effectively a noop.  No channels can attach a reference to that
module.

* Removed call to ast_module_user_hangup_all() in app_celgenuserevent.c.
The caller of unload_module() has already called it.

* Removed redundant channel module references in pbx_dundi.c.  The
registered dialplan function callback dispatchers for the read/read2/write
callbacks already reference the module before calling.

* pbx_dundi: Moved unregistering CLI commands, DUNDi switch, and dialplan
functions to the first thing the unload_module() does.  This will reduce
the chance of new channels using DUNDi services while the module is being
torn down.
........

Merged revisions 376657 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 376658 from http://svn.asterisk.org/svn/asterisk/branches/10
........

Merged revisions 376659 from http://svn.asterisk.org/svn/asterisk/branches/11


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@376660 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-11-27 20:39:51 +00:00
Kinsey Moore 9b16c8b0f6 Clean up and ensure proper usage of alloca()
This replaces all calls to alloca() with ast_alloca() which calls gcc's
__builtin_alloca() to avoid BSD semantics and removes all NULL checks
on memory allocated via ast_alloca() and ast_strdupa().

(closes issue ASTERISK-20125)
Review: https://reviewboard.asterisk.org/r/2032/
Patch-by: Walter Doekes (wdoekes)
........

Merged revisions 370642 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 370643 from http://svn.asterisk.org/svn/asterisk/branches/10


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@370655 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-07-31 20:21:43 +00:00
Tilghman Lesher a78b0af5ea Re-commit the verbose branch.
This change permits each verbose destination (consoles, logger) to have its
own concept of what the verbosity level is.  The big feature here is that
the logger will now be able to capture a particular verbosity level without
condemning each console to need to suffer that level of verbosity.
Additionally, a stray 'core set verbose' will no longer change what will go
to the log.

Review:  https://reviewboard.asterisk.org/r/1599/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@355413 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-02-14 20:27:16 +00:00
Tilghman Lesher 77b670c4ab Allow each logging destination and console to have its own notion of the verbosity level.
Review: https://reviewboard.asterisk.org/r/1599


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@346391 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-11-29 18:43:16 +00:00
Leif Madsen a525edea59 Merged revisions 328247 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.10

................
  r328247 | lmadsen | 2011-07-14 16:25:31 -0400 (Thu, 14 Jul 2011) | 14 lines
  
  Merged revisions 328209 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/branches/1.8
  
  ........
    r328209 | lmadsen | 2011-07-14 16:13:06 -0400 (Thu, 14 Jul 2011) | 6 lines
    
    Introduce <support_level> tags in MODULEINFO.
    This change introduces MODULEINFO into many modules in Asterisk in order to show
    the community support level for those modules. This is used by changes committed
    to menuselect by Russell Bryant recently (r917 in menuselect). More information about
    the support level types and what they mean is available on the wiki at
    https://wiki.asterisk.org/wiki/display/AST/Asterisk+Module+Support+States
  ........
................


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@328259 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-07-14 20:28:54 +00:00
Sean Bright 41bfc0c9e0 Merged revisions 317370 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8

........
  r317370 | seanbright | 2011-05-05 16:25:52 -0400 (Thu, 05 May 2011) | 10 lines
  
  Don't duplicate our data on the stack and just use the MYSQL_ROW directly.
  
  With large result sets we were blowing out the stack.
  
  (closes issue #19090)
  Reported by: mickecarlsson
  Patches:
        issue19090_trunk_svn.patch uploaded by seanbright (license 71)
  Tested by: mickecarlsson
........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@317377 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-05-05 20:27:25 +00:00
Tilghman Lesher fbe3c85dee Merged revisions 316429 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8

........
  r316429 | tilghman | 2011-05-03 19:12:25 -0500 (Tue, 03 May 2011) | 7 lines
  
  Escape column names in case they contain illegal characters ('-') or reserved words.
  
  (closes issue #19063)
   Reported by: festr
   Patches: 
         patch uploaded by festr (license 443)
........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@316430 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-05-04 00:13:23 +00:00
Tilghman Lesher a1aa18b8ac Merged revisions 300798 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8

........
  r300798 | tilghman | 2011-01-06 00:28:18 -0600 (Thu, 06 Jan 2011) | 8 lines
  
  Don't destroy handle not created by use (because the caller will).
  
  (closes issue #18526)
   Reported by: makoto
   Patches: 
         res-config-mysql-include.patch uploaded by makoto (license 38)
   Tested by: makoto
........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@300799 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-01-06 06:29:08 +00:00
Tilghman Lesher 2f79916fa8 Merged revisions 299583 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8

........
  r299583 | tilghman | 2010-12-24 11:58:30 -0600 (Fri, 24 Dec 2010) | 7 lines
  
  Reset 'first' variable after usage.
  
  (closes issue #18525)
   Reported by: makoto
   Patches: 
         res-config-mysql-update2.patch uploaded by makoto (license 38)
........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@299584 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-12-24 17:59:23 +00:00
Erin Spiceland 89c3bd4d13 Add option to res_config_mysql and app_mysql to specify a character set that
MySQL should use.
 (closes issue 17948)
 Reported by qmax.


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@290939 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-10-08 16:27:31 +00:00
Jason Parker 7dd1392fba Merged revisions 283882 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8

................
  r283882 | qwell | 2010-08-27 15:31:55 -0500 (Fri, 27 Aug 2010) | 22 lines
  
  Merged revisions 283881 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/branches/1.6.2
  
  ................
    r283881 | qwell | 2010-08-27 15:30:27 -0500 (Fri, 27 Aug 2010) | 15 lines
    
    Merged revisions 283880 via svnmerge from 
    https://origsvn.digium.com/svn/asterisk/branches/1.4
    
    ........
      r283880 | qwell | 2010-08-27 15:29:11 -0500 (Fri, 27 Aug 2010) | 8 lines
      
      Fix issue with decoding ^-escaped characters in realtime.
      
      (closes issue #17790)
      Reported by: denzs
      Patches: 
            17790-chunky.diff uploaded by qwell (license 4)
      Tested by: qwell, denzs
    ........
  ................
................


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@283883 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-08-27 20:32:21 +00:00
Tilghman Lesher b4e18d5660 Add load priority order, such that preload becomes unnecessary in most cases
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@278132 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-07-20 19:35:02 +00:00
Tilghman Lesher a7c92fad28 Merged revisions 277568 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
  r277568 | tilghman | 2010-07-16 16:54:29 -0500 (Fri, 16 Jul 2010) | 8 lines
  
  Since we split values at the semicolon, we should store values with a semicolon as an encoded value.
  
  (closes issue #17369)
   Reported by: gkservice
   Patches: 
         20100625__issue17369.diff.txt uploaded by tilghman (license 14)
   Tested by: tilghman
........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@277773 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-07-17 17:39:28 +00:00
Tilghman Lesher 80cb88e1f8 Typo pointed out on #asterisk-dev (by atis_work)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@233732 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-12-08 18:40:19 +00:00
Tilghman Lesher 494647fbe7 Update the mysql driver to always return NULL columns, as this is needed for the realtime API to work correctly.
(closes issue #16138)
 Reported by: sohosys
 Patches: 
       20091029__issue16138.diff.txt uploaded by tilghman (license 14)
 Tested by: sohosys


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@233050 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-12-04 16:08:58 +00:00
Tilghman Lesher e25ca31589 Select uncommented lines, not commented ones.
(closes issue #15746)
 Reported by: makoto


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@213248 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-08-20 15:29:53 +00:00
Tilghman Lesher ed7bc8d72f Clarify some of the error messages, to help upgraders.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@212883 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-08-18 19:49:52 +00:00
Tilghman Lesher 642bec4d6f AST-2009-005
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@211539 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-08-10 19:20:57 +00:00
Tilghman Lesher 257e41e85b Merged revisions 981 via svnmerge from
https://origsvn.digium.com/svn/asterisk-addons/branches/1.4

........
  r981 | tilghman | 2009-07-06 16:30:13 -0500 (Mon, 06 Jul 2009) | 7 lines
  
  Don't reset reconnect time, unless a reconnect really occurred.
  (closes issue #15375)
   Reported by: kowalma
   Patches: 
         20090628__issue15375.diff.txt uploaded by tilghman (license 14)
   Tested by: kowalma, jacco
........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@204986 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-07-06 21:37:39 +00:00
Russell Bryant d806ae0da0 Rename res_mysql.conf to res_config_mysql.conf, make module support both
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@204422 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-06-30 17:15:09 +00:00
Russell Bryant c511a26749 Move Asterisk-addons modules into the main Asterisk source tree.
Someone asked yesterday, "is there a good reason why we can't just put these
modules in Asterisk?".  After a brief discussion, as long as the modules are
clearly set aside in their own directory and not enabled by default, it is
perfectly fine.

For more information about why a module goes in addons, see README-addons.txt.

chan_ooh323 does not currently compile as it is behind some trunk API updates.
However, it will not build by default, so it should be okay for now.


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@204413 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-06-30 16:40:38 +00:00