[asterisk-bugs] [JIRA] (ASTERISK-25868) Sorcery "append to category" should allow filters
Nick Repin (JIRA)
noreply at issues.asterisk.org
Sun Mar 27 06:10:56 CDT 2016
Nick Repin created ASTERISK-25868:
-------------------------------------
Summary: 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/Sorcery
Affects Versions: 13.7.2
Environment: N/A
Reporter: Nick Repin
Severity: Blocker
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==
...
#include pjsip.endpoint.conf
...
[Callcentric]
type=endpoint
...
...
#include pjsip.registration.conf
[Callcentric]
type=registration
...
...
#include pjsip.registration_custom_post.conf
[Trunk](+)
;type=registration ; This doesn't help
forbidden_retry_interval=600
==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 allow duplicate names for categories of different types, it should allow appending to a specific category, otherwise it's a bug.
The simplest fix is to modify main/config.c as follows:
--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);
---
The above will allow a custom filter like this:
[Callcentric](+type=registration)
forbidden_retry_interval=600
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:
[Category]("+RegexValue1=RegexName1,RegexValue2=RegexName2",!,parent1,parent2)
AppendedName=AppendedValue
--
This message was sent by Atlassian JIRA
(v6.2#6252)
More information about the asterisk-bugs
mailing list