[asterisk-bugs] [JIRA] (ASTERISK-25868) Sorcery "append to category" should allow filters
Nick Repin (JIRA)
noreply at issues.asterisk.org
Sat Apr 23 05:53:57 CDT 2016
[ https://issues.asterisk.org/jira/browse/ASTERISK-25868?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=230365#comment-230365 ]
Nick Repin commented on ASTERISK-25868:
---------------------------------------
George,
Thank you for the prompt patch and sorry for the slow reply. I've reviewed the fix before testing it:
{noformat}
while ((cur = strsep(&c, ","))) {
if (!strcasecmp(cur, "!")) {
(*cat)->ignored = 1;
} else if (cur[0] == '+') {
char *filter = NULL;
if (cur[1] != ',') {
filter = &cur[1];
}
*cat = category_get_sep(cfg, catname, filter, '&');
{noformat}
It seems to me that "if (cur[1] != ',') {" is incorrect because the condition is always true. There will never be a comma in the token because it'd be zeroed out by strsep in "while ((cur = strsep(&c, ","))) {"
I haven't tried the fix because of that.
Thanks,
Nick
> Sorcery "append to category" should allow filters
> -------------------------------------------------
>
> Key: ASTERISK-25868
> URL: https://issues.asterisk.org/jira/browse/ASTERISK-25868
> Project: Asterisk
> Issue Type: Bug
> Security Level: None
> Components: Core/Configuration
> Affects Versions: 13.7.2, 13.8.0-rc1
> Environment: N/A
> Reporter: Nick Repin
> Assignee: Nick Repin
> Severity: Minor
>
> Below is a typical FreePBX config with trunk "Callcentric", for which I am trying to add custom variable "forbidden_retry_interval". In other words, there are multiple categories with the same name ("Callcentric") but different types ("endpoint" vs "registration"), and one of the categories ("registration") needs to be appended.
> ==pjsip.conf==
> {noformat}
> ...
> #include pjsip.endpoint.conf
> ...
> [Callcentric]
> type=endpoint
> ...
> ...
> #include pjsip.registration.conf
> [Callcentric]
> type=registration
> ...
> ...
> #include pjsip.registration_custom_post.conf
> [Callcentric](+)
> ;type=registration ; This doesn't help
> forbidden_retry_interval=600
> {noformat}
> ==end==
> The problem is, Sorcery searches for the first category named "Callcentric" and tries to append to it. In the above example, the first category is of type "endpoint" which does not accept "forbidden_retry_interval", so Sorcery displays an error. As long as Asterisk allows duplicate names for categories of different types, it should allow appending to a specific category, otherwise it's a bug. In case of FreePBX, the bug makes it impossible to add custom variables to pjsip.conf for SIP trunks and extensions.
> The simplest fix is to change main/config.c as follows:
> {noformat}
> --original code --
> } else if (!strcasecmp(cur, "+")) {
> *cat = ast_category_get(cfg, catname, NULL);
> --new code--
> } else if (cur[0] == '+') {
> const char* filter = cur[1] ? (cur+1) : NULL;
> *cat = ast_category_get(cfg, catname, filter);
> ---
> {noformat}
> The above will allow a custom filter like this:
> {noformat}
> [Callcentric](+type=registration)
> forbidden_retry_interval=600
> {noformat}
> A full-blown fix needs more coding to allow the use of commas in the filter (since parsing is currently done with "strsep"), e.g:
> {noformat}
> [Category]("+RegexValue1=RegexName1,RegexValue2=RegexName2",!,parent1,parent2)
> AppendedName=AppendedValue
> {noformat}
--
This message was sent by Atlassian JIRA
(v6.2#6252)
More information about the asterisk-bugs
mailing list