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: https://origsvn.digium.com/svn/asterisk/trunk@142992 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.6.2
Tilghman Lesher 17 years ago
parent 5d39c767c1
commit 08af5bb312

@ -639,6 +639,9 @@ static int load_config(void)
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) {

@ -376,8 +376,12 @@ static int load_config(int reload)
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);

@ -362,6 +362,9 @@ static struct ast_config *realtime_directory(char *context)
/* 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 @@ static int directory_exec(struct ast_channel *chan, void *data)
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))

@ -300,7 +300,11 @@ static int festival_exec(struct ast_channel *chan, void *vdata)
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 @@ static int load_module(void)
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);

@ -293,8 +293,12 @@ static int reload_followme(int reload)
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);

@ -2921,6 +2921,9 @@ static struct ast_conference *find_conf(struct ast_channel *chan, char *confno,
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 @@ static int conf_exec(struct ast_channel *chan, void *data)
/* 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 @@ static void load_config_meetme(void)
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 @@ static int sla_load_config(int reload)
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);

@ -2363,8 +2363,12 @@ static int load_config(int reload)
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);

@ -1776,8 +1776,12 @@ static int osp_load(int reload)
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)

@ -461,8 +461,12 @@ static int reload(void)
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 @@ static int load_module(void)
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);

@ -5135,6 +5135,9 @@ static int reload_queue_rules(int reload)
} 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 @@ static int reload_queues(int reload)
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 */

@ -2008,7 +2008,7 @@ struct ast_variable *vp;
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 @@ static char *cs_keywords[] = {"rptena","rptdis","apena","apdis","lnkena","lnkdis
#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 @@ char *this,*val;
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);
}

@ -1157,7 +1157,7 @@ static void vm_change_password(struct ast_vm_user *vmu, const char *newpassword)
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 @@ static void vm_change_password(struct ast_vm_user *vmu, const char *newpassword)
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 @@ static int store_file(char *dir, char *mailboxuser, char *mailboxcontext, int ms
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 @@ static int vm_forwardoptions(struct ast_channel *chan, struct ast_vm_user *vmu,
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 @@ static int play_message(struct ast_channel *chan, struct ast_vm_user *vmu, struc
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 @@ static int load_config(int reload)
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 @@ static int advanced_options(struct ast_channel *chan, struct ast_vm_user *vmu, s
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;
}

@ -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) {

@ -857,8 +857,12 @@ static int load_module(void)
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) {

@ -1400,6 +1400,9 @@ static int load_config(int reload)
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);

@ -14567,13 +14567,28 @@ static int setup_dahdi(int reload)
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 */

@ -1869,8 +1869,12 @@ static int gtalk_load_config(void)
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));

@ -2816,13 +2816,28 @@ static int reload_config(int is_reload)
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) {

@ -11010,10 +11010,21 @@ static int set_config(char *config_file, int reload)
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) {

@ -1736,8 +1736,9 @@ static int jingle_load_config(void)
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));

@ -4120,8 +4120,12 @@ static int reload_config(int reload)
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;

@ -1434,6 +1434,9 @@ static int load_module(void)
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 {

@ -1346,7 +1346,10 @@ static int load_module(void)
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) {

@ -21220,14 +21220,29 @@ static int reload_config(enum channelreloadreason reason)
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 @@ static int reload_config(enum channelreloadreason reason)
/* 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);

@ -6210,7 +6210,10 @@ static int reload_config(void)
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) {

@ -5304,6 +5304,9 @@ static int reload_config(void)
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 */

@ -345,9 +345,7 @@ static int parse_config(int reload)
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")) {

@ -128,9 +128,7 @@ static int parse_config(int reload)
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")) {

@ -351,9 +351,7 @@ static int parse_config(int reload)
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) {

@ -244,9 +244,7 @@ static int parse_config(int reload)
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")) {

@ -890,9 +890,7 @@ static int parse_config(int reload)
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")) {

@ -229,9 +229,7 @@ static int parse_config(int reload)
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")) {

@ -255,9 +255,7 @@ static int parse_config(int reload)
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")) {

@ -375,9 +375,7 @@ static int parse_config(int reload)
int res;
float res_f;
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, "speex"); var; var = var->next) {

@ -141,9 +141,7 @@ static int parse_config(int reload)
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")) {

@ -82,7 +82,7 @@ static int config_function_read(struct ast_channel *chan, const char *cmd, char
return -1;
}
if (!(cfg = ast_config_load(args.filename, cfg_flags))) {
if (!(cfg = ast_config_load(args.filename, cfg_flags)) || cfg == CONFIG_STATUS_FILEINVALID) {
return -1;
}
@ -107,7 +107,7 @@ static int config_function_read(struct ast_channel *chan, const char *cmd, char
strcpy(cur->filename, args.filename);
ast_clear_flag(&cfg_flags, CONFIG_FLAG_FILEUNCHANGED);
if (!(cfg = ast_config_load(args.filename, cfg_flags))) {
if (!(cfg = ast_config_load(args.filename, cfg_flags)) || cfg == CONFIG_STATUS_FILEINVALID) {
ast_free(cur);
AST_RWLIST_UNLOCK(&configs);
return -1;

@ -812,7 +812,7 @@ static int load_module(void)
AST_RWLIST_WRLOCK(&queries);
cfg = ast_config_load(config, config_flags);
if (!cfg) {
if (!cfg || cfg == CONFIG_STATUS_FILEINVALID) {
ast_log(LOG_NOTICE, "Unable to load config for func_odbc: %s\n", config);
AST_RWLIST_UNLOCK(&queries);
return AST_MODULE_LOAD_DECLINE;
@ -878,7 +878,7 @@ static int reload(void)
struct ast_flags config_flags = { CONFIG_FLAG_FILEUNCHANGED };
cfg = ast_config_load(config, config_flags);
if (cfg == CONFIG_STATUS_FILEUNCHANGED)
if (cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID)
return 0;
AST_RWLIST_WRLOCK(&queries);

@ -45,7 +45,9 @@ enum {
CONFIG_FLAG_NOCACHE = (1 << 2),
};
#define CONFIG_STATUS_FILEMISSING (void *)0
#define CONFIG_STATUS_FILEUNCHANGED (void *)-1
#define CONFIG_STATUS_FILEINVALID (void *)-2
/*!
* \brief Types used in ast_realtime_require_field

@ -2596,7 +2596,7 @@ static void ast_readconfig(void)
if (ast_opt_override_config) {
cfg = ast_config_load2(ast_config_AST_CONFIG_FILE, "" /* core, can't reload */, config_flags);
if (!cfg)
if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID)
ast_log(LOG_WARNING, "Unable to open specified master config file '%s', using built-in defaults\n", ast_config_AST_CONFIG_FILE);
} else
cfg = ast_config_load2(config, "" /* core, can't reload */, config_flags);
@ -2619,7 +2619,7 @@ static void ast_readconfig(void)
ast_set_default_eid(&g_eid);
/* no asterisk.conf? no problem, use buildtime config! */
if (!cfg) {
if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID) {
return;
}
@ -2869,6 +2869,9 @@ static void run_startup_commands(void)
if (!(cfg = ast_config_load2("cli.conf", "" /* core, can't reload */, cfg_flags)))
return;
if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID) {
return;
}
fd = open("/dev/null", O_RDWR);
if (fd < 0) {

@ -1388,6 +1388,9 @@ static int do_reload(int reload)
if ((config = ast_config_load2("cdr.conf", "cdr", config_flags)) == CONFIG_STATUS_FILEUNCHANGED)
return 0;
if (config == CONFIG_STATUS_FILEMISSING || config == CONFIG_STATUS_FILEUNCHANGED || config == CONFIG_STATUS_FILEINVALID) {
return 0;
}
ast_mutex_lock(&cdr_batch_lock);

@ -1015,13 +1015,17 @@ static int process_text_line(struct ast_config *cfg, struct ast_category **cat,
cur++;
c = cur;
while (*c && (*c > 32)) c++;
while (*c && (*c > 32)) {
c++;
}
if (*c) {
*c = '\0';
/* Find real argument */
c = ast_skip_blanks(c + 1);
if (!(*c))
if (!(*c)) {
c = NULL;
}
} else
c = NULL;
if (!strcasecmp(cur, "include")) {
@ -1390,7 +1394,7 @@ static struct ast_config *config_text_file_load(const char *database, const char
char *buffer = ast_strip(process_buf);
if (!ast_strlen_zero(buffer)) {
if (process_text_line(cfg, &cat, buffer, lineno, fn, flags, comment_buffer, lline_buffer, suggested_include_file, &last_cat, &last_var, who_asked)) {
cfg = NULL;
cfg = CONFIG_STATUS_FILEINVALID;
break;
}
}
@ -1428,15 +1432,16 @@ static struct ast_config *config_text_file_load(const char *database, const char
ast_log(LOG_WARNING,"Unterminated comment detected beginning on line %d\n", nest[comment - 1]);
}
#ifdef AST_INCLUDE_GLOB
if (cfg == NULL || cfg == CONFIG_STATUS_FILEUNCHANGED)
if (cfg == NULL || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID) {
break;
}
}
globfree(&globbuf);
}
}
#endif
if (cfg && cfg != CONFIG_STATUS_FILEUNCHANGED && cfg->include_level == 1 && ast_test_flag(&flags, CONFIG_FLAG_WITHCOMMENTS)) {
if (cfg && cfg != CONFIG_STATUS_FILEUNCHANGED && cfg != CONFIG_STATUS_FILEINVALID && cfg->include_level == 1 && ast_test_flag(&flags, CONFIG_FLAG_WITHCOMMENTS)) {
if (comment_buffer)
ast_free(comment_buffer);
if (lline_buffer)
@ -2055,7 +2060,7 @@ struct ast_config *ast_config_load2(const char *filename, const char *who_asked,
return NULL;
result = ast_config_internal_load(filename, cfg, flags, "", who_asked);
if (!result || result == CONFIG_STATUS_FILEUNCHANGED)
if (!result || result == CONFIG_STATUS_FILEUNCHANGED || result == CONFIG_STATUS_FILEINVALID)
ast_config_destroy(cfg);
return result;

@ -372,8 +372,10 @@ static int do_reload(int loading)
int was_enabled;
int res = -1;
if ((config = ast_config_load2("dnsmgr.conf", "dnsmgr", config_flags)) == CONFIG_STATUS_FILEUNCHANGED)
config = ast_config_load2("dnsmgr.conf", "dnsmgr", config_flags);
if (config == CONFIG_STATUS_FILEMISSING || config == CONFIG_STATUS_FILEUNCHANGED || config == CONFIG_STATUS_FILEINVALID) {
return 0;
}
/* ensure that no refresh cycles run while the reload is in progress */
ast_mutex_lock(&refresh_lock);

@ -1614,6 +1614,9 @@ static int _dsp_init(int reload)
struct ast_config *cfg;
cfg = ast_config_load2(CONFIG_FILE_NAME, "dsp", config_flags);
if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID) {
return 0;
}
if (cfg && cfg != CONFIG_STATUS_FILEUNCHANGED) {
const char *value;

@ -959,6 +959,9 @@ static int private_enum_init(int reload)
if ((cfg = ast_config_load2("enum.conf", "enum", config_flags)) == CONFIG_STATUS_FILEUNCHANGED)
return 0;
if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID) {
return 0;
}
/* Destroy existing list */
ast_mutex_lock(&enumlock);

@ -3143,7 +3143,7 @@ static int load_config(void)
atxfercallbackretries = DEFAULT_ATXFER_CALLBACK_RETRIES;
cfg = ast_config_load2("features.conf", "features", config_flags);
if (!cfg) {
if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID) {
ast_log(LOG_WARNING,"Could not load features.conf\n");
return 0;
}

@ -851,7 +851,8 @@ static int __ast_http_load(int reload)
struct http_uri_redirect *redirect;
struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
if ((cfg = ast_config_load2("http.conf", "http", config_flags)) == CONFIG_STATUS_FILEUNCHANGED) {
cfg = ast_config_load2("http.conf", "http", config_flags);
if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID) {
return 0;
}

@ -787,7 +787,8 @@ int load_modules(unsigned int preload_only)
embedded_module_list.first = NULL;
}
if (!(cfg = ast_config_load2(AST_MODULE_CONFIG, "" /* core, can't reload */, config_flags))) {
cfg = ast_config_load2(AST_MODULE_CONFIG, "" /* core, can't reload */, config_flags);
if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEINVALID) {
ast_log(LOG_WARNING, "No '%s' found, no modules will be loaded.\n", AST_MODULE_CONFIG);
goto done;
}

@ -1132,7 +1132,8 @@ static int action_getconfig(struct mansession *s, const struct message *m)
astman_send_error(s, m, "Filename not specified");
return 0;
}
if (!(cfg = ast_config_load2(fn, "manager", config_flags))) {
cfg = ast_config_load2(fn, "manager", config_flags);
if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEINVALID) {
astman_send_error(s, m, "Config file not found");
return 0;
}

@ -4694,8 +4694,10 @@ static int __ast_rtp_reload(int reload)
const char *s;
struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
if ((cfg = ast_config_load2("rtp.conf", "rtp", config_flags)) == CONFIG_STATUS_FILEUNCHANGED)
cfg = ast_config_load2("rtp.conf", "rtp", config_flags);
if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID) {
return 0;
}
rtpstart = 5000;
rtpend = 31000;

@ -1223,8 +1223,10 @@ static void __ast_udptl_reload(int reload)
const char *s;
struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
if ((cfg = ast_config_load2("udptl.conf", "udptl", config_flags)) == CONFIG_STATUS_FILEUNCHANGED)
cfg = ast_config_load2("udptl.conf", "udptl", config_flags);
if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID) {
return;
}
udptlstart = 4500;
udptlend = 4999;

@ -1021,10 +1021,10 @@ static void adsi_load(int reload)
char *name, *sname;
init_state();
if (!(conf = ast_config_load("adsi.conf", config_flags)))
return;
else if (conf == CONFIG_STATUS_FILEUNCHANGED)
conf = ast_config_load("adsi.conf", config_flags);
if (conf == CONFIG_STATUS_FILEMISSING || conf == CONFIG_STATUS_FILEUNCHANGED || conf == CONFIG_STATUS_FILEINVALID) {
return;
}
for (v = ast_variable_browse(conf, "intro"); v; v = v->next) {
if (!strcasecmp(v->name, "alignment"))
alignment = str2align(v->value);

@ -1391,8 +1391,7 @@ int parse_config(void)
char *category_name = NULL;
config = ast_config_load(RES_CONFIG_LDAP_CONF, config_flags);
if (!config) {
if (config == CONFIG_STATUS_FILEMISSING || config == CONFIG_STATUS_FILEINVALID) {
ast_log(LOG_WARNING, "Cannot load configuration %s\n", RES_CONFIG_LDAP_CONF);
return -1;
}

@ -1131,10 +1131,12 @@ static int parse_config(int is_reload)
const char *s;
struct ast_flags config_flags = { is_reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
if ((config = ast_config_load(RES_CONFIG_PGSQL_CONF, config_flags)) == CONFIG_STATUS_FILEUNCHANGED)
config = ast_config_load(RES_CONFIG_PGSQL_CONF, config_flags);
if (config == CONFIG_STATUS_FILEUNCHANGED) {
return 0;
}
if (!config) {
if (config == CONFIG_STATUS_FILEMISSING || config == CONFIG_STATUS_FILEINVALID) {
ast_log(LOG_WARNING, "Unable to load config %s\n", RES_CONFIG_PGSQL_CONF);
return 0;
}

@ -730,7 +730,7 @@ static int load_config(void)
config = ast_config_load(RES_CONFIG_SQLITE_CONF_FILE, config_flags);
if (!config) {
if (config == CONFIG_STATUS_FILEMISSING || config == CONFIG_STATUS_FILEINVALID) {
ast_log(LOG_ERROR, "Unable to load " RES_CONFIG_SQLITE_CONF_FILE "\n");
return 1;
}

@ -266,7 +266,8 @@ static int __ast_http_post_load(int reload)
struct ast_variable *v;
struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
if ((cfg = ast_config_load2("http.conf", "http", config_flags)) == CONFIG_STATUS_FILEUNCHANGED) {
cfg = ast_config_load2("http.conf", "http", config_flags);
if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID) {
return 0;
}

@ -263,10 +263,11 @@ static int ind_load_module(int reload)
/* that the following cast is needed, is yuk! */
/* yup, checked it out. It is NOT written to. */
cfg = ast_config_load((char *)config, config_flags);
if (!cfg)
if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEINVALID) {
return -1;
else if (cfg == CONFIG_STATUS_FILEUNCHANGED)
} else if (cfg == CONFIG_STATUS_FILEUNCHANGED) {
return 0;
}
if (reload)
ast_unregister_indication_country(NULL);

@ -2883,7 +2883,7 @@ static int aji_load_config(int reload)
/* Reset flags to default value */
ast_set_flag(&globalflags, AJI_AUTOREGISTER);
if (!cfg) {
if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEINVALID) {
ast_log(LOG_WARNING, "No such configuration file %s\n", JABBER_CONFIG);
return 0;
}

@ -1337,8 +1337,9 @@ static int load_moh_classes(int is_reload)
cfg = ast_config_load("musiconhold.conf", config_flags);
if (cfg == NULL || cfg == CONFIG_STATUS_FILEUNCHANGED)
if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID) {
return 0;
}
if (is_reload) {
AST_RWLIST_WRLOCK(&mohclasses);

@ -417,7 +417,7 @@ static int load_odbc_config(void)
struct odbc_class *new;
config = ast_config_load(cfg, config_flags);
if (!config) {
if (config == CONFIG_STATUS_FILEMISSING || config == CONFIG_STATUS_FILEINVALID) {
ast_log(LOG_WARNING, "Unable to load config file res_odbc.conf\n");
return -1;
}

@ -903,12 +903,12 @@ static int set_config(void)
/* Try to grab the port from sip.conf. If we don't get it here, we'll set it
* to whatever is set in phoneprov.conf or default to 5060 */
if ((cfg = ast_config_load("sip.conf", config_flags))) {
if ((cfg = ast_config_load("sip.conf", config_flags)) && cfg != CONFIG_STATUS_FILEINVALID) {
ast_copy_string(global_serverport, S_OR(ast_variable_retrieve(cfg, "general", "bindport"), "5060"), sizeof(global_serverport));
ast_config_destroy(cfg);
}
if (!(cfg = ast_config_load("users.conf", config_flags))) {
if (!(cfg = ast_config_load("users.conf", config_flags)) || cfg == CONFIG_STATUS_FILEINVALID) {
ast_log(LOG_WARNING, "Unable to load users.cfg\n");
return 0;
}
@ -930,7 +930,7 @@ static int set_config(void)
}
}
if (!(phoneprov_cfg = ast_config_load("phoneprov.conf", config_flags))) {
if (!(phoneprov_cfg = ast_config_load("phoneprov.conf", config_flags)) || phoneprov_cfg == CONFIG_STATUS_FILEINVALID) {
ast_log(LOG_ERROR, "Unable to load config phoneprov.conf\n");
return -1;
}

@ -848,7 +848,7 @@ static int smdi_load(int reload)
int msdstrip = 0; /* strip zero digits */
long msg_expiry = SMDI_MSG_EXPIRY_TIME;
if (!(conf = ast_config_load(config_file, config_flags))) {
if (!(conf = ast_config_load(config_file, config_flags)) || conf == CONFIG_STATUS_FILEINVALID) {
if (reload)
ast_log(LOG_NOTICE, "Unable to reload config %s: SMDI untouched\n", config_file);
else

@ -52,7 +52,7 @@ static int load_config(void)
res_snmp_enabled = 0;
res_snmp_agentx_subagent = 1;
cfg = ast_config_load("res_snmp.conf", config_flags);
if (!cfg) {
if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEINVALID) {
ast_log(LOG_WARNING, "Could not load res_snmp.conf\n");
return 0;
}

Loading…
Cancel
Save