Commit Graph

37 Commits

Author SHA1 Message Date
Alexander Traud 1230369b71 progdocs: Remove outdated references in doxyref.h.
ASTERISK-29773

Change-Id: Ica93160d9158cc0e80c5fda829b80d1b49a6b9b9
2021-11-29 11:12:40 -06:00
Christoph Moench-Tegeder 52ade18420 cdr_pgsql cel_pgsql res_config_pgsql: compatibility with PostgreSQL 12
PostgreSQL 12 finally removed column adsrc from table pg_catalog.pg_attrdef
(column default values), which has been deprecated since version 8.0.
Since then, the official/correct/supported way to retrieve the column
default value from the catalog is function pg_catalog.pg_get_expr().

This change breaks compatibility with pre-8.0 PostgreSQL servers,
but has reached end-of-support more than a decade ago.
cdr_pgsql and res_config_pgsql still have support for pre-7.3
servers, but cleaning that up is perhaps a topic for a major release,
not this bugfix.

ASTERISK-28571

Change-Id: I834cb3addf1937e19e87ede140bdd16cea531ebe
2019-10-14 05:08:02 -05:00
Corey Farrell 572a508ef2 loader: Convert reload_classes to built-in modules.
* 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-03-14 05:20:12 -04:00
Corey Farrell c8a521b6c8 Replace direct checks of option_debug with DEBUG_ATLEAST macro.
Checking option_debug directly is incorrect as it ignores file/module
specific debug settings.  This system-wide change replaces nearly all
direct checks for option_debug with the DEBUG_ATLEAST macro.

Change-Id: Ic342d4799a945dbc40ac085ac142681094a4ebf0
2018-03-07 16:03:01 -06:00
Sean Bright c537f99488 cdr_pgsql: Fix buffer overflow calling libpq
Implement the same buffer size checking done in cel_pgsql.

ASTERISK-26896 #close
Reported by: twisted

Change-Id: Iaacfa1f1de7cb1e9414d121850d2d8c2888f3f48
2017-03-30 17:48:42 -05:00
Josh Roberson f66edcb8b0 cel_pgsql.c: Fix buffer overflow calling libpq
PQEscapeStringConn() expects the buffer passed in to be an
adequitely sized buffer to write out the escaped SQL value string
into.  It is possible, for large values (such as large values to
Dial with a lot of devices) to have more than our 512+1 byte
allocation and thus cause libpq to create a buffer overrun.

glibc will nicely ABRT asterisk for you, citing a stack smash.

Let's only allocate it to be as large as needed:
If we have a value, then (strlen(value) * 2) + 1 (as recommended
by libpq), and if we have none, just one byte to hold our null
will do.

ASTERISK-26896 #close

Change-Id: If611c734292618ed68dde17816d09dd16667dea2
2017-03-29 07:54:14 -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
Rodrigo Ramírez Norambuena 99aa7cb26e dr_adaptive_odbc.c, cel_odbc.c, cel_pgsql.c: REFACTOR Macro LENGTHEN_BUF
Remove repeated code on macro of assigned buffer to SQL vars

Change-Id: Icb19ad013124498e172ea1d0b29ccd0ed17deef0
2015-09-18 12:51:59 -03:00
Joshua Colp 1b7febe18f Merge "cel/cel_pgsql.c: Use the 'SEP' macro when appending a column name" 2015-05-14 05:02:14 -05:00
Rodrigo Ramírez Norambuena 46bb8449e8 cel/cel_pgsql.c: Use the 'SEP' macro when appending a column name
When appending a column name to the sql buffer, the predicate, "if first is
non-null, use empty string; else, use comma", is identical to the 'SEP' macro
definition. Since they are the same, this patch replaces the redundant
predicate statement with the 'SEP' macro.

Change-Id: Ib8b6138b06a48381723108a05ab8752cb8700509
2015-05-13 15:49:37 -05:00
Joshua Colp 4505f5e676 Merge "cdr_pgsql, cel_pgsql: Store maximum buffer size to prevent reallocation" 2015-05-13 15:17:48 -05:00
Rodrigo Ramírez Norambuena e6daafb8a6 cdr_pgsql, cel_pgsql: Store maximum buffer size to prevent reallocation
The code previously used a fixed size of 512 for the SQL
queries. Depending on the size this may require it to grow.

This change makes it so if the buffer size does grow the size
is stored and next time the buffer will be large enough.

Change-Id: I55385899f1c06dee47e4274c2d21538037b2d895
2015-05-12 05:11:39 -05:00
Rodrigo Ramírez Norambuena cb79b8ab80 cel_pgsql: Add support for setting schema
Add feature to set optional schema parameter on configuration file via
'schema' setting.

Fix query to get columns from table while considering schema. If in
the database there exists two tables with same name in distinct schemas
it will return an error when inserting record.

ASTERISK-24967 #close

Change-Id: I691fd2cbc277fcba10e615f5884f8de5d8152f2c
2015-05-05 07:59:12 -04:00
Rodrigo Ramírez Norambuena 33a319ae73 cel_pgsql: Fix name string for log on unable allocate memory.
The LOG_ERROR has reference to CDR instead of CEL  for LENGTHEN_BUF1 and
LENGTHEN_BUF2.

ASTERISK-24965 #close
Reported by: Rodrigo Ramirez Norambuena

Change-Id: Icc818697d7d66d34bfe3048cdd15ca2b06c89744
2015-04-15 06:17:34 -05: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
Matthew Jordan 016fba12e2 cel_pgsl: Add support for GMT timestamps
This patch adds a new option to cel_pgsl, "usegmtime", which causes timestamps
to be logged in GMT.

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

ASTERISK-23186 #close
Reported by: Rodrigo Ramirez Norambuena
patches:
  cel_pgsql.c_add_usegmtime2.patch submitted by Rodrigo Ramirez Norambuena (License 6577)



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@434284 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-04-08 11:35:53 +00: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
Matthew Jordan 03e9c598e5 cel_pgsql, cdr_pgsql, res_config_pgsql: Add PostgreSQL application_name support
This patch adds support for the PostgreSQL application_name connection setting.
When the appropriate PostgreSQL module's configuration is set with an
application name, the name will be passed to PostgreSQL on connection and
displayed in the database's pg_stat_activity view, as well as in CSV logs. This
aids in managing which applications/servers are connected to a PostgreSQL
database, as well as tracing the activity of those connections.

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

ASTERISK-23737 #close
Reported by: Gergely Domodi
patches:
  pgsql_application_name.patch uploaded by Gergely Domodi (License 6610)


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@418755 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-07-16 13:55:36 +00:00
Matthew Jordan fb5690ce4b Logger/CLI/etc.: Fix some aesthetic issues; reduce chatty verbose messages
This patch addresses some aesthetic issues in Asterisk. These are all just
minor tweaks to improve the look of the CLI when used in a variety of
settings. Specifically:
 * A number of chatty verbose messages were removed or demoted to DEBUG
   messages. Verbose messages with a verbosity level of 5 or higher were -
   if kept as verbose messages - demoted to level 4. Several messages
   that were emitted at verbose level 3 were demoted to 4, as announcement
   of dialplan applications being executed occur at level 3 (and so the
   effects of those applications should generally be less).
 * Some verbose messages that only appear when their respective 'debug'
   options are enabled were bumped up to always be displayed.
 * Prefix/timestamping of verbose messages were moved to the verboser
   handlers. This was done to prevent duplication of prefixes when the
   timestamp option (-T) is used with the CLI.
 * Verbose magic is removed from messages before being emitted to
   non-verboser handlers. This prevents the magic in multi-line verbose
   messages (such as SIP debug traces or the output of DumpChan) from
   being written to files.
 * _Slightly_ better support for the "light background" option (-W) was
   added. This includes using ast_term_quit in the output of XML
   documentation help, as well as changing the "Asterisk Ready" prompt to
   bright green on the default background (which stands a better chance of
   being displayed properly than bright white).

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



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@414798 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-05-28 22:54:12 +00:00
Kinsey Moore abd3e4040b Allow Asterisk to compile under GCC 4.10
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-05-09 22:49:26 +00:00
Kevin Harwell 2f62394fb5 cel_pgsql: module not correctly reloading
Upon reload the module unconditionally "unloaded" the module (freeing memory
and setting pointers to NULL) and then when attempting a "load" if the config
file had not changed then nothing would be reinitialized.

By moving the "unload" to occur conditionally (reload only) after an attempted
configuration load, but before module "loading" alleviates the issue. The module
now loads/unloads/reloads correctly.

(closes issue ASTERISK-22871)
Reported by: Matteo
........

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

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

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


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@404860 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-01-03 22:00:42 +00:00
Kevin Harwell bb30b22419 cel_pgsql: deadlock on unload and core_event_dispatcher
A deadlock can happen between a thread unloading or reloading the cel_pgsql
module and the core_event_dispatcher taskprocessor thread. Description of
what is happening:

Thread 1 (for example, a netconsole thread):

    a "module reload cel_pgsql" is launched
    the thread enter the "my_unload_module" function (cel_pgsql.c)
    the thread acquire the write lock on psql_columns
    the thread enter the "ast_event_unsubscribe" function (event.c)
    the thread try to acquire the write lock on ast_event_subs[sub->type]

Thread 2 (core_event_dispatcher taskprocessor thread):

    the taskprocessor pop a CEL event
    the thread enter the "handle_event" function (event.c)
    the thread acquire the read lock on ast_event_subs[sub->type]
    the thread callback the "pgsql_log" function (cel_pgsql.c), since it's a subscriber of CEL events
    the thread try to acquire a read lock on psql_columns

(closes issue ASTERISK-22854)
Reported by: Etienne Lessard
Patches:
     cel_pgsql_fix_deadlock_event.patch uploaded by hexanol (license 6394)
........

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

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

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


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@404606 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-12-31 21:39:45 +00:00
Kinsey Moore d7f1f31270 Refactor CEL to avoid using the event system core
This removes usage of the event system for CEL backend data
distribution and strips unused pieces out of the event system.

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


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@396888 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-08-17 14:46:44 +00:00
Andrew Latham 6f61cb50c5 Doxygen Updates - janitor work
Doxygen updates including mistakes, misspellings, missing parameters, updates for Doxygen style.  Some missing txt file links are removed but their content or essense will be included in some later updates.  A majority of the txt files were removed in the 1.6 era but never noted. The HR and EXTREF are simple changes that make the documentation more compatable with more versions of Doxygen.

Further updates coming.

(issue ASTERISK-20259)


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@373330 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-09-21 17:14:59 +00:00
Matthew Jordan d88f91c8d0 Fix memory leak when CEL is successfully written to PostgreSQL database
PQClear is not called when the result object of a call to PQExec has a
status of PGRES_COMMAND_OK.  Interestingly enough, the off nominal case was
handled properly, so this memory leak only occurred when CEL records were
successfully written.

This patch properly clears the result in the nominal code path.

(closes issue ASTERISK-19991)
Reported by: Etienne Lessard
Tested by: Etienne Lessard
patches:
  mem_leak_cel_pgsql.patch uploaded by Etienne Lessard (license #6394)
........

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

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

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


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@372176 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-09-05 02:26:54 +00:00
Richard Mudgett 797d633139 Remove inconsistency in CEL eventtype for user defined events.
The CEL eventtype field for ODBC and PGSQL backends should be USER_DEFINED
instead of the user defined event name supplied by the CELGenUserEvent
application.  If the field is output as a number, the user defined name
does not have a value and is always output as 21 for USER_DEFINED and the
userdeftype field would be required to supply the user defined name.

The following CEL backends (cel_odbc, cel_pgsql, cel_custom, cel_manager,
and cel_sqlite3_custom) can be independently configured to remove this
inconsistency.

* Allows cel_manager, cel_custom, and cel_sqlite3_custom to behave the
same way.

(closes issue ASTERISK-17189)
Reported by: Bryant Zimmerman

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


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@353648 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-02-01 17:42:15 +00:00
Matthew Jordan 262ea69764 Fix for memory leaks / cleanup in cel_pgsql
There were a number of issues in cel_pgsql's pgsql_log method:
* If either sql or sql2 could not be allocated, the method would return while
the pgsql_lock was still locked
* If the execution of the log statement succeeded, the sql and sql2 structs
were never free'd
* Reconnection successes were logged as ERRORs.  In general, the severity of
several logging statements was reduced

(closes issue ASTERISK-18879)
Reported by: Niolas Bouliane
Tested by: Matt Jordan

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

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

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


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@348890 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-12-22 22:39:29 +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
Russell Bryant 2dfb427540 Add CEL extra field to cel_pgsql.
(closes issue #18462)
Reported by: joscas
Patches:
      bug_18462.diff uploaded by snuffy (license 35)
      cel_pgsql.conf.sample.issue18462.patch uploaded by joscas (license 1180)


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@317482 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-05-05 23:08:05 +00:00
Russell Bryant f0f5e237bf Merged revisions 317474 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8

........
  r317474 | russell | 2011-05-05 17:36:33 -0500 (Thu, 05 May 2011) | 2 lines
  
  Fix more "set but unused" warnings.
........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@317475 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-05-05 22:44:52 +00:00
Brett Bryant f50b132064 Merged revisions 305603 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8

........
  r305603 | bbryant | 2011-02-01 14:23:20 -0500 (Tue, 01 Feb 2011) | 4 lines
  
  Add a possible solution to a customer problem with reloading cel_pgsql.so
  quickly.
........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@305604 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-02-01 19:27:23 +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
Tim Ringenbach e19a6c248f Fix documentation for pgsql cel and cdr, and slightly improve pgsql_cel.
Change the documented pgsql schema to use "timestamp" instead of "time",
as the latter is only a time without a date.

Added some missing columns for cel's pgsql schema, and corrected spelling
on some others. Updated cel's uniqueid size to be the same as the cdr.
Added id column to cel's pgsql schema and updated code to allow unknown
columns to get their default value instead of forcing 0 or empty string.

Added microseconds to the timestamp cel logs to pgsql.

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


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@276349 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-07-14 16:09:11 +00:00
Russell Bryant 3da9f8ed19 Resolve more compiler warnings on FreeBSD.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@253540 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-03-20 12:03:07 +00:00
Olle Johansson fff998bf41 Use extref for doxygen references to external libraries (in this case PostgreSQL)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@222614 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-10-07 18:55:25 +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
Russell Bryant 0264eef115 Merge the new Channel Event Logging (CEL) subsystem.
CEL is the new system for logging channel events.  This was inspired after
facing many problems trying to represent what is possible to happen to a call
in Asterisk using CDR records.  For more information on CEL, see the built in
HTML or PDF documentation generated from the files in doc/tex/.

Many thanks to Steve Murphy (murf) and Brian Degenhardt (bmd) for their hard
work developing this code.  Also, thanks to Matt Nicholson (mnicholson) and
Sean Bright (seanbright) for their assistance in the final push to get this
code ready for Asterisk trunk.

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


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@203638 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-06-26 15:28:53 +00:00