[svn-commits] tilghman: trunk r142992 - in /trunk: apps/ channels/ codecs/ funcs/ include/a...
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Fri Sep 12 18:30:04 CDT 2008
Author: tilghman
Date: Fri Sep 12 18:30:03 2008
New Revision: 142992
URL: http://svn.digium.com/view/asterisk?view=rev&rev=142992
Log:
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)
Modified:
trunk/apps/app_alarmreceiver.c
trunk/apps/app_amd.c
trunk/apps/app_directory.c
trunk/apps/app_festival.c
trunk/apps/app_followme.c
trunk/apps/app_meetme.c
trunk/apps/app_minivm.c
trunk/apps/app_osplookup.c
trunk/apps/app_playback.c
trunk/apps/app_queue.c
trunk/apps/app_rpt.c
trunk/apps/app_voicemail.c
trunk/channels/chan_agent.c
trunk/channels/chan_alsa.c
trunk/channels/chan_console.c
trunk/channels/chan_dahdi.c
trunk/channels/chan_gtalk.c
trunk/channels/chan_h323.c
trunk/channels/chan_iax2.c
trunk/channels/chan_jingle.c
trunk/channels/chan_mgcp.c
trunk/channels/chan_oss.c
trunk/channels/chan_phone.c
trunk/channels/chan_sip.c
trunk/channels/chan_skinny.c
trunk/channels/chan_unistim.c
trunk/codecs/codec_adpcm.c
trunk/codecs/codec_alaw.c
trunk/codecs/codec_dahdi.c
trunk/codecs/codec_g722.c
trunk/codecs/codec_g726.c
trunk/codecs/codec_gsm.c
trunk/codecs/codec_lpc10.c
trunk/codecs/codec_speex.c
trunk/codecs/codec_ulaw.c
trunk/funcs/func_config.c
trunk/funcs/func_odbc.c
trunk/include/asterisk/config.h
trunk/main/asterisk.c
trunk/main/cdr.c
trunk/main/config.c
trunk/main/dnsmgr.c
trunk/main/dsp.c
trunk/main/enum.c
trunk/main/features.c
trunk/main/http.c
trunk/main/loader.c
trunk/main/manager.c
trunk/main/rtp.c
trunk/main/udptl.c
trunk/res/res_adsi.c
trunk/res/res_config_ldap.c
trunk/res/res_config_pgsql.c
trunk/res/res_config_sqlite.c
trunk/res/res_http_post.c
trunk/res/res_indications.c
trunk/res/res_jabber.c
trunk/res/res_musiconhold.c
trunk/res/res_odbc.c
trunk/res/res_phoneprov.c
trunk/res/res_smdi.c
trunk/res/res_snmp.c
Modified: trunk/apps/app_alarmreceiver.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_alarmreceiver.c?view=diff&rev=142992&r1=142991&r2=142992
==============================================================================
--- trunk/apps/app_alarmreceiver.c (original)
+++ trunk/apps/app_alarmreceiver.c Fri Sep 12 18:30:03 2008
@@ -639,6 +639,9 @@
if (!cfg) {
ast_verb(4, "AlarmReceiver: No config file\n");
return 0;
+ } else if (cfg == CONFIG_STATUS_FILEINVALID) {
+ ast_log(LOG_ERROR, "Config file %s is in an invalid format. Aborting.\n", ALMRCV_CONFIG);
+ return 0;
} else {
p = ast_variable_retrieve(cfg, "general", "eventcmd");
if (p) {
Modified: trunk/apps/app_amd.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_amd.c?view=diff&rev=142992&r1=142991&r2=142992
==============================================================================
--- trunk/apps/app_amd.c (original)
+++ trunk/apps/app_amd.c Fri Sep 12 18:30:03 2008
@@ -376,8 +376,12 @@
if (!(cfg = ast_config_load("amd.conf", config_flags))) {
ast_log(LOG_ERROR, "Configuration file amd.conf missing.\n");
return -1;
- } else if (cfg == CONFIG_STATUS_FILEUNCHANGED)
+ } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) {
return 0;
+ } else if (cfg == CONFIG_STATUS_FILEINVALID) {
+ ast_log(LOG_ERROR, "Config file amd.conf is in an invalid format. Aborting.\n");
+ return -1;
+ }
cat = ast_category_browse(cfg, NULL);
Modified: trunk/apps/app_directory.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_directory.c?view=diff&rev=142992&r1=142991&r2=142992
==============================================================================
--- trunk/apps/app_directory.c (original)
+++ trunk/apps/app_directory.c Fri Sep 12 18:30:03 2008
@@ -362,6 +362,9 @@
/* Loading config failed. */
ast_log(LOG_WARNING, "Loading config failed.\n");
return NULL;
+ } else if (cfg == CONFIG_STATUS_FILEINVALID) {
+ ast_log(LOG_ERROR, "Config file %s is in an invalid format. Aborting.\n", VOICEMAIL_CONFIG);
+ return NULL;
}
/* Get realtime entries, categorized by their mailbox number
@@ -670,7 +673,10 @@
return -1;
}
- ucfg = ast_config_load("users.conf", config_flags);
+ if ((ucfg = ast_config_load("users.conf", config_flags)) == CONFIG_STATUS_FILEINVALID) {
+ ast_log(LOG_ERROR, "Config file users.conf is in an invalid format. Aborting.\n");
+ ucfg = NULL;
+ }
dirintro = ast_variable_retrieve(cfg, args.vmcontext, "directoryintro");
if (ast_strlen_zero(dirintro))
Modified: trunk/apps/app_festival.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_festival.c?view=diff&rev=142992&r1=142991&r2=142992
==============================================================================
--- trunk/apps/app_festival.c (original)
+++ trunk/apps/app_festival.c Fri Sep 12 18:30:03 2008
@@ -300,7 +300,11 @@
if (!cfg) {
ast_log(LOG_WARNING, "No such configuration file %s\n", FESTIVAL_CONFIG);
return -1;
- }
+ } else if (cfg == CONFIG_STATUS_FILEINVALID) {
+ ast_log(LOG_ERROR, "Config file " FESTIVAL_CONFIG " is in an invalid format. Aborting.\n");
+ return -1;
+ }
+
if (!(host = ast_variable_retrieve(cfg, "general", "host"))) {
host = "localhost";
}
@@ -517,6 +521,9 @@
if (!cfg) {
ast_log(LOG_WARNING, "No such configuration file %s\n", FESTIVAL_CONFIG);
return AST_MODULE_LOAD_DECLINE;
+ } else if (cfg == CONFIG_STATUS_FILEINVALID) {
+ ast_log(LOG_ERROR, "Config file " FESTIVAL_CONFIG " is in an invalid format. Aborting.\n");
+ return AST_MODULE_LOAD_DECLINE;
}
ast_config_destroy(cfg);
return ast_register_application(app, festival_exec, synopsis, descrip);
Modified: trunk/apps/app_followme.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_followme.c?view=diff&rev=142992&r1=142991&r2=142992
==============================================================================
--- trunk/apps/app_followme.c (original)
+++ trunk/apps/app_followme.c Fri Sep 12 18:30:03 2008
@@ -293,8 +293,12 @@
if (!(cfg = ast_config_load("followme.conf", config_flags))) {
ast_log(LOG_WARNING, "No follow me config file (followme.conf), so no follow me\n");
return 0;
- } else if (cfg == CONFIG_STATUS_FILEUNCHANGED)
+ } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) {
return 0;
+ } else if (cfg == CONFIG_STATUS_FILEINVALID) {
+ ast_log(LOG_ERROR, "Config file followme.conf is in an invalid format. Aborting.\n");
+ return 0;
+ }
AST_RWLIST_WRLOCK(&followmes);
Modified: trunk/apps/app_meetme.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_meetme.c?view=diff&rev=142992&r1=142991&r2=142992
==============================================================================
--- trunk/apps/app_meetme.c (original)
+++ trunk/apps/app_meetme.c Fri Sep 12 18:30:03 2008
@@ -2921,6 +2921,9 @@
if (!cfg) {
ast_log(LOG_WARNING, "No %s file :(\n", CONFIG_FILE_NAME);
return NULL;
+ } else if (cfg == CONFIG_STATUS_FILEINVALID) {
+ ast_log(LOG_ERROR, "Config file " CONFIG_FILE_NAME " is in an invalid format. Aborting.\n");
+ return NULL;
}
for (var = ast_variable_browse(cfg, "rooms"); var; var = var->next) {
if (strcasecmp(var->name, "conf"))
@@ -3083,7 +3086,7 @@
/* We only need to load the config file for static and empty_no_pin (otherwise we don't care) */
if ((empty_no_pin) || (!dynamic)) {
cfg = ast_config_load(CONFIG_FILE_NAME, config_flags);
- if (cfg) {
+ if (cfg && cfg != CONFIG_STATUS_FILEINVALID) {
var = ast_variable_browse(cfg, "rooms");
while (var) {
if (!strcasecmp(var->name, "conf")) {
@@ -3729,8 +3732,12 @@
struct ast_flags config_flags = { 0 };
const char *val;
- if (!(cfg = ast_config_load(CONFIG_FILE_NAME, config_flags)))
+ if (!(cfg = ast_config_load(CONFIG_FILE_NAME, config_flags))) {
return;
+ } else if (cfg == CONFIG_STATUS_FILEINVALID) {
+ ast_log(LOG_ERROR, "Config file " CONFIG_FILE_NAME " is in an invalid format. Aborting.\n");
+ return;
+ }
audio_buffers = DEFAULT_AUDIO_BUFFERS;
@@ -5558,10 +5565,14 @@
ast_cond_init(&sla.cond, NULL);
}
- if (!(cfg = ast_config_load(SLA_CONFIG_FILE, config_flags)))
+ if (!(cfg = ast_config_load(SLA_CONFIG_FILE, config_flags))) {
return 0; /* Treat no config as normal */
- else if (cfg == CONFIG_STATUS_FILEUNCHANGED)
+ } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) {
return 0;
+ } else if (cfg == CONFIG_STATUS_FILEINVALID) {
+ ast_log(LOG_ERROR, "Config file " SLA_CONFIG_FILE " is in an invalid format. Aborting.\n");
+ return 0;
+ }
if ((val = ast_variable_retrieve(cfg, "general", "attemptcallerid")))
sla.attempt_callerid = ast_true(val);
Modified: trunk/apps/app_minivm.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_minivm.c?view=diff&rev=142992&r1=142991&r2=142992
==============================================================================
--- trunk/apps/app_minivm.c (original)
+++ trunk/apps/app_minivm.c Fri Sep 12 18:30:03 2008
@@ -2363,8 +2363,12 @@
struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
cfg = ast_config_load(VOICEMAIL_CONFIG, config_flags);
- if (cfg == CONFIG_STATUS_FILEUNCHANGED)
+ if (cfg == CONFIG_STATUS_FILEUNCHANGED) {
return 0;
+ } else if (cfg == CONFIG_STATUS_FILEINVALID) {
+ ast_log(LOG_ERROR, "Config file " VOICEMAIL_CONFIG " is in an invalid format. Aborting.\n");
+ return 0;
+ }
ast_mutex_lock(&minivmlock);
Modified: trunk/apps/app_osplookup.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_osplookup.c?view=diff&rev=142992&r1=142991&r2=142992
==============================================================================
--- trunk/apps/app_osplookup.c (original)
+++ trunk/apps/app_osplookup.c Fri Sep 12 18:30:03 2008
@@ -1776,8 +1776,12 @@
struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
int error = OSPC_ERR_NO_ERROR;
- if ((cfg = ast_config_load(OSP_CONFIG_FILE, config_flags)) == CONFIG_STATUS_FILEUNCHANGED)
+ if ((cfg = ast_config_load(OSP_CONFIG_FILE, config_flags)) == CONFIG_STATUS_FILEUNCHANGED) {
return 0;
+ } else if (cfg == CONFIG_STATUS_FILEINVALID) {
+ ast_log(LOG_ERROR, "Config file " OSP_CONFIG_FILE " is in an invalid format. Aborting.\n");
+ return 0;
+ }
if (cfg) {
if (reload)
Modified: trunk/apps/app_playback.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_playback.c?view=diff&rev=142992&r1=142991&r2=142992
==============================================================================
--- trunk/apps/app_playback.c (original)
+++ trunk/apps/app_playback.c Fri Sep 12 18:30:03 2008
@@ -461,8 +461,12 @@
struct ast_flags config_flags = { CONFIG_FLAG_FILEUNCHANGED };
struct ast_config *newcfg;
- if ((newcfg = ast_config_load("say.conf", config_flags)) == CONFIG_STATUS_FILEUNCHANGED)
+ if ((newcfg = ast_config_load("say.conf", config_flags)) == CONFIG_STATUS_FILEUNCHANGED) {
return 0;
+ } else if (newcfg == CONFIG_STATUS_FILEINVALID) {
+ ast_log(LOG_ERROR, "Config file say.conf is in an invalid format. Aborting.\n");
+ return 0;
+ }
if (say_cfg) {
ast_config_destroy(say_cfg);
@@ -506,7 +510,7 @@
struct ast_flags config_flags = { 0 };
say_cfg = ast_config_load("say.conf", config_flags);
- if (say_cfg) {
+ if (say_cfg && say_cfg != CONFIG_STATUS_FILEINVALID) {
for (v = ast_variable_browse(say_cfg, "general"); v ; v = v->next) {
if (ast_extension_match(v->name, "mode")) {
say_init_mode(v->value);
Modified: trunk/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_queue.c?view=diff&rev=142992&r1=142991&r2=142992
==============================================================================
--- trunk/apps/app_queue.c (original)
+++ trunk/apps/app_queue.c Fri Sep 12 18:30:03 2008
@@ -5135,6 +5135,9 @@
} else if (cfg == CONFIG_STATUS_FILEUNCHANGED) {
ast_log(LOG_NOTICE, "queuerules.conf has not changed since it was last loaded. Not taking any action.\n");
return AST_MODULE_LOAD_SUCCESS;
+ } else if (cfg == CONFIG_STATUS_FILEINVALID) {
+ ast_log(LOG_ERROR, "Config file queuerules.conf is in an invalid format. Aborting.\n");
+ return AST_MODULE_LOAD_SUCCESS;
} else {
AST_LIST_LOCK(&rule_lists);
while ((rl_iter = AST_LIST_REMOVE_HEAD(&rule_lists, list))) {
@@ -5196,8 +5199,12 @@
if (!(cfg = ast_config_load("queues.conf", config_flags))) {
ast_log(LOG_NOTICE, "No call queueing config file (queues.conf), so no call queues\n");
return 0;
- } else if (cfg == CONFIG_STATUS_FILEUNCHANGED)
+ } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) {
return 0;
+ } else if (cfg == CONFIG_STATUS_FILEINVALID) {
+ ast_log(LOG_ERROR, "Config file queues.conf is in an invalid format. Aborting.\n");
+ return 0;
+ }
ao2_lock(queues);
use_weight=0;
/* Mark all queues as dead for the moment */
Modified: trunk/apps/app_rpt.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_rpt.c?view=diff&rev=142992&r1=142991&r2=142992
==============================================================================
--- trunk/apps/app_rpt.c (original)
+++ trunk/apps/app_rpt.c Fri Sep 12 18:30:03 2008
@@ -2008,7 +2008,7 @@
ourcfg = ast_config_load(myrpt->p.extnodefile);
#endif
/* if file not there, just bail */
- if (!ourcfg)
+ if (!ourcfg || ourcfg == CONFIG_STATUS_FILEINVALID)
{
ast_mutex_unlock(&nodelookuplock);
return(NULL);
@@ -2234,7 +2234,7 @@
#else
cfg = ast_config_load("rpt.conf");
#endif
- if (!cfg) {
+ if (!cfg || cfg == CONFIG_STATUS_FILEINVALID) {
ast_mutex_unlock(&rpt_vars[n].lock);
ast_log(LOG_NOTICE, "Unable to open radio repeater configuration rpt.conf. Radio Repeater disabled.\n");
pthread_exit(NULL);
@@ -12923,7 +12923,7 @@
rpt_vars[n].cfg = ast_config_load("rpt.conf");
#endif
cfg = rpt_vars[n].cfg;
- if (!cfg) {
+ if (!cfg || cfg == CONFIG_STATUS_FILEINVALID) {
ast_log(LOG_NOTICE, "Unable to open radio repeater configuration rpt.conf. Radio Repeater disabled.\n");
pthread_exit(NULL);
}
Modified: trunk/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_voicemail.c?view=diff&rev=142992&r1=142991&r2=142992
==============================================================================
--- trunk/apps/app_voicemail.c (original)
+++ trunk/apps/app_voicemail.c Fri Sep 12 18:30:03 2008
@@ -1157,7 +1157,7 @@
return;
/* check voicemail.conf */
- if ((cfg = ast_config_load(VOICEMAIL_CONFIG, config_flags))) {
+ if ((cfg = ast_config_load(VOICEMAIL_CONFIG, config_flags)) && cfg != CONFIG_STATUS_FILEINVALID) {
while ((category = ast_category_browse(cfg, category))) {
if (!strcasecmp(category, vmu->context)) {
if (!(tmp = ast_variable_retrieve(cfg, category, vmu->mailbox))) {
@@ -1187,7 +1187,7 @@
var = NULL;
/* check users.conf and update the password stored for the mailbox*/
/* if no vmsecret entry exists create one. */
- if ((cfg = ast_config_load("users.conf", config_flags))) {
+ if ((cfg = ast_config_load("users.conf", config_flags)) && cfg != CONFIG_STATUS_FILEINVALID) {
ast_debug(4, "we are looking for %s\n", vmu->mailbox);
while ((category = ast_category_browse(cfg, category))) {
ast_debug(4, "users.conf: %s\n", category);
@@ -3181,7 +3181,7 @@
res = -1;
break;
}
- if (cfg) {
+ if (cfg && cfg != CONFIG_STATUS_FILEINVALID) {
if (!(idata.context = ast_variable_retrieve(cfg, "message", "context"))) {
idata.context = "";
}
@@ -5756,7 +5756,7 @@
strncat(textfile, ".txt", sizeof(textfile) - strlen(textfile) - 1);
strncat(backup, "-bak", sizeof(backup) - strlen(backup) - 1);
- if ((msg_cfg = ast_config_load(textfile, config_flags)) && (duration_str = ast_variable_retrieve(msg_cfg, "message", "duration"))) {
+ if ((msg_cfg = ast_config_load(textfile, config_flags)) && msg_cfg != CONFIG_STATUS_FILEINVALID && (duration_str = ast_variable_retrieve(msg_cfg, "message", "duration"))) {
*duration = atoi(duration_str);
} else {
*duration = 0;
@@ -6456,7 +6456,7 @@
snprintf(filename, sizeof(filename), "%s.txt", vms->fn);
RETRIEVE(vms->curdir, vms->curmsg, vmu->mailbox, vmu->context);
msg_cfg = ast_config_load(filename, config_flags);
- if (!msg_cfg) {
+ if (!msg_cfg || msg_cfg == CONFIG_STATUS_FILEINVALID) {
ast_log(LOG_WARNING, "No message attribute file?!! (%s)\n", filename);
return 0;
}
@@ -9954,13 +9954,27 @@
ast_unload_realtime("voicemail_data");
if ((cfg = ast_config_load(VOICEMAIL_CONFIG, config_flags)) == CONFIG_STATUS_FILEUNCHANGED) {
- if ((ucfg = ast_config_load("users.conf", config_flags)) == CONFIG_STATUS_FILEUNCHANGED)
+ if ((ucfg = ast_config_load("users.conf", config_flags)) == CONFIG_STATUS_FILEUNCHANGED) {
return 0;
+ } else if (ucfg == CONFIG_STATUS_FILEINVALID) {
+ ast_log(LOG_ERROR, "Config file users.conf is in an invalid format. Avoiding.\n");
+ ucfg = NULL;
+ }
ast_clear_flag(&config_flags, CONFIG_FLAG_FILEUNCHANGED);
- cfg = ast_config_load(VOICEMAIL_CONFIG, config_flags);
+ if ((cfg = ast_config_load(VOICEMAIL_CONFIG, config_flags)) == CONFIG_STATUS_FILEINVALID) {
+ ast_config_destroy(ucfg);
+ ast_log(LOG_ERROR, "Config file " VOICEMAIL_CONFIG " is in an invalid format. Aborting.\n");
+ return 0;
+ }
+ } else if (cfg == CONFIG_STATUS_FILEINVALID) {
+ ast_log(LOG_ERROR, "Config file " VOICEMAIL_CONFIG " is in an invalid format. Aborting.\n");
+ return 0;
} else {
ast_clear_flag(&config_flags, CONFIG_FLAG_FILEUNCHANGED);
- ucfg = ast_config_load("users.conf", config_flags);
+ if ((ucfg = ast_config_load("users.conf", config_flags)) == CONFIG_STATUS_FILEINVALID) {
+ ast_log(LOG_ERROR, "Config file users.conf is in an invalid format. Avoiding.\n");
+ ucfg = NULL;
+ }
}
#ifdef IMAP_STORAGE
ast_copy_string(imapparentfolder, "\0", sizeof(imapparentfolder));
@@ -10772,7 +10786,7 @@
RETRIEVE(vms->curdir, vms->curmsg, vmu->mailbox, vmu->context);
msg_cfg = ast_config_load(filename, config_flags);
DISPOSE(vms->curdir, vms->curmsg);
- if (!msg_cfg) {
+ if (!msg_cfg || msg_cfg == CONFIG_STATUS_FILEINVALID) {
ast_log(AST_LOG_WARNING, "No message attribute file?!! (%s)\n", filename);
return 0;
}
Modified: trunk/channels/chan_agent.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_agent.c?view=diff&rev=142992&r1=142991&r2=142992
==============================================================================
--- trunk/channels/chan_agent.c (original)
+++ trunk/channels/chan_agent.c Fri Sep 12 18:30:03 2008
@@ -1117,8 +1117,21 @@
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 @@
}
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) {
Modified: trunk/channels/chan_alsa.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_alsa.c?view=diff&rev=142992&r1=142991&r2=142992
==============================================================================
--- trunk/channels/chan_alsa.c (original)
+++ trunk/channels/chan_alsa.c Fri Sep 12 18:30:03 2008
@@ -857,8 +857,12 @@
strcpy(mohinterpret, "default");
- if (!(cfg = ast_config_load(config, config_flags)))
+ if (!(cfg = ast_config_load(config, config_flags))) {
return AST_MODULE_LOAD_DECLINE;
+ } else if (cfg == CONFIG_STATUS_FILEINVALID) {
+ ast_log(LOG_ERROR, "%s is in an invalid format. Aborting.\n", config);
+ return AST_MODULE_LOAD_DECLINE;
+ }
v = ast_variable_browse(cfg, "general");
for (; v; v = v->next) {
Modified: trunk/channels/chan_console.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_console.c?view=diff&rev=142992&r1=142991&r2=142992
==============================================================================
--- trunk/channels/chan_console.c (original)
+++ trunk/channels/chan_console.c Fri Sep 12 18:30:03 2008
@@ -1400,6 +1400,9 @@
if (!(cfg = ast_config_load(config_file, config_flags))) {
ast_log(LOG_NOTICE, "Unable to open configuration file %s!\n", config_file);
return -1;
+ } else if (cfg == CONFIG_STATUS_FILEINVALID) {
+ ast_log(LOG_NOTICE, "Config file %s has an invalid format\n", config_file);
+ return -1;
}
ao2_callback(pvts, OBJ_NODATA, pvt_mark_destroy_cb, NULL);
Modified: trunk/channels/chan_dahdi.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_dahdi.c?view=diff&rev=142992&r1=142991&r2=142992
==============================================================================
--- trunk/channels/chan_dahdi.c (original)
+++ trunk/channels/chan_dahdi.c Fri Sep 12 18:30:03 2008
@@ -14567,13 +14567,28 @@
return 0;
} else if (cfg == CONFIG_STATUS_FILEUNCHANGED) {
ucfg = ast_config_load("users.conf", config_flags);
- if (ucfg == CONFIG_STATUS_FILEUNCHANGED)
+ if (ucfg == CONFIG_STATUS_FILEUNCHANGED) {
return 0;
+ } else if (ucfg == CONFIG_STATUS_FILEINVALID) {
+ ast_log(LOG_ERROR, "File users.conf cannot be parsed. Aborting.\n");
+ return 0;
+ }
ast_clear_flag(&config_flags, CONFIG_FLAG_FILEUNCHANGED);
- cfg = ast_config_load(config, config_flags);
+ if ((cfg = ast_config_load(config, config_flags)) == CONFIG_STATUS_FILEINVALID) {
+ ast_log(LOG_ERROR, "File %s cannot be parsed. Aborting.\n", config);
+ ast_config_destroy(ucfg);
+ return 0;
+ }
+ } else if (cfg == CONFIG_STATUS_FILEINVALID) {
+ ast_log(LOG_ERROR, "File %s cannot be parsed. Aborting.\n", config);
+ return 0;
} else {
ast_clear_flag(&config_flags, CONFIG_FLAG_FILEUNCHANGED);
- ucfg = ast_config_load("users.conf", config_flags);
+ if ((ucfg = ast_config_load("users.conf", config_flags)) == CONFIG_STATUS_FILEINVALID) {
+ ast_log(LOG_ERROR, "File users.conf cannot be parsed. Aborting.\n");
+ ast_config_destroy(cfg);
+ return 0;
+ }
}
/* It's a little silly to lock it, but we mind as well just to be sure */
Modified: trunk/channels/chan_gtalk.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_gtalk.c?view=diff&rev=142992&r1=142991&r2=142992
==============================================================================
--- trunk/channels/chan_gtalk.c (original)
+++ trunk/channels/chan_gtalk.c Fri Sep 12 18:30:03 2008
@@ -1869,8 +1869,12 @@
struct ast_flags config_flags = { 0 };
cfg = ast_config_load(GOOGLE_CONFIG, config_flags);
- if (!cfg)
+ if (!cfg) {
return 0;
+ } else if (cfg == CONFIG_STATUS_FILEINVALID) {
+ ast_log(LOG_ERROR, "Config file %s is in an invalid format. Aborting.\n", GOOGLE_CONFIG);
+ return 0;
+ }
/* Copy the default jb config over global_jbconf */
memcpy(&global_jbconf, &default_jbconf, sizeof(struct ast_jb_conf));
Modified: trunk/channels/chan_h323.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_h323.c?view=diff&rev=142992&r1=142991&r2=142992
==============================================================================
--- trunk/channels/chan_h323.c (original)
+++ trunk/channels/chan_h323.c Fri Sep 12 18:30:03 2008
@@ -2816,13 +2816,28 @@
return 1;
} else if (cfg == CONFIG_STATUS_FILEUNCHANGED) {
ucfg = ast_config_load("users.conf", config_flags);
- if (ucfg == CONFIG_STATUS_FILEUNCHANGED)
+ if (ucfg == CONFIG_STATUS_FILEUNCHANGED) {
return 0;
+ } else if (ucfg == CONFIG_STATUS_FILEINVALID) {
+ ast_log(LOG_ERROR, "Config file users.conf is in an invalid format. Aborting.\n");
+ return 0;
+ }
ast_clear_flag(&config_flags, CONFIG_FLAG_FILEUNCHANGED);
- cfg = ast_config_load(config, config_flags);
+ if ((cfg = ast_config_load(config, config_flags))) {
+ ast_log(LOG_ERROR, "Config file %s is in an invalid format. Aborting.\n", config);
+ ast_config_destroy(ucfg);
+ return 0;
+ }
+ } else if (cfg == CONFIG_STATUS_FILEINVALID) {
+ ast_log(LOG_ERROR, "Config file %s is in an invalid format. Aborting.\n", config);
+ return 0;
} else {
ast_clear_flag(&config_flags, CONFIG_FLAG_FILEUNCHANGED);
- ucfg = ast_config_load("users.conf", config_flags);
+ if ((ucfg = ast_config_load("users.conf", config_flags)) == CONFIG_STATUS_FILEINVALID) {
+ ast_log(LOG_ERROR, "Config file users.conf is in an invalid format. Aborting.\n");
+ ast_config_destroy(cfg);
+ return 0;
+ }
}
if (is_reload) {
Modified: trunk/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_iax2.c?view=diff&rev=142992&r1=142991&r2=142992
==============================================================================
--- trunk/channels/chan_iax2.c (original)
+++ trunk/channels/chan_iax2.c Fri Sep 12 18:30:03 2008
@@ -11010,10 +11010,21 @@
return 0;
/* Otherwise we need to reread both files */
ast_clear_flag(&config_flags, CONFIG_FLAG_FILEUNCHANGED);
- cfg = ast_config_load(config_file, config_flags);
+ if ((cfg = ast_config_load(config_file, config_flags)) == CONFIG_STATUS_FILEINVALID) {
+ ast_log(LOG_ERROR, "Config file %s is in an invalid format. Aborting.\n", config_file);
+ ast_config_destroy(ucfg);
+ return 0;
+ }
+ } else if (cfg == CONFIG_STATUS_FILEINVALID) {
+ ast_log(LOG_ERROR, "Config file %s is in an invalid format. Aborting.\n", config_file);
+ return 0;
} else { /* iax.conf changed, gotta reread users.conf, too */
ast_clear_flag(&config_flags, CONFIG_FLAG_FILEUNCHANGED);
- ucfg = ast_config_load("users.conf", config_flags);
+ if ((ucfg = ast_config_load("users.conf", config_flags)) == CONFIG_STATUS_FILEINVALID) {
+ ast_log(LOG_ERROR, "Config file users.conf is in an invalid format. Aborting.\n");
+ ast_config_destroy(cfg);
+ return 0;
+ }
}
if (reload) {
Modified: trunk/channels/chan_jingle.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_jingle.c?view=diff&rev=142992&r1=142991&r2=142992
==============================================================================
--- trunk/channels/chan_jingle.c (original)
+++ trunk/channels/chan_jingle.c Fri Sep 12 18:30:03 2008
@@ -1736,8 +1736,9 @@
struct ast_flags config_flags = { 0 };
cfg = ast_config_load(JINGLE_CONFIG, config_flags);
- if (!cfg)
+ if (!cfg || cfg == CONFIG_STATUS_FILEINVALID) {
return 0;
+ }
/* Copy the default jb config over global_jbconf */
memcpy(&global_jbconf, &default_jbconf, sizeof(struct ast_jb_conf));
Modified: trunk/channels/chan_mgcp.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_mgcp.c?view=diff&rev=142992&r1=142991&r2=142992
==============================================================================
--- trunk/channels/chan_mgcp.c (original)
+++ trunk/channels/chan_mgcp.c Fri Sep 12 18:30:03 2008
@@ -4120,8 +4120,12 @@
if (!cfg) {
ast_log(LOG_NOTICE, "Unable to load config %s, MGCP disabled\n", config);
return 0;
- } else if (cfg == CONFIG_STATUS_FILEUNCHANGED)
+ } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) {
return 0;
+ } else if (cfg == CONFIG_STATUS_FILEINVALID) {
+ ast_log(LOG_ERROR, "Config file %s is in an invalid format. Aborting.\n", config);
+ return 0;
+ }
memset(&bindaddr, 0, sizeof(bindaddr));
dtmfmode = 0;
Modified: trunk/channels/chan_oss.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_oss.c?view=diff&rev=142992&r1=142991&r2=142992
==============================================================================
--- trunk/channels/chan_oss.c (original)
+++ trunk/channels/chan_oss.c Fri Sep 12 18:30:03 2008
@@ -1434,6 +1434,9 @@
if (!(cfg = ast_config_load(config, config_flags))) {
ast_log(LOG_NOTICE, "Unable to load config %s\n", config);
return AST_MODULE_LOAD_DECLINE;
+ } else if (cfg == CONFIG_STATUS_FILEINVALID) {
+ ast_log(LOG_ERROR, "Config file %s is in an invalid format. Aborting.\n", config);
+ return AST_MODULE_LOAD_DECLINE;
}
do {
Modified: trunk/channels/chan_phone.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_phone.c?view=diff&rev=142992&r1=142991&r2=142992
==============================================================================
--- trunk/channels/chan_phone.c (original)
+++ trunk/channels/chan_phone.c Fri Sep 12 18:30:03 2008
@@ -1346,7 +1346,10 @@
int txgain = DEFAULT_GAIN, rxgain = DEFAULT_GAIN; /* default gain 1.0 */
struct ast_flags config_flags = { 0 };
- cfg = ast_config_load(config, config_flags);
+ if ((cfg = ast_config_load(config, config_flags)) == CONFIG_STATUS_FILEINVALID) {
+ ast_log(LOG_ERROR, "Config file %s is in an invalid format. Aborting.\n", config);
+ return AST_MODULE_LOAD_DECLINE;
+ }
/* We *must* have a config file otherwise stop immediately */
if (!cfg) {
Modified: trunk/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_sip.c?view=diff&rev=142992&r1=142991&r2=142992
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Fri Sep 12 18:30:03 2008
@@ -21220,14 +21220,29 @@
return -1;
} else if (cfg == CONFIG_STATUS_FILEUNCHANGED) {
ucfg = ast_config_load("users.conf", config_flags);
- if (ucfg == CONFIG_STATUS_FILEUNCHANGED)
+ if (ucfg == CONFIG_STATUS_FILEUNCHANGED) {
return 1;
+ } else if (ucfg == CONFIG_STATUS_FILEINVALID) {
+ ast_log(LOG_ERROR, "Contents of users.conf are invalid and cannot be parsed\n");
+ return 1;
+ }
/* Must reread both files, because one changed */
ast_clear_flag(&config_flags, CONFIG_FLAG_FILEUNCHANGED);
- cfg = ast_config_load(config, config_flags);
+ if ((cfg = ast_config_load(config, config_flags)) == CONFIG_STATUS_FILEINVALID) {
+ ast_log(LOG_ERROR, "Contents of %s are invalid and cannot be parsed\n", config);
+ ast_config_destroy(ucfg);
+ return 1;
+ }
+ } else if (cfg == CONFIG_STATUS_FILEINVALID) {
+ ast_log(LOG_ERROR, "Contents of %s are invalid and cannot be parsed\n", config);
+ return 1;
} else {
ast_clear_flag(&config_flags, CONFIG_FLAG_FILEUNCHANGED);
- ucfg = ast_config_load("users.conf", config_flags);
+ if ((ucfg = ast_config_load("users.conf", config_flags)) == CONFIG_STATUS_FILEINVALID) {
+ ast_log(LOG_ERROR, "Contents of users.conf are invalid and cannot be parsed\n");
+ ast_config_destroy(cfg);
+ return 1;
+ }
}
/* Initialize tcp sockets */
@@ -21996,7 +22011,10 @@
/* Load the list of manual NOTIFY types to support */
if (notify_types)
ast_config_destroy(notify_types);
- notify_types = ast_config_load(notify_config, config_flags);
+ if ((notify_types = ast_config_load(notify_config, config_flags)) == CONFIG_STATUS_FILEINVALID) {
+ ast_log(LOG_ERROR, "Contents of %s are invalid and cannot be parsed.\n", notify_config);
+ notify_types = NULL;
+ }
/* Done, tell the manager */
manager_event(EVENT_FLAG_SYSTEM, "ChannelReload", "ChannelType: SIP\r\nReloadReason: %s\r\nRegistry_Count: %d\r\nPeer_Count: %d\r\n", channelreloadreason2txt(reason), registry_count, peer_count);
Modified: trunk/channels/chan_skinny.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_skinny.c?view=diff&rev=142992&r1=142991&r2=142992
==============================================================================
--- trunk/channels/chan_skinny.c (original)
+++ trunk/channels/chan_skinny.c Fri Sep 12 18:30:03 2008
@@ -6210,7 +6210,10 @@
ast_log(LOG_WARNING, "Unable to get hostname, Skinny disabled\n");
return 0;
}
- cfg = ast_config_load(config, config_flags);
+ if ((cfg = ast_config_load(config, config_flags)) == CONFIG_STATUS_FILEINVALID) {
+ ast_log(LOG_ERROR, "Config file %s is in an invalid format. Aborting.\n", config);
+ return 0;
+ }
/* We *must* have a config file otherwise stop immediately */
if (!cfg) {
Modified: trunk/channels/chan_unistim.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_unistim.c?view=diff&rev=142992&r1=142991&r2=142992
==============================================================================
--- trunk/channels/chan_unistim.c (original)
+++ trunk/channels/chan_unistim.c Fri Sep 12 18:30:03 2008
@@ -5304,6 +5304,9 @@
if (!cfg) {
ast_log(LOG_ERROR, "Unable to load config %s\n", config);
return -1;
+ } else if (cfg == CONFIG_STATUS_FILEINVALID) {
+ ast_log(LOG_ERROR, "Config file %s is in an invalid format. Aborting.\n", config);
+ return -1;
}
/* Copy the default jb config over global_jbconf */
Modified: trunk/codecs/codec_adpcm.c
URL: http://svn.digium.com/view/asterisk/trunk/codecs/codec_adpcm.c?view=diff&rev=142992&r1=142991&r2=142992
==============================================================================
--- trunk/codecs/codec_adpcm.c (original)
+++ trunk/codecs/codec_adpcm.c Fri Sep 12 18:30:03 2008
@@ -345,9 +345,7 @@
struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
struct ast_config *cfg = ast_config_load("codecs.conf", config_flags);
struct ast_variable *var;
- if (cfg == NULL)
- return 0;
- if (cfg == CONFIG_STATUS_FILEUNCHANGED)
+ if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID)
return 0;
for (var = ast_variable_browse(cfg, "plc"); var ; var = var->next) {
if (!strcasecmp(var->name, "genericplc")) {
Modified: trunk/codecs/codec_alaw.c
URL: http://svn.digium.com/view/asterisk/trunk/codecs/codec_alaw.c?view=diff&rev=142992&r1=142991&r2=142992
==============================================================================
--- trunk/codecs/codec_alaw.c (original)
+++ trunk/codecs/codec_alaw.c Fri Sep 12 18:30:03 2008
@@ -128,9 +128,7 @@
struct ast_variable *var;
struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
struct ast_config *cfg = ast_config_load("codecs.conf", config_flags);
- if (cfg == NULL)
- return 0;
- if (cfg == CONFIG_STATUS_FILEUNCHANGED)
+ if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID)
return 0;
for (var = ast_variable_browse(cfg, "plc"); var; var = var->next) {
if (!strcasecmp(var->name, "genericplc")) {
Modified: trunk/codecs/codec_dahdi.c
URL: http://svn.digium.com/view/asterisk/trunk/codecs/codec_dahdi.c?view=diff&rev=142992&r1=142991&r2=142992
==============================================================================
--- trunk/codecs/codec_dahdi.c (original)
+++ trunk/codecs/codec_dahdi.c Fri Sep 12 18:30:03 2008
@@ -351,9 +351,7 @@
struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
struct ast_config *cfg = ast_config_load("codecs.conf", config_flags);
- if (cfg == NULL)
- return 0;
- if (cfg == CONFIG_STATUS_FILEUNCHANGED)
+ if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID)
return 0;
for (var = ast_variable_browse(cfg, "plc"); var; var = var->next) {
Modified: trunk/codecs/codec_g722.c
URL: http://svn.digium.com/view/asterisk/trunk/codecs/codec_g722.c?view=diff&rev=142992&r1=142991&r2=142992
==============================================================================
--- trunk/codecs/codec_g722.c (original)
+++ trunk/codecs/codec_g722.c Fri Sep 12 18:30:03 2008
@@ -244,9 +244,7 @@
struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
struct ast_config *cfg = ast_config_load("codecs.conf", config_flags);
- if (cfg == NULL)
- return 0;
- if (cfg == CONFIG_STATUS_FILEUNCHANGED)
+ if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID)
return 0;
for (var = ast_variable_browse(cfg, "plc"); var; var = var->next) {
if (!strcasecmp(var->name, "genericplc")) {
Modified: trunk/codecs/codec_g726.c
URL: http://svn.digium.com/view/asterisk/trunk/codecs/codec_g726.c?view=diff&rev=142992&r1=142991&r2=142992
==============================================================================
--- trunk/codecs/codec_g726.c (original)
+++ trunk/codecs/codec_g726.c Fri Sep 12 18:30:03 2008
@@ -890,9 +890,7 @@
struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
struct ast_config *cfg = ast_config_load("codecs.conf", config_flags);
- if (cfg == NULL)
- return 0;
- if (cfg == CONFIG_STATUS_FILEUNCHANGED)
+ if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID)
return 0;
for (var = ast_variable_browse(cfg, "plc"); var; var = var->next) {
if (!strcasecmp(var->name, "genericplc")) {
Modified: trunk/codecs/codec_gsm.c
URL: http://svn.digium.com/view/asterisk/trunk/codecs/codec_gsm.c?view=diff&rev=142992&r1=142991&r2=142992
==============================================================================
--- trunk/codecs/codec_gsm.c (original)
+++ trunk/codecs/codec_gsm.c Fri Sep 12 18:30:03 2008
@@ -229,9 +229,7 @@
struct ast_variable *var;
struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
struct ast_config *cfg = ast_config_load("codecs.conf", config_flags);
- if (cfg == NULL)
- return 0;
- if (cfg == CONFIG_STATUS_FILEUNCHANGED)
+ if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID)
return 0;
for (var = ast_variable_browse(cfg, "plc"); var; var = var->next) {
if (!strcasecmp(var->name, "genericplc")) {
Modified: trunk/codecs/codec_lpc10.c
URL: http://svn.digium.com/view/asterisk/trunk/codecs/codec_lpc10.c?view=diff&rev=142992&r1=142991&r2=142992
==============================================================================
--- trunk/codecs/codec_lpc10.c (original)
+++ trunk/codecs/codec_lpc10.c Fri Sep 12 18:30:03 2008
@@ -255,9 +255,7 @@
struct ast_variable *var;
struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
struct ast_config *cfg = ast_config_load("codecs.conf", config_flags);
- if (cfg == NULL)
- return 0;
- if (cfg == CONFIG_STATUS_FILEUNCHANGED)
+ if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID)
return 0;
for (var = ast_variable_browse(cfg, "plc"); var; var = var->next) {
[... 578 lines stripped ...]
More information about the svn-commits
mailing list