aboutsummaryrefslogtreecommitdiffstats
path: root/cdr
diff options
context:
space:
mode:
authortwilson <twilson@f38db490-d61c-443f-a65b-d21fe96a405b>2008-11-19 19:25:14 +0000
committertwilson <twilson@f38db490-d61c-443f-a65b-d21fe96a405b>2008-11-19 19:25:14 +0000
commitf93ebdba02a7563314d5417a63a7e2de516663c1 (patch)
treed96fa0b3cb5fba3fb499b6f6faf3fd29f768cc8d /cdr
parent84d63d33cab0213edc53a79bfae943c0fe38a252 (diff)
Fix checking for CONFIG_STATUS_FILEINVALID so that modules don't crash upon trying to parse an invalid config
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@157818 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'cdr')
-rw-r--r--cdr/cdr_adaptive_odbc.c2
-rw-r--r--cdr/cdr_csv.c2
-rw-r--r--cdr/cdr_custom.c5
-rw-r--r--cdr/cdr_manager.c5
-rw-r--r--cdr/cdr_odbc.c4
-rw-r--r--cdr/cdr_pgsql.c2
-rw-r--r--cdr/cdr_radius.c2
-rw-r--r--cdr/cdr_sqlite3_custom.c2
-rw-r--r--cdr/cdr_tds.c2
9 files changed, 18 insertions, 8 deletions
diff --git a/cdr/cdr_adaptive_odbc.c b/cdr/cdr_adaptive_odbc.c
index 17e70fada..85b54e52c 100644
--- a/cdr/cdr_adaptive_odbc.c
+++ b/cdr/cdr_adaptive_odbc.c
@@ -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;
}
diff --git a/cdr/cdr_csv.c b/cdr/cdr_csv.c
index 10fa0c1ac..eb0619b7d 100644
--- a/cdr/cdr_csv.c
+++ b/cdr/cdr_csv.c
@@ -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)
diff --git a/cdr/cdr_custom.c b/cdr/cdr_custom.c
index 6ecef8af4..45207750a 100644
--- a/cdr/cdr_custom.c
+++ b/cdr/cdr_custom.c
@@ -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);
diff --git a/cdr/cdr_manager.c b/cdr/cdr_manager.c
index 8b2ab215d..4dad2306f 100644
--- a/cdr/cdr_manager.c
+++ b/cdr/cdr_manager.c
@@ -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);
}
diff --git a/cdr/cdr_odbc.c b/cdr/cdr_odbc.c
index d4db02b52..3c2cfb2ec 100644
--- a/cdr/cdr_odbc.c
+++ b/cdr/cdr_odbc.c
@@ -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;
}
diff --git a/cdr/cdr_pgsql.c b/cdr/cdr_pgsql.c
index c6e17381f..c56bf97f1 100644
--- a/cdr/cdr_pgsql.c
+++ b/cdr/cdr_pgsql.c
@@ -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)
diff --git a/cdr/cdr_radius.c b/cdr/cdr_radius.c
index d326eba64..2251f149d 100644
--- a/cdr/cdr_radius.c
+++ b/cdr/cdr_radius.c
@@ -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);
diff --git a/cdr/cdr_sqlite3_custom.c b/cdr/cdr_sqlite3_custom.c
index b617ab579..898e415ae 100644
--- a/cdr/cdr_sqlite3_custom.c
+++ b/cdr/cdr_sqlite3_custom.c
@@ -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
diff --git a/cdr/cdr_tds.c b/cdr/cdr_tds.c
index fd3f32864..e05f21453 100644
--- a/cdr/cdr_tds.c
+++ b/cdr/cdr_tds.c
@@ -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)