mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-24 05:38:11 +00:00
ignore non-regular files during config parsing (issue #5510, different fix)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6902 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
34
config.c
34
config.c
@@ -30,6 +30,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
#define AST_INCLUDE_GLOB 1
|
#define AST_INCLUDE_GLOB 1
|
||||||
#ifdef AST_INCLUDE_GLOB
|
#ifdef AST_INCLUDE_GLOB
|
||||||
#ifdef __Darwin__
|
#ifdef __Darwin__
|
||||||
@@ -538,6 +539,7 @@ static struct ast_config *config_text_file_load(const char *database, const char
|
|||||||
int comment = 0, nest[MAX_NESTED_COMMENTS];
|
int comment = 0, nest[MAX_NESTED_COMMENTS];
|
||||||
struct ast_category *cat = NULL;
|
struct ast_category *cat = NULL;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
struct stat statbuf;
|
||||||
|
|
||||||
cat = ast_config_get_current_category(cfg);
|
cat = ast_config_get_current_category(cfg);
|
||||||
|
|
||||||
@@ -569,11 +571,26 @@ static struct ast_config *config_text_file_load(const char *database, const char
|
|||||||
for (i=0; i<globbuf.gl_pathc; i++) {
|
for (i=0; i<globbuf.gl_pathc; i++) {
|
||||||
ast_copy_string(fn, globbuf.gl_pathv[i], sizeof(fn));
|
ast_copy_string(fn, globbuf.gl_pathv[i], sizeof(fn));
|
||||||
#endif
|
#endif
|
||||||
if ((option_verbose > 1) && !option_debug) {
|
do {
|
||||||
ast_verbose( VERBOSE_PREFIX_2 "Parsing '%s': ", fn);
|
if (stat(fn, &statbuf)) {
|
||||||
fflush(stdout);
|
ast_log(LOG_WARNING, "Cannot stat() '%s', ignoring\n", fn);
|
||||||
}
|
continue;
|
||||||
if ((f = fopen(fn, "r"))) {
|
}
|
||||||
|
if (!S_ISREG(statbuf.st_mode)) {
|
||||||
|
ast_log(LOG_WARNING, "'%s' is not a regular file, ignoring\n", fn);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ((option_verbose > 1) && !option_debug) {
|
||||||
|
ast_verbose(VERBOSE_PREFIX_2 "Parsing '%s': ", fn);
|
||||||
|
fflush(stdout);
|
||||||
|
}
|
||||||
|
if (!(f = fopen(fn, "r"))) {
|
||||||
|
if (option_debug)
|
||||||
|
ast_log(LOG_DEBUG, "No file to parse: %s\n", fn);
|
||||||
|
else if (option_verbose > 1)
|
||||||
|
ast_verbose( "Not found (%s)\n", strerror(errno));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
count++;
|
count++;
|
||||||
if (option_debug)
|
if (option_debug)
|
||||||
ast_log(LOG_DEBUG, "Parsing %s\n", fn);
|
ast_log(LOG_DEBUG, "Parsing %s\n", fn);
|
||||||
@@ -641,12 +658,7 @@ static struct ast_config *config_text_file_load(const char *database, const char
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose(f);
|
fclose(f);
|
||||||
} else { /* can't open file */
|
} while(0);
|
||||||
if (option_debug)
|
|
||||||
ast_log(LOG_DEBUG, "No file to parse: %s\n", fn);
|
|
||||||
else if (option_verbose > 1)
|
|
||||||
ast_verbose( "Not found (%s)\n", strerror(errno));
|
|
||||||
}
|
|
||||||
if (comment) {
|
if (comment) {
|
||||||
ast_log(LOG_WARNING,"Unterminated comment detected beginning on line %d\n", nest[comment]);
|
ast_log(LOG_WARNING,"Unterminated comment detected beginning on line %d\n", nest[comment]);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user