channels.c: core show channeltypes slicing

'core show channeltypes' type column is being sliced, resulting in incomplete
type names.

(closes issue ASTERISK-22919)
Reported by: outtolunc
Patches:
     svn_channel.c.format_15.diff.txt uploaded by outtolunc (license 5198)
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
func_strings: use memmove to prevent overlapping memory on strcpy

When calling REPLACE() with an empty replace-char argument, strcpy
is used to overwrite the the matching <find-char>.  However as the
src and dest arguments to strcpy must not overlap, it causes other
parts of the string to be overwritten with adjacent characters and
the result is mangled.  Patch replaces call to strcpy with memmove
and adds a test suite case for REPLACE.

(closes issue ASTERISK-22910)
Reported by: Gareth Palmer
Review: https://reviewboard.asterisk.org/r/3083/
Patches:
    func_strings.patch uploaded by Gareth Palmer (license 5169)
........

Merged revisions 404674 from http://svn.asterisk.org/svn/asterisk/branches/1.8
app_meetme: compiler warning

Fixed a compiler warning (errors in 'dev-mode') given by gcc version 4.8.1.
The one in app_meetme involved the 'sizeof-pointer-memaccess'
(see: http://gcc.gnu.org/gcc-4.8/porting_to.html) warning. Fixed so
it would no longer issue a warning and can compile again in 'dev-mode'.

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

Merged revisions 404742 from http://svn.asterisk.org/svn/asterisk/branches/1.8
chan_dahdi: dahdi show channels slices PRI channel dnid on output

dahdi show channels output slices the callerid (which is dnid copied over on
PRI channels). If the channel naming structures look like:

 'DAHDI/i1/1408409XXXX-6'

then the output slices 1408409XXXX down to 1408409XXX. This patch just opens
it up to 15 chars so you can see the whole thing.

(closes issue ASTERISK-22918)
Reported by: outtolunc
Patches:
     svn_chan_dahdi.c.format12_15.diff.txt uploaded by outtolunc (license 5198)
........

Merged revisions 404784 from http://svn.asterisk.org/svn/asterisk/branches/1.8
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
asterisk.c: suppress live_dangerously warning on rasterisk

Even since the fixes of AST-2013-007, Asterisk prints the following
warning on startup if the user decided to live dangerously:

  Privilege escalation protection disabled!
  See https://wiki.asterisk.org/wiki/x/1gKfAQ for more details.

This message is intended for the logs and interactive startup. No need
for it to appear on a remote console. This commit removes it from there.

(closes issue ASTERISK-23084)
Review: https://reviewboard.asterisk.org/r/3101/
........

Merged revisions 404861 from http://svn.asterisk.org/svn/asterisk/branches/1.8
Add the missing part of r400140

When the patch to add retry-on-forbidden-response was committed, part
of the patch for chan_sip was not committed which caused the feature to
be entirely nonfunctional. This corrects the code in question.

(closes issue ASTERISK-17138)
Review: https://reviewboard.asterisk.org/r/2874
........

Merged revisions 405033 from http://svn.asterisk.org/svn/asterisk/branches/1.8
UPGRADE: Add a note about non-functionality

Add a note that the "retry on 403 response to REGISTER" for chan_sip is
non-functional in the versions in which it was first introduced.
........

Merged revisions 405088 from http://svn.asterisk.org/svn/asterisk/branches/1.8
pbx_lua: Add support for Lua 5.2

This adds support for Lua 5.2 in pbx_lua which is available on newer
operating systems.

(closes issue ASTERISK-23011)
Review: https://reviewboard.asterisk.org/r/3075/
Reported by: George Joseph
Patch by: George Joseph
........

Merged revisions 405090 from http://svn.asterisk.org/svn/asterisk/branches/1.8
"Minimun" typo.
........

Merged revisions 405160 from http://svn.asterisk.org/svn/asterisk/branches/1.8
app_confbridge: Fix crash caused when waitmarked/marked users leave together

When waitmarked users join a ConfBridge, the conference state is transitioned
from EMPTY -> INACTIVE. In this state, the users are maintined in a waiting
users list. When a marked user joins, the ConfBridge conference transitions
from INACTIVE -> MULTI_MARKED, and all users are put onto the active list of
users. This process works correctly.

When the marked user leaves, if they are the last marked user, the MULTI_MARKED
state does the following:
(1) It plays back a message to the bridge stating that the leader has left the
    conference. This requires an unlocking of the bridge.
(2) It moves waitmarked users back to the waiting list
(3) It transitions to the appropriate state: in this case, INACTIVE

However, because it plays the prompt back to the bridge before moving the users
and before finishing the state transition, this creates a race condition: with
the bridge unlocked, waitmarked users who leave the conference (or are kicked
from it) can cause a state transition of the bridge to another state before
the conference is transitioned to the INACTIVE state. This causes the state
machine to get a bit wonky, often leading to a crash when the MULTI_MARKED state
attempts to conclude its processing.

This patch fixes this problem:
(1) It prevents kicked users from being kicked again. That's just a nicety.
(2) More importantly, it fixes the race condition by only playing the prompt
    once the state has transitioned correctly to INACTIVE. If waitmarked users
    sneak out during the prompt being played, no harm no foul.

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

(closes issue AST-1258)
Reported by: Steve Pitts
res_rtp_asterisk: Fails to resume WebRTC call from hold

In ast_rtp_ice_start if the ice session create check list failed, start check
was never initiated and ice_started was never set to true.  Upon re-entering
the function (for instance, [un]hold) it would try to create the check list
again with duplicate remote candidates.

Fixed so that if the create check list fails the necessary data structures
are properly re-initialized for any subsequent retries.

Note, it was decided to not stop ice support (by calling ast_rtp_ice_stop) on a
check list failure because it possible things might still work.  However, a
debug message was added to help with any future troubleshooting.

(closes issue ASTERISK-22911)
Reported by: Vytis Valentinavičius
Patches:
     works_on_my_machine.patch uploaded by xytis (license 6558)
Logging callid: Fix some sizeof() references per coding guidelines.
res/Makefile: alias dist-clean to distclean

A 'make distclean' is equivalent to 'make dist-clean' in the top most Makefile.
This patch updates the res/Makefile to recognize both distclean and dist-clean.
Note that this is needed for removing build.mak, which can run into problems
if the source file of Asterisk or its path is changed after build.mak is
generated.

(issue ASTERISK-22480)
Reported by: Matt Jordan
chan_sip: Hangup transferer/transferee when transfer to Parking fails

When performing a SIP transfer to a Park extension, if the Park fails, chan_sip
will currently not hang up either the transferer or the transfer target. This
results in the channels being orphaned with no thread to service frames,
resulting in stuck channels.

This patch immediately hangs up the two channels if a Park fails.

(closes issue ASTERISK-22834)
Reported by: rsw686
Tested by: rsw686

(closes issue ASTERISK-23047)
Reported by: Tommy Thompson
Tested by: Tommy Thomspon

Review: https://reviewboard.asterisk.org/r/3107
verbosity: Fix performance of console verbose messages.

The per console verbose level feature as previously implemented caused a
large performance penalty.  The fix required some minor incompatibilities
if the new rasterisk is used to connect to an earlier version.  If the new
rasterisk connects to an older Asterisk version then the root console
verbose level is always affected by the "core set verbose" command of the
remote console even though it may appear to only affect the current
console.  If an older version of rasterisk connects to the new version
then the "core set verbose" command will have no effect.

* Fixed the verbose performance by not generating a verbose message if
nothing is going to use it and then filtered any generated verbose
messages before actually sending them to the remote consoles.

* Split the "core set debug" and "core set verbose" CLI commands to remove
the per module verbose support that cannot work with the per console
verbose level.

* Added a silent option to the "core set verbose" command.

* Fixed "core set debug off" tab completion.

* Made "core show settings" list the current console verbosity in addition
to the root console verbosity.

* Changed the default verbose level of the 'verbose' setting in the
logger.conf [logfiles] section.  The default is now to once again follow
the current root console level.  As a result, using the AMI Command action
with "core set verbose" could again set the root console verbose level and
affect the verbose level logged.

(closes issue AST-1252)
Reported by: Guenther Kelleter

Review: https://reviewboard.asterisk.org/r/3114/
chan_sip: fix Local From tag on outbound register regression

In ASTERISK-12117, an improvement to insure consistant local from tags
on outbound registrations resulted in an undesirable behavior - caused
by leftover unexpired sip_pvt dialogs (with the previous cseq number),
resulting in many uncessary REGISTER requests.  Instead of significant
rework of transmit_register(), this change deletes the dialogs after a
200 OK response indiciating a successful registration, keeping the old
dialogs from interfering with normal operation.

(closes issue ASTERISK-22946)
Reported by: Stephan Eisvogel
Review: https://reviewboard.asterisk.org/r/3109/
........

Merged revisions 405433 from http://svn.asterisk.org/svn/asterisk/branches/1.8
chan_sip: No BYE message sent after INVITE with Replaces

Setting channel state DOWN is an unnecessary step that was
only being done in handle_invite_replaces().  This changes
that by removing the call and reducing locking.

(closes issue ASTERISK-23010)
Reported by: Ryan Tilton
Review: https://reviewboard.asterisk.org/r/3116/
........

Merged revisions 405486 from http://svn.asterisk.org/svn/asterisk/branches/1.8
cel_manager: Don't crash if configuration file is invalid.

The cel_manager module did not properly handle the case where the
configuration file was invalid. The module will now output a warning
message and disable itself if this occurs.

Reported by: Bryan Walters
........

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