aboutsummaryrefslogtreecommitdiffstats
path: root/main/asterisk/ASTERISK-19107.patch
blob: cb43615b24e0ec2f6a367b0b18288e3f1cbc26c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
diff --git a/main/config.c b/main/config.c
index 498ae99..0f5f0e2 100644
--- a/main/config.c
+++ b/main/config.c
@@ -1199,9 +1199,11 @@ static int process_text_line(struct ast_config *cfg, struct ast_category **cat,
 		if (newcat)
 			ast_category_append(cfg, *cat);
 	} else if (cur[0] == '#') { /* A directive - #include or #exec */
+		struct ast_config *res;
 		char *cur2;
 		char real_inclusion_name[256];
 		int do_include = 0;	/* otherwise, it is exec */
+		int quiet = 0;
 
 		cur++;
 		c = cur;
@@ -1221,6 +1223,9 @@ static int process_text_line(struct ast_config *cfg, struct ast_category **cat,
 		}
 		if (!strcasecmp(cur, "include")) {
 			do_include = 1;
+		} else if (!strcasecmp(cur, "-include")) {
+			do_include = 1;
+			quiet = 1;
 		} else if (!strcasecmp(cur, "exec")) {
 			if (!ast_opt_exec_includes) {
 				ast_log(LOG_WARNING, "Cannot perform #exec unless execincludes option is enabled in asterisk.conf (options section)!\n");
@@ -1233,7 +1238,7 @@ static int process_text_line(struct ast_config *cfg, struct ast_category **cat,
 
 		if (c == NULL) {
 			ast_log(LOG_WARNING, "Directive '#%s' needs an argument (%s) at line %d of %s\n", 
-					do_include ? "include" : "exec",
+					cur,
 					do_include ? "filename" : "/path/to/executable",
 					lineno,
 					configfile);
@@ -1275,10 +1280,13 @@ static int process_text_line(struct ast_config *cfg, struct ast_category **cat,
 		/* record this inclusion */
 		ast_include_new(cfg, cfg->include_level == 1 ? "" : configfile, cur, !do_include, cur2, lineno, real_inclusion_name, sizeof(real_inclusion_name));
 
-		do_include = ast_config_internal_load(cur, cfg, flags, real_inclusion_name, who_asked) ? 1 : 0;
+		res = ast_config_internal_load(cur, cfg, flags, real_inclusion_name, who_asked);
 		if (!ast_strlen_zero(exec_file))
 			unlink(exec_file);
-		if (!do_include) {
+		if (res == CONFIG_STATUS_FILEINVALID) {
+			ast_log(LOG_ERROR, "The file '%s' was listed as a #include but it failed to load.\n", cur);
+			return -1;
+		} else if (res == CONFIG_STATUS_FILEMISSING && !quiet) {
 			ast_log(LOG_ERROR, "The file '%s' was listed as a #include but it does not exist.\n", cur);
 			return -1;
 		}
@@ -1643,7 +1651,7 @@ static struct ast_config *config_text_file_load(const char *database, const char
 	}
 	
 	if (count == 0)
-		return NULL;
+		return CONFIG_STATUS_FILEMISSING;
 
 	return cfg;
 }