diff options
author | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-09-12 23:30:03 +0000 |
---|---|---|
committer | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-09-12 23:30:03 +0000 |
commit | 95bae857590d3ca7e1bb44f384014d691442eb00 (patch) | |
tree | 790035cc6aca2440080bd357a68a09fdbbb2624c /main/config.c | |
parent | cdf54b5bc1d32ecbb11e9cb465514ad0298de20b (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 'main/config.c')
-rw-r--r-- | main/config.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/main/config.c b/main/config.c index 40b116a47..870aaed57 100644 --- a/main/config.c +++ b/main/config.c @@ -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; |