]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Fix checking for CONFIG_STATUS_FILEINVALID so that modules don't crash upon trying...
authorTerry Wilson <twilson@digium.com>
Wed, 19 Nov 2008 19:25:14 +0000 (19:25 +0000)
committerTerry Wilson <twilson@digium.com>
Wed, 19 Nov 2008 19:25:14 +0000 (19:25 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@157818 65c4cc65-6c06-0410-ace0-fbb531ad65f3

19 files changed:
cdr/cdr_adaptive_odbc.c
cdr/cdr_csv.c
cdr/cdr_custom.c
cdr/cdr_manager.c
cdr/cdr_odbc.c
cdr/cdr_pgsql.c
cdr/cdr_radius.c
cdr/cdr_sqlite3_custom.c
cdr/cdr_tds.c
channels/chan_skinny.c
channels/chan_usbradio.c
channels/chan_vpb.cc
channels/iax2-provision.c
channels/misdn_config.c
main/logger.c
main/xmldoc.c
pbx/pbx_dundi.c
res/ais/evt.c
res/res_clialiases.c

index 17e70fadaacec20b0f20e8fc29f319b7c9c37239..85b54e52c049d14682cdea57286556a588f9120d 100644 (file)
@@ -97,7 +97,7 @@ static int load_config(void)
        struct ast_flags config_flags = { 0 }; /* Part of our config comes from the database */
 
        cfg = ast_config_load(CONFIG, config_flags);
-       if (!cfg) {
+       if (!cfg || cfg == CONFIG_STATUS_FILEINVALID) {
                ast_log(LOG_WARNING, "Unable to load " CONFIG ".  No adaptive ODBC CDRs.\n");
                return -1;
        }
index 10fa0c1acba890c98174daf8bff71765b056f5bf..eb0619b7d67a61bc46ed128d9a5f1ce7d127c6fc 100644 (file)
@@ -100,7 +100,7 @@ static int load_config(int reload)
        loguniqueid = 0;
        loguserfield = 0;
 
-       if (!(cfg = ast_config_load(config, config_flags))) {
+       if (!(cfg = ast_config_load(config, config_flags)) || cfg == CONFIG_STATUS_FILEINVALID) {
                ast_log(LOG_WARNING, "unable to load config: %s\n", config);
                return 0;
        } else if (cfg == CONFIG_STATUS_FILEUNCHANGED)
index 6ecef8af4242e8ef6f2b016dcb412f25aaa873c1..45207750a20fe2c3883d7752cc5bc9af4ef8236a 100644 (file)
@@ -67,6 +67,11 @@ static int load_config(int reload)
        if ((cfg = ast_config_load("cdr_custom.conf", config_flags)) == CONFIG_STATUS_FILEUNCHANGED)
                return 0;
 
+       if (cfg == CONFIG_STATUS_FILEINVALID) {
+               ast_log(LOG_ERROR, "Invalid config file\n");
+               return 1;
+       }
+
        strcpy(format, "");
        strcpy(master, "");
        ast_mutex_lock(&lock);
index 8b2ab215d4d180c13a10db2a6e52520d1646ea10..4dad2306f94e0df4fe2225315add73b570d91607 100644 (file)
@@ -62,6 +62,11 @@ static int load_config(int reload)
        if (cfg == CONFIG_STATUS_FILEUNCHANGED)
                return 0;
 
+       if (cfg == CONFIG_STATUS_FILEINVALID) {
+               ast_log(LOG_ERROR, "Config file '%s' could not be parsed\n", CONF_FILE);
+               return 1;
+       }
+
        if (reload && customfields) {
                ast_free(customfields);
        }
index d4db02b52b9670f32ea92979f0be189587503260..3c2cfb2ec3161d9a76c2117cb719bf0ded8500cc 100644 (file)
@@ -161,7 +161,7 @@ static int odbc_load_module(int reload)
 
        do {
                cfg = ast_config_load(config_file, config_flags);
-               if (!cfg) {
+               if (!cfg || cfg == CONFIG_STATUS_FILEINVALID) {
                        ast_log(LOG_WARNING, "cdr_odbc: Unable to load config for ODBC CDR's: %s\n", config_file);
                        res = AST_MODULE_LOAD_DECLINE;
                        break;
@@ -228,7 +228,7 @@ static int odbc_load_module(int reload)
                }
        } while (0);
 
-       if (cfg && cfg != CONFIG_STATUS_FILEUNCHANGED)
+       if (cfg && cfg != CONFIG_STATUS_FILEUNCHANGED && cfg != CONFIG_STATUS_FILEINVALID)
                ast_config_destroy(cfg);
        return res;
 }
index c6e17381f936dea7fca12b8ae1b42a66e978f1d0..c56bf97f1524c109e56880d2e803a20eae0d04fa 100644 (file)
@@ -370,7 +370,7 @@ static int config_module(int reload)
        struct ast_config *cfg;
        struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
 
-       if ((cfg = ast_config_load(config, config_flags)) == NULL) {
+       if ((cfg = ast_config_load(config, config_flags)) == NULL || cfg == CONFIG_STATUS_FILEINVALID) {
                ast_log(LOG_WARNING, "Unable to load config for PostgreSQL CDR's: %s\n", config);
                return -1;
        } else if (cfg == CONFIG_STATUS_FILEUNCHANGED)
index d326eba6455f689bcf27cbb088e8eb01e3a21160..2251f149dd97a2c14264b88e1f571883ee78ab53 100644 (file)
@@ -228,7 +228,7 @@ static int load_module(void)
        int res;
        const char *tmp;
 
-       if ((cfg = ast_config_load(cdr_config, config_flags))) {
+       if ((cfg = ast_config_load(cdr_config, config_flags)) && cfg != CONFIG_STATUS_FILEINVALID) {
                ast_set2_flag(&global_flags, ast_true(ast_variable_retrieve(cfg, "radius", "usegmtime")), RADIUS_FLAG_USEGMTIME);
                ast_set2_flag(&global_flags, ast_true(ast_variable_retrieve(cfg, "radius", "loguniqueid")), RADIUS_FLAG_LOGUNIQUEID);
                ast_set2_flag(&global_flags, ast_true(ast_variable_retrieve(cfg, "radius", "loguserfield")), RADIUS_FLAG_LOGUSERFIELD);
index b617ab579e09b41f3f5011e5317b9756c9b40a14..898e415ae23948a3151f00b5c6a875df3985dce1 100644 (file)
@@ -158,7 +158,7 @@ static int load_config(int reload)
        struct ast_variable *mappingvar;
        const char *tmp;
 
-       if (!(cfg = ast_config_load(config_file, config_flags))) {
+       if (!(cfg = ast_config_load(config_file, config_flags)) || cfg == CONFIG_STATUS_FILEINVALID) {
                if (reload)
                        ast_log(LOG_WARNING, "Failed to reload configuration file.\n");
                else
index fd3f32864e703852441b2bfd0e846394323b523a..e05f21453490f771826c3224f6fcdd7e7dd54b49 100644 (file)
@@ -426,7 +426,7 @@ static int tds_load_module(int reload)
        struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
 
        cfg = ast_config_load(config, config_flags);
-       if (!cfg) {
+       if (!cfg || cfg == CONFIG_STATUS_FILEINVALID) {
                ast_log(LOG_NOTICE, "Unable to load TDS config for CDRs: %s\n", config);
                return 0;
        } else if (cfg == CONFIG_STATUS_FILEUNCHANGED)
index a72345cfe42739d39cac3e5d31e57ce09b734152..04c700559b5a50e0a573e7c49f6a7c43640c961a 100644 (file)
@@ -6477,7 +6477,7 @@ static struct ast_channel *skinny_request(const char *type, int format, void *da
        cfg = ast_config_load(config, config_flags);
   
        /* We *must* have a config file otherwise stop immediately */
-       if (!cfg) {
+       if (!cfg || cfg == CONFIG_STATUS_FILEINVALID) {
                ast_log(LOG_NOTICE, "Unable to load config %s, Skinny disabled.\n", config);
                return -1;
        }
index bc1dbb3c2396f93692c9548fd222e39b22f90c1b..df5bad5411401ee880ccdc12fc048c80b7d9e45f 100644 (file)
@@ -3510,7 +3510,7 @@ static struct chan_usbradio_pvt *store_config(struct ast_config *cfg, char *ctg)
        o->txctcssadj = 200;
        o->rxsquelchadj = 500;
        o->devstr[0] = 0;
-       if (cfg1) {
+       if (cfg1 && cfg1 != CONFIG_STATUS_FILEINVALID) {
                for (v = ast_variable_browse(cfg1, o->name); v; v = v->next) {
        
                        M_START((char *)v->name, (char *)v->value);
@@ -3942,9 +3942,9 @@ static int load_module(void)
 
        /* load config file */
 #ifdef NEW_ASTERISK
-       if (!(cfg = ast_config_load(config,zeroflag))) {
+       if (!(cfg = ast_config_load(config,zeroflag)) || cfg == CONFIG_STATUS_FILEINVALID) {
 #else
-       if (!(cfg = ast_config_load(config))) {
+       if (!(cfg = ast_config_load(config))) || cfg == CONFIG_STATUS_FILEINVALID {
 #endif
                ast_log(LOG_NOTICE, "Unable to load config %s\n", config);
                return AST_MODULE_LOAD_DECLINE;
index b8ca240110f4900f675b19d49421b8d442d2c0bd..f7223127636276f984588e80c41e6e75690b539c 100644 (file)
@@ -2714,7 +2714,7 @@ static enum ast_module_load_result load_module()
        cfg = ast_config_load(config, config_flags);
 
        /* We *must* have a config file otherwise stop immediately */
-       if (!cfg) {
+       if (!cfg || cfg == CONFIG_STATUS_FILEINVALID) {
                ast_log(LOG_ERROR, "Unable to load config %s\n", config);
                return AST_MODULE_LOAD_DECLINE;
        }  
index 8bdfdbfb72b23f4a321c64ae47fd3908e8898345..7278819b7b509880bb55736ff0437fbf8fd204ad 100644 (file)
@@ -493,7 +493,7 @@ int iax_provision_reload(int reload)
                iax_provision_init();
        
        cfg = ast_config_load2("iaxprov.conf", "chan_iax2", config_flags);
-       if (cfg != NULL && cfg != CONFIG_STATUS_FILEUNCHANGED) {
+       if (cfg != NULL && cfg != CONFIG_STATUS_FILEUNCHANGED && cfg != CONFIG_STATUS_FILEINVALID) {
                /* Mark all as dead.  No need for locking */
                cur = templates;
                while(cur) {
index fb0739356f6e3cbf8f1471fdb06d029577e93891..12a742cf347f81ff4340d66e917e2c9b3f609e6a 100644 (file)
@@ -1101,8 +1101,8 @@ int misdn_cfg_init(int this_max_ports, int reload)
        struct ast_variable *v;
        struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
 
-       if (!(cfg = ast_config_load2(config, "chan_misdn", config_flags))) {
-               ast_log(LOG_WARNING, "missing file: misdn.conf\n");
+       if (!(cfg = ast_config_load2(config, "chan_misdn", config_flags)) || cfg == CONFIG_STATUS_FILEINVALID) {
+               ast_log(LOG_WARNING, "missing or invalid file: misdn.conf\n");
                return -1;
        } else if (cfg == CONFIG_STATUS_FILEUNCHANGED)
                return 0;
index b4f4c4dd0cb364acfded86e74c514bd4ec67be60..2c312eecc601b89403a10ec1716ef4168ec2bfff 100644 (file)
@@ -326,7 +326,7 @@ static void init_logger_chain(int locked)
        const char *s;
        struct ast_flags config_flags = { 0 };
 
-       if (!(cfg = ast_config_load2("logger.conf", "logger", config_flags)))
+       if (!(cfg = ast_config_load2("logger.conf", "logger", config_flags)) || cfg == CONFIG_STATUS_FILEINVALID)
                return;
 
        /* delete our list of log channels */
index c3c9e80c195a55da1ead7fed3b1a4b96a52c428b..273ddc6ca690a36d929758f76a9df162cfa713c6 100644 (file)
@@ -1721,7 +1721,7 @@ int ast_xmldoc_load_documentation(void)
        /* setup default XML documentation language */
        snprintf(documentation_language, sizeof(documentation_language), default_documentation_language);
 
-       if ((cfg = ast_config_load2("asterisk.conf", "" /* core can't reload */, cnfflags))) {
+       if ((cfg = ast_config_load2("asterisk.conf", "" /* core can't reload */, cnfflags)) && cfg != CONFIG_STATUS_FILEINVALID) {
                for (var = ast_variable_browse(cfg, "options"); var; var = var->next) {
                        if (!strcasecmp(var->name, "documentation_language")) {
                                if (!ast_strlen_zero(var->value)) {
index 2b2ff6ef83a344ad3f36442781ea1bd5de013b4b..08177723f828e42164228fb31974b4b0dba14bbb 100644 (file)
@@ -4558,7 +4558,7 @@ static int set_config(char *config_file, struct sockaddr_in* sin, int reload)
        int globalpcmodel = 0;
        dundi_eid testeid;
 
-       if (!(cfg = ast_config_load(config_file, config_flags))) {
+       if (!(cfg = ast_config_load(config_file, config_flags)) || cfg == CONFIG_STATUS_FILEINVALID) {
                ast_log(LOG_ERROR, "Unable to load config %s\n", config_file);
                return -1;
        } else if (cfg == CONFIG_STATUS_FILEUNCHANGED)
index 2965df0e35c97762d97ab9f70797b9a8532e6a5f..5de26e39c0eb0ae2350d80c6d2da723b0a26c162 100644 (file)
@@ -475,7 +475,7 @@ static void load_config(void)
        const char *cat = NULL;
        struct ast_flags config_flags = { 0 };
 
-       if (!(cfg = ast_config_load(filename, config_flags)))
+       if (!(cfg = ast_config_load(filename, config_flags)) || cfg == CONFIG_STATUS_FILEINVALID)
                return;
 
        while ((cat = ast_category_browse(cfg, cat))) {
index a20947bb19af44884b63b2dd342447cdc17870ac..2d9a396a73164b0d5d8382c2a92de48372517bac 100644 (file)
@@ -190,7 +190,7 @@ static void load_config(int reload)
        struct cli_alias *alias;
        struct ast_variable *v, *v1;
 
-       if (!(cfg = ast_config_load(config_file, config_flags))) {
+       if (!(cfg = ast_config_load(config_file, config_flags)) || cfg == CONFIG_STATUS_FILEINVALID) {
                ast_log(LOG_ERROR, "res_clialiases configuration file '%s' not found\n", config_file);
                return;
        } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) {