aboutsummaryrefslogtreecommitdiffstats
path: root/res
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2008-09-12 23:30:03 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2008-09-12 23:30:03 +0000
commit95bae857590d3ca7e1bb44f384014d691442eb00 (patch)
tree790035cc6aca2440080bd357a68a09fdbbb2624c /res
parentcdf54b5bc1d32ecbb11e9cb465514ad0298de20b (diff)
Create a new config file status, CONFIG_STATUS_FILEINVALID for differentiating
when a file is invalid from when a file is missing. This is most important when we have two configuration files. Consider the following example: Old system: sip.conf users.conf Old result New result ======== ========== ========== ========== Missing Missing SIP doesn't load SIP doesn't load Missing OK SIP doesn't load SIP doesn't load Missing Invalid SIP doesn't load SIP doesn't load OK Missing SIP loads SIP loads OK OK SIP loads SIP loads OK Invalid SIP loads incompletely SIP doesn't load Invalid Missing SIP doesn't load SIP doesn't load Invalid OK SIP doesn't load SIP doesn't load Invalid Invalid SIP doesn't load SIP doesn't load So in the case when users.conf doesn't load because there's a typo that disrupts the syntax, we may only partially load users, instead of failing with an error, which may cause some calls not to get processed. Worse yet, the old system would do this with no indication that anything was even wrong. (closes issue #10690) Reported by: dtyoo Patches: 20080716__bug10690.diff.txt uploaded by Corydon76 (license 14) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@142992 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res')
-rw-r--r--res/res_adsi.c6
-rw-r--r--res/res_config_ldap.c3
-rw-r--r--res/res_config_pgsql.c6
-rw-r--r--res/res_config_sqlite.c2
-rw-r--r--res/res_http_post.c3
-rw-r--r--res/res_indications.c5
-rw-r--r--res/res_jabber.c2
-rw-r--r--res/res_musiconhold.c3
-rw-r--r--res/res_odbc.c2
-rw-r--r--res/res_phoneprov.c6
-rw-r--r--res/res_smdi.c2
-rw-r--r--res/res_snmp.c2
12 files changed, 23 insertions, 19 deletions
diff --git a/res/res_adsi.c b/res/res_adsi.c
index 385ad2617..4d2aaaa8f 100644
--- a/res/res_adsi.c
+++ b/res/res_adsi.c
@@ -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);
diff --git a/res/res_config_ldap.c b/res/res_config_ldap.c
index 04066074d..916ce8fe7 100644
--- a/res/res_config_ldap.c
+++ b/res/res_config_ldap.c
@@ -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;
}
diff --git a/res/res_config_pgsql.c b/res/res_config_pgsql.c
index 214d9eeea..c42e35e80 100644
--- a/res/res_config_pgsql.c
+++ b/res/res_config_pgsql.c
@@ -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;
}
diff --git a/res/res_config_sqlite.c b/res/res_config_sqlite.c
index 448fab32b..05dc64d0a 100644
--- a/res/res_config_sqlite.c
+++ b/res/res_config_sqlite.c
@@ -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;
}
diff --git a/res/res_http_post.c b/res/res_http_post.c
index 2e4a20a1d..3e265c4d5 100644
--- a/res/res_http_post.c
+++ b/res/res_http_post.c
@@ -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;
}
diff --git a/res/res_indications.c b/res/res_indications.c
index af56444cd..7fdca5be3 100644
--- a/res/res_indications.c
+++ b/res/res_indications.c
@@ -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);
diff --git a/res/res_jabber.c b/res/res_jabber.c
index 8f8f91af8..38b1b5959 100644
--- a/res/res_jabber.c
+++ b/res/res_jabber.c
@@ -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;
}
diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c
index 9a34c293f..9fce79475 100644
--- a/res/res_musiconhold.c
+++ b/res/res_musiconhold.c
@@ -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);
diff --git a/res/res_odbc.c b/res/res_odbc.c
index 7a5d7b3dc..384696da3 100644
--- a/res/res_odbc.c
+++ b/res/res_odbc.c
@@ -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;
}
diff --git a/res/res_phoneprov.c b/res/res_phoneprov.c
index 54c094294..ddb2b4d93 100644
--- a/res/res_phoneprov.c
+++ b/res/res_phoneprov.c
@@ -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;
}
diff --git a/res/res_smdi.c b/res/res_smdi.c
index 6a5cf1aa5..88f562b2d 100644
--- a/res/res_smdi.c
+++ b/res/res_smdi.c
@@ -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
diff --git a/res/res_snmp.c b/res/res_snmp.c
index 71a79f209..f3cedfb1d 100644
--- a/res/res_snmp.c
+++ b/res/res_snmp.c
@@ -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;
}