Create a new config file status, CONFIG_STATUS_FILEINVALID for differentiating
authorTilghman Lesher <tilghman@meg.abyt.es>
Fri, 12 Sep 2008 23:30:03 +0000 (23:30 +0000)
committerTilghman Lesher <tilghman@meg.abyt.es>
Fri, 12 Sep 2008 23:30:03 +0000 (23:30 +0000)
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

62 files changed:
apps/app_alarmreceiver.c
apps/app_amd.c
apps/app_directory.c
apps/app_festival.c
apps/app_followme.c
apps/app_meetme.c
apps/app_minivm.c
apps/app_osplookup.c
apps/app_playback.c
apps/app_queue.c
apps/app_rpt.c
apps/app_voicemail.c
channels/chan_agent.c
channels/chan_alsa.c
channels/chan_console.c
channels/chan_dahdi.c
channels/chan_gtalk.c
channels/chan_h323.c
channels/chan_iax2.c
channels/chan_jingle.c
channels/chan_mgcp.c
channels/chan_oss.c
channels/chan_phone.c
channels/chan_sip.c
channels/chan_skinny.c
channels/chan_unistim.c
codecs/codec_adpcm.c
codecs/codec_alaw.c
codecs/codec_dahdi.c
codecs/codec_g722.c
codecs/codec_g726.c
codecs/codec_gsm.c
codecs/codec_lpc10.c
codecs/codec_speex.c
codecs/codec_ulaw.c
funcs/func_config.c
funcs/func_odbc.c
include/asterisk/config.h
main/asterisk.c
main/cdr.c
main/config.c
main/dnsmgr.c
main/dsp.c
main/enum.c
main/features.c
main/http.c
main/loader.c
main/manager.c
main/rtp.c
main/udptl.c
res/res_adsi.c
res/res_config_ldap.c
res/res_config_pgsql.c
res/res_config_sqlite.c
res/res_http_post.c
res/res_indications.c
res/res_jabber.c
res/res_musiconhold.c
res/res_odbc.c
res/res_phoneprov.c
res/res_smdi.c
res/res_snmp.c

index 37d8177..db76bbd 100644 (file)
@@ -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) {
index 131cd01..81298f4 100644 (file)
@@ -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);
 
index 59a82a2..69523ec 100644 (file)
@@ -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))
index d9659eb..4a929a3 100644 (file)
@@ -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);
index 0e23acb..7a4b1fd 100644 (file)
@@ -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);
 
index 823b74e..9ca81eb 100644 (file)
@@ -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);
index 4aed152..c151068 100644 (file)
@@ -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);
 
index 93968cc..34ddc05 100644 (file)
@@ -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)
index 356d325..b905a93 100644 (file)
@@ -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);
index 3f9c9c6..4f6d160 100644 (file)
@@ -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 */
index be52773..b3a26dd 100644 (file)
@@ -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);
        }
index 66df949..90e0795 100644 (file)
@@ -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;
        }
index 5f5afbd..83dbd38 100644 (file)
@@ -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) {
index 9a6f728..66fecd5 100644 (file)
@@ -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) {
index 92777f5..3511e0b 100644 (file)
@@ -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);
index 5a9e1a5..25e76b5 100644 (file)
@@ -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 */
index 76b4f9a..4a11b56 100644 (file)
@@ -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));
index fc0c7f3..36f8cd5 100644 (file)
@@ -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) {
index 31d9ccf..32ebe34 100644 (file)
@@ -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) {
index 6284618..d239fd7 100644 (file)
@@ -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));
index a5c54d4..644e7b7 100644 (file)
@@ -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;
index b3c29c0..125fa15 100644 (file)
@@ -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 {
index 5ac5469..d6030bb 100644 (file)
@@ -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) {
index 865b98f..ea1a0e3 100644 (file)
@@ -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);
index 9ab3852..b25d492 100644 (file)
@@ -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) {
index a605c6b..48a41fc 100644 (file)
@@ -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 */
index 5cdf541..2090115 100644 (file)
@@ -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")) {
index a261ded..04d4048 100644 (file)
@@ -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")) {
index 4c6ee32..47fabc7 100644 (file)
@@ -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) {
index b221ab2..41e1780 100644 (file)
@@ -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")) {
index 80e0e8e..38d461a 100644 (file)
@@ -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")) {
index defc1d8..1664632 100644 (file)
@@ -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")) {
index abea9d2..9237f70 100644 (file)
@@ -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")) {
index 734491c..961aaa6 100644 (file)
@@ -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) {
index d58abe9..799b963 100644 (file)
@@ -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")) {
index 6bed8a9..5669f36 100644 (file)
@@ -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;
index b6a17ff..24034bb 100644 (file)
@@ -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);
index a12d12b..8c9a1d3 100644 (file)
@@ -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
index d8dc99b..0aa9f9a 100644 (file)
@@ -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) {
index b977362..cf9d1bc 100644 (file)
@@ -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);
 
index 40b116a..870aaed 100644 (file)
@@ -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;
index 2df778b..7ff7a4f 100644 (file)
@@ -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);
index f3adcf0..e5db83c 100644 (file)
@@ -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;
index 6f821c2..d10864c 100644 (file)
@@ -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);
index c8ce6cc..275c006 100644 (file)
@@ -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;
        }
index 7601158..b1bb878 100644 (file)
@@ -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;
        }
 
index 735459f..e8a5662 100644 (file)
@@ -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;
        }
index 4aa1be6..7d57eb6 100644 (file)
@@ -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;
        }
index b4d7734..2f4bca4 100644 (file)
@@ -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;
index 6b14ec5..ad1c96d 100644 (file)
@@ -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;
index 385ad26..4d2aaaa 100644 (file)
@@ -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);
index 0406607..916ce8f 100644 (file)
@@ -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;
        }
index 214d9ee..c42e35e 100644 (file)
@@ -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;
        }
index 448fab3..05dc64d 100644 (file)
@@ -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;
        }
index 2e4a20a..3e265c4 100644 (file)
@@ -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;
        }
 
index af56444..7fdca5b 100644 (file)
@@ -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);
index 8f8f91a..38b1b59 100644 (file)
@@ -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;
        }
index 9a34c29..9fce794 100644 (file)
@@ -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);
index 7a5d7b3..384696d 100644 (file)
@@ -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;
        }
index 54c0942..ddb2b4d 100644 (file)
@@ -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;
        }
index 6a5cf1a..88f562b 100644 (file)
@@ -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
index 71a79f2..f3cedfb 100644 (file)
@@ -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;
        }