]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
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 37d8177429f4907799aabe397f7062287785f3f9..db76bbdb770a5088ad2ebe65ad8522b31953b4b4 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 131cd01fd260b4a2d1c12bc58d78e884c485bbb5..81298f4009e342093049fb02259f6990f713ba56 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 59a82a23877939ab2534c6371792fa8fa3e088c1..69523ec65eeab0c2a60d7bb0d62099177d4c39d7 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 d9659ebef8fa2e993e624f7466dd20c5323ab2b4..4a929a3e51d4e30f66fd237c68f90d5d7aca4f12 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 0e23acbff504f82d3abcf9fb789e3a441c8af932..7a4b1fdc3d5654afcb35ba959b2e14afa65ca965 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 823b74efc146fee1a28fed882e892314c09767d7..9ca81eb081eea452f903c1343c34d6cef5241602 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 4aed1528e48c299bba751de6ac52ed3d0c5932b6..c151068df3826914a843890bf975e5788bf9e2ca 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 93968ccee8ee0bc4342bcd3e0fff1fbd1892da2d..34ddc05a8a39ed910fb8be9c7250d0a6b786a789 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 356d325b47ff8e8b831719397c67e3cac8282fb8..b905a93357647c9c8b01f3aeafab01daeab5e430 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 3f9c9c6253e4ccbaedc08b40e8e484109c8f1f33..4f6d160ea668b951d371c7d903326cea047c480c 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 be52773ac9e1ee359367decfb161b08086d1b062..b3a26dd7b886e2a3b505428790c37039ca229a4a 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 66df9496896146f5b234f538ad16abb2222702bc..90e0795b7268f08f034e585909c5bd01454f7ba5 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 5f5afbd43de1e4a5d08bc4d452c403c766792b02..83dbd38e46b618fdef58c303b18af3f38c02499a 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 9a6f7287c7dbdd9703c3911c6c934570952475f1..66fecd5647131b2cf06d3efdcc0c6281cf3e0eb9 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 92777f5ea06e7db31c5b839c09e5cfa726b5b80e..3511e0bacbcaed772bb9e45ed9cbd0296e773e25 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 5a9e1a510dafcc24d5da26135dbfff420a8d6113..25e76b5af5b05b53b00523219a5129ca7ed20ddb 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 76b4f9ad1152aff5ed7548ab0f3b49fae91127c0..4a11b56a824c70382ab8aa6427e3ef85c64aa5c3 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 fc0c7f3c0e2040951bfcb3626ba091f7100483a1..36f8cd5eb89cfa5e0fb3d438e9a7dd9f3a5b2d34 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 31d9ccf2eb0cb3e01e2ad71f98dd395a9750b9fb..32ebe341be7339b6f48d8f88988e97defea27847 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 6284618872d7d29264ed2fade586ec4923d2d5d0..d239fd717fc0354956322a92f4df19989d022b63 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 a5c54d4b98016ea37289c8ef041be5df18b0c8a8..644e7b787f1edd5706f10004839a70419da7e9f9 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 b3c29c0315a145ba1ce3c1660eb309f4d014263c..125fa156d4304fd8eecb6c75d9153761eae7d0ee 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 5ac54694dc7f27fa072037e3cc450097fee0ebff..d6030bbf13c2d91df14474c2429cf48ab0a8548e 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 865b98f63436ea71e7b28d8de5d6c7008ff9e805..ea1a0e3272e1606bc27ccca0ce59371457df9880 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 9ab38521d305c02ad2130572bf0f1d973e6b739d..b25d492b92d33cca78a2bab826509676549bdbd6 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 a605c6be7ca91c50937a7c9fb73a61373caf1d12..48a41fc7ab8b1c54d7f867d95158b98fadc2b12f 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 5cdf541765041384e3bd6eb4eb432e9dff8e12be..20901151bb1fbf666f7966399e53eece849b58cc 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 a261dedb7ad64f072fe86051fad271831754c7b0..04d4048b848bd478b27ac7d813648eb461536cad 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 4c6ee32694b7dd7c875aabef6bebf6dd5f2106ac..47fabc7c0349c2c579e961ea52433679ef16f438 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 b221ab20fd2344bae5d64a1ebfdee92fad08d8ae..41e17807f40df97e18503575bf938d1fd6288b9f 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 80e0e8ea982c4b51c5e9034501f522fa31ca6105..38d461a1c3703bef634b9857471d93c5d4eeaa59 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 defc1d8988df143f85078d2f43c2b7fe040c6ed2..1664632a4645e207246a784b331f0db908ca6f54 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 abea9d2043ce9535877a523eb2e2dd59beb32e0d..9237f70fea2cae2b8d7fb867bb45840e2b8d6756 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 734491c75d136b7e372b5c8cbff46b47ad4cd71b..961aaa649d11ee029c839af4cc3567d1fdca1b41 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 d58abe9267a5e0e11f00c29906c75afc7b65ae3c..799b96357f7b2fca1dff79b9cd045a12ee8142c2 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 6bed8a9b2b61483dabb1992af3efc95df5837f86..5669f36559bfbde1222e1a1dd9b469af2269d978 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 b6a17ffa218e23560f63a1c0e8df17444516e6ee..24034bb0d7e27779bcd07257997e19012ba5842e 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 a12d12bf62ab475a65778c27269ffbcb3a8a854a..8c9a1d3beb0a1a4870e47cddcc415f2f1d03774f 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 d8dc99b860ee4d7bae883abb635c062dd31674d6..0aa9f9a3d96573972bf6e711be9ee55184fb00da 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 b97736203ddd457bbcb1339ad8ef49cac0812724..cf9d1bc6135d4c906287e241c0e0afbdf9f88c50 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 40b116a479e9bbfd3a5acf1dcca749c31f439df9..870aaed57400c2f9341ac5a5d3a97435974bf732 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 2df778b45cc0f3e162ff57ac81a6f00d39c8fa31..7ff7a4f5d7eda87ca67290224f58badccb502332 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 f3adcf0bef72fddb419ca52fdf2144daff0c240c..e5db83cd554c8ec492691aabdbdbbd9dd9b65d8b 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 6f821c26d333fa5aa47bd2f1ec07eccfa6df886c..d10864c0bd2c327688c6d78ded03de7df44c182d 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 c8ce6ccde07d0104f279926e29718995299e4477..275c006bd946daebc1b6c4bd8596d6c588ae5aab 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 7601158bb8717304aeb78a85777cde0a0ebc194a..b1bb878f76a43cc6934d8b7eb4d3bbedd740f6fe 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 735459f040c0038d0852bc29dec80611a232ca7d..e8a5662efe46cb8bb685a13ce6a74338f158de95 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 4aa1be631f6d74c6093f7bfc86701563a1995f6b..7d57eb673817919d5b464ce4031bc082a098317e 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 b4d7734d112503553885cc408c66536938a71527..2f4bca429ecd202a55e8361d3df0a2f211d6a115 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 6b14ec56f349d7de792ab3c1a2242bb2d4770c52..ad1c96d63237967a5ca35f73bcae271121c3a3d8 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 385ad26171cedd29968d792cb5ef6a9cf30cf0d0..4d2aaaa8f020eada82995022445e25ccb472ea08 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 04066074d1b29f80469d7e61d3ec25d16e220112..916ce8fe775773b0d1a0fc46fc402c212558d336 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 214d9eeea6e1c4530625d5a2264967d45ec4eac3..c42e35e802b29334ed0d5a0fe9cd940f06406667 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 448fab32b65092da2aa66f96efcb847aee7bf379..05dc64d0a459228d443533e30105ee9848c4a554 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 2e4a20a1d44358afc05957d6c4ae85cdff7862ee..3e265c4d5b7a858642f6282bcfb717e420275aa6 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 af56444cd115b1e7661ecdc11bd7f864ed008475..7fdca5be37ec195bf7e0e686ee2c88a15f736299 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 8f8f91af89f6b990a6502bfdebb3e56bfdb1a657..38b1b5959e0710ee12aa96a5db11c78b68ee43dc 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 9a34c293f37620ef80199382863434d860aa1737..9fce79475c8bd6e44dac6ae113d2b8f672857e81 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 7a5d7b3dcb7c99b8e2cf1d529d1b96544779bf60..384696da34321dfc33afaaa5ea83e60946c57851 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 54c094294d4b65ece64f6d1d28a0f1a8d10ebf1f..ddb2b4d93abdd38cb0eadb06fea49fe21757736b 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 6a5cf1aa505f4349064c6c866645019379de2bce..88f562b2d7353681d79d1ca50be5d25c6d33b727 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 71a79f2096905f88136b83d144adcc1e643642fc..f3cedfb1d6123ca763a95154d3f93dad62ecca3b 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;
        }