aboutsummaryrefslogtreecommitdiffstats
path: root/channels/chan_agent.c
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2008-09-12 23:30:03 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2008-09-12 23:30:03 +0000
commit95bae857590d3ca7e1bb44f384014d691442eb00 (patch)
tree790035cc6aca2440080bd357a68a09fdbbb2624c /channels/chan_agent.c
parentcdf54b5bc1d32ecbb11e9cb465514ad0298de20b (diff)
Create a new config file status, CONFIG_STATUS_FILEINVALID for differentiating
when a file is invalid from when a file is missing. This is most important when we have two configuration files. Consider the following example: Old system: sip.conf users.conf Old result New result ======== ========== ========== ========== Missing Missing SIP doesn't load SIP doesn't load Missing OK SIP doesn't load SIP doesn't load Missing Invalid SIP doesn't load SIP doesn't load OK Missing SIP loads SIP loads OK OK SIP loads SIP loads OK Invalid SIP loads incompletely SIP doesn't load Invalid Missing SIP doesn't load SIP doesn't load Invalid OK SIP doesn't load SIP doesn't load Invalid Invalid SIP doesn't load SIP doesn't load So in the case when users.conf doesn't load because there's a typo that disrupts the syntax, we may only partially load users, instead of failing with an error, which may cause some calls not to get processed. Worse yet, the old system would do this with no indication that anything was even wrong. (closes issue #10690) Reported by: dtyoo Patches: 20080716__bug10690.diff.txt uploaded by Corydon76 (license 14) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@142992 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels/chan_agent.c')
-rw-r--r--channels/chan_agent.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/channels/chan_agent.c b/channels/chan_agent.c
index 5f5afbd43..83dbd38e4 100644
--- a/channels/chan_agent.c
+++ b/channels/chan_agent.c
@@ -1117,8 +1117,21 @@ static int read_agent_config(int reload)
if (!cfg) {
ast_log(LOG_NOTICE, "No agent configuration found -- agent support disabled\n");
return 0;
- } else if (cfg == CONFIG_STATUS_FILEUNCHANGED)
+ } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) {
return -1;
+ } else if (cfg == CONFIG_STATUS_FILEINVALID) {
+ ast_log(LOG_ERROR, "%s contains a parsing error. Aborting\n", config);
+ return 0;
+ }
+ if ((ucfg = ast_config_load("users.conf", config_flags))) {
+ if (ucfg == CONFIG_STATUS_FILEUNCHANGED) {
+ ucfg = NULL;
+ } else if (ucfg == CONFIG_STATUS_FILEINVALID) {
+ ast_log(LOG_ERROR, "users.conf contains a parsing error. Aborting\n");
+ return 0;
+ }
+ }
+
AST_LIST_LOCK(&agents);
AST_LIST_TRAVERSE(&agents, p, list) {
p->dead = 1;
@@ -1208,7 +1221,7 @@ static int read_agent_config(int reload)
}
v = v->next;
}
- if ((ucfg = ast_config_load("users.conf", config_flags)) && ucfg != CONFIG_STATUS_FILEUNCHANGED) {
+ if (ucfg) {
genhasagent = ast_true(ast_variable_retrieve(ucfg, "general", "hasagent"));
catname = ast_category_browse(ucfg, NULL);
while(catname) {