summaryrefslogtreecommitdiff
path: root/src/sp_config_keywords.c
diff options
context:
space:
mode:
authorjvoisin2017-09-25 14:04:21 +0200
committerjvoisin2017-09-25 14:04:21 +0200
commitbed568094b95b65a43c44d7b4d38aced394fce1c (patch)
treedfa1fece12df05adee964eb27b98b46cb5a34ead /src/sp_config_keywords.c
parent302dd00ff445a3b8257fa75bdb24ed354a513746 (diff)
Show the line number in case of processing error
Diffstat (limited to 'src/sp_config_keywords.c')
-rw-r--r--src/sp_config_keywords.c44
1 files changed, 22 insertions, 22 deletions
diff --git a/src/sp_config_keywords.c b/src/sp_config_keywords.c
index 4a6dd3a..b068bec 100644
--- a/src/sp_config_keywords.c
+++ b/src/sp_config_keywords.c
@@ -17,7 +17,7 @@ static int parse_enable(char *line, bool * restrict retval, bool * restrict simu
17 } 17 }
18 18
19 if (!(enable ^ disable)) { 19 if (!(enable ^ disable)) {
20 sp_log_err("config", "A rule can't be enabled and disabled."); 20 sp_log_err("config", "A rule can't be enabled and disabled on line %zu.", sp_line_no);
21 return -1; 21 return -1;
22 } 22 }
23 23
@@ -135,50 +135,50 @@ int parse_disabled_functions(char *line) {
135 if (df->value && df->regexp) { 135 if (df->value && df->regexp) {
136 sp_log_err("config", 136 sp_log_err("config",
137 "Invalid configuration line: 'sp.disabled_functions%s':" 137 "Invalid configuration line: 'sp.disabled_functions%s':"
138 "'.value' and '.regexp' are mutually exclusives.", 138 "'.value' and '.regexp' are mutually exclusives on line %zu.",
139 line); 139 line, sp_line_no);
140 return -1; 140 return -1;
141 } else if (df->r_function && df->function) { 141 } else if (df->r_function && df->function) {
142 sp_log_err("config", 142 sp_log_err("config",
143 "Invalid configuration line: 'sp.disabled_functions%s': " 143 "Invalid configuration line: 'sp.disabled_functions%s': "
144 "'.r_function' and '.function' are mutually exclusive.", 144 "'.r_function' and '.function' are mutually exclusive on line %zu.",
145 line); 145 line, sp_line_no);
146 return -1; 146 return -1;
147 } else if (df->r_filename && df->filename) { 147 } else if (df->r_filename && df->filename) {
148 sp_log_err("config", 148 sp_log_err("config",
149 "Invalid configuration line: 'sp.disabled_functions%s':" 149 "Invalid configuration line: 'sp.disabled_functions%s':"
150 "'.r_filename' and '.filename' are mutually exclusive.", 150 "'.r_filename' and '.filename' are mutually exclusive on line %zu.",
151 line); 151 line, sp_line_no);
152 return -1; 152 return -1;
153 } else if (df->r_param && df->param) { 153 } else if (df->r_param && df->param) {
154 sp_log_err("config", 154 sp_log_err("config",
155 "Invalid configuration line: 'sp.disabled_functions%s':" 155 "Invalid configuration line: 'sp.disabled_functions%s':"
156 "'.r_param' and '.param' are mutually exclusive.", 156 "'.r_param' and '.param' are mutually exclusive on line %zu.",
157 line); 157 line, sp_line_no);
158 return -1; 158 return -1;
159 } else if (df->r_ret && df->ret) { 159 } else if (df->r_ret && df->ret) {
160 sp_log_err("config", 160 sp_log_err("config",
161 "Invalid configuration line: 'sp.disabled_functions%s':" 161 "Invalid configuration line: 'sp.disabled_functions%s':"
162 "'.r_ret' and '.ret' are mutually exclusive.", 162 "'.r_ret' and '.ret' are mutually exclusive on line %zu.",
163 line); 163 line, sp_line_no);
164 return -1; 164 return -1;
165 } else if ((df->r_ret || df->ret) && (df->r_param || df->param)) { 165 } else if ((df->r_ret || df->ret) && (df->r_param || df->param)) {
166 sp_log_err("config", 166 sp_log_err("config",
167 "Invalid configuration line: 'sp.disabled_functions%s':" 167 "Invalid configuration line: 'sp.disabled_functions%s':"
168 "`ret` and `param` are mutually exclusives.", 168 "`ret` and `param` are mutually exclusive on line %zu.",
169 line); 169 line, sp_line_no);
170 return -1; 170 return -1;
171 } else if (!(df->r_function || df->function)) { 171 } else if (!(df->r_function || df->function)) {
172 sp_log_err("config", 172 sp_log_err("config",
173 "Invalid configuration line: 'sp.disabled_functions%s':" 173 "Invalid configuration line: 'sp.disabled_functions%s':"
174 " must take a function name.", 174 " must take a function name on line %zu.",
175 line); 175 line, sp_line_no);
176 return -1; 176 return -1;
177 } else if (!(df->allow ^ df->drop)) { 177 } else if (!(df->allow ^ df->drop)) {
178 sp_log_err("config", 178 sp_log_err("config",
179 "Invalid configuration line: 'sp.disabled_functions%s': The " 179 "Invalid configuration line: 'sp.disabled_functions%s': The "
180 "rule must either be a `drop` or and `allow` one.", 180 "rule must either be a `drop` or and `allow` one on line %zu.",
181 line); 181 line, sp_line_no);
182 return -1; 182 return -1;
183 } 183 }
184 184
@@ -245,7 +245,7 @@ int parse_upload_validation(char *line) {
245 } 245 }
246 246
247 if (!(enable ^ disable)) { 247 if (!(enable ^ disable)) {
248 sp_log_err("config", "A rule can't be enabled and disabled."); 248 sp_log_err("config", "A rule can't be enabled and disabled on line %zu.", sp_line_no);
249 return -1; 249 return -1;
250 } 250 }
251 SNUFFLEUPAGUS_G(config).config_upload_validation->enable = enable; 251 SNUFFLEUPAGUS_G(config).config_upload_validation->enable = enable;
@@ -253,14 +253,14 @@ int parse_upload_validation(char *line) {
253 char const *script = SNUFFLEUPAGUS_G(config).config_upload_validation->script; 253 char const *script = SNUFFLEUPAGUS_G(config).config_upload_validation->script;
254 254
255 if (!script) { 255 if (!script) {
256 sp_log_err("config", "The `script` directive is mandatory in %s", 256 sp_log_err("config", "The `script` directive is mandatory in '%s' on line %zu.",
257 line); 257 line, sp_line_no);
258 return -1; 258 return -1;
259 } else if (-1 == access(script, F_OK)) { 259 } else if (-1 == access(script, F_OK)) {
260 sp_log_err("config", "The `script` (%s) doesn't exist.", script); 260 sp_log_err("config", "The `script` (%s) doesn't exist on line %zu.", script, sp_line_no);
261 return -1; 261 return -1;
262 } else if (-1 == access(script, X_OK)) { 262 } else if (-1 == access(script, X_OK)) {
263 sp_log_err("config", "The `script` (%s) isn't executable.", script); 263 sp_log_err("config", "The `script` (%s) isn't executable on line %zu.", script, sp_line_no);
264 return -1; 264 return -1;
265 } 265 }
266 266