Affects Version/s: None
Target Release Version/s: None
SVN Revision Number:7380
[I have put reproducibility=always because the problem is deterministic,
and severity=major because it is an undetected configuration error which
may result in serious and hard-to-detect misbehaviours of the dialplan.
Then, your mileage may vary]
When using regcontext=xyz where xyz is the name of a context already
existing in extensions.conf (or probably some other config file as well),
asterisk will create two instances of the context xyz.
However the extension lookup code will stop the search after the
first instance, thus resulting in unexpected results.
A stripped down example is below, where the _5. entry is in exension.conf,
and the 551 entry is the result of regcontext=local-users regexten=551 in
sip.conf for a peer.
The source of the problem is that regcontext creates immediately
the empty context in the global list, whereas pbx_config later
builds contexts in a temporary list, then calling
ast_merge_contexts_and_delete() at line 1776 to merge the two lists.
Unfortunately the list merging only puts the local list in front of
the existing contexts, without checks for duplicates.
I have no idea on what is the proper fix, nor what is the behaviour
on a 'extension reload' or similar.
Surely, at the very least the code should produce a big warning message
in case we found one such misconfiguration (i.e. multiple contexts with
the same name), if merging the two is not possible or too expensive.
On a related topic: most functions that compare context names are
case-sensitive, however a few of them are not, e.g.
and possibly more.
Apart from the inconsistency that needs to be fixed, there is also
the issue that most of asterisk is case-insensitive when it comes to
names, so i think you should state clearly what is the policy
and why contexts are dealt with in a different way.
- ADDITIONAL INFORMATION ******
*CLI> show dialplan local-users
[ Context 'local-users' created by 'pbx_config' ]
'_5.' => 2. Dial(SIP/$
[ Context 'local-users' created by 'SIP' ]
'551' => 1. Noop(551) [SIP]
*CLI> dial 551@local-users
No such extension '551' in context 'local-users'