diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/util/configuration.c | 68 |
1 files changed, 35 insertions, 33 deletions
diff --git a/src/util/configuration.c b/src/util/configuration.c index d0090ae53..8ca3681af 100644 --- a/src/util/configuration.c +++ b/src/util/configuration.c | |||
@@ -308,45 +308,47 @@ GNUNET_CONFIGURATION_deserialize (struct GNUNET_CONFIGURATION_Handle *cfg, | |||
308 | "@INLINE@ ", | 308 | "@INLINE@ ", |
309 | strlen ("@INLINE@ "))) | 309 | strlen ("@INLINE@ "))) |
310 | { | 310 | { |
311 | /* @INLINE@ value */ | 311 | char *inline_path; |
312 | value = &line[strlen ("@INLINE@ ")]; | 312 | char *inline_realpath; |
313 | if (NULL != basedir) | 313 | |
314 | { | 314 | if (NULL == basedir) |
315 | if ('/' == *value) | ||
316 | { | ||
317 | if (GNUNET_OK != | ||
318 | GNUNET_CONFIGURATION_parse (cfg, | ||
319 | value)) | ||
320 | { | ||
321 | ret = GNUNET_SYSERR; /* failed to parse included config */ | ||
322 | break; | ||
323 | } | ||
324 | } | ||
325 | else | ||
326 | { | ||
327 | char *fn; | ||
328 | |||
329 | GNUNET_asprintf (&fn, "%s/%s", | ||
330 | basedir, | ||
331 | value); | ||
332 | if (GNUNET_OK != | ||
333 | GNUNET_CONFIGURATION_parse (cfg, | ||
334 | fn)) | ||
335 | { | ||
336 | GNUNET_free (fn); | ||
337 | ret = GNUNET_SYSERR; /* failed to parse included config */ | ||
338 | break; | ||
339 | } | ||
340 | GNUNET_free (fn); | ||
341 | } | ||
342 | } | ||
343 | else | ||
344 | { | 315 | { |
345 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 316 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
346 | "Ignoring parsing @INLINE@ configurations, not allowed!\n"); | 317 | "Ignoring parsing @INLINE@ configurations, not allowed!\n"); |
347 | ret = GNUNET_SYSERR; | 318 | ret = GNUNET_SYSERR; |
348 | break; | 319 | break; |
349 | } | 320 | } |
321 | /* FIXME: also trim space and end of line comment? */ | ||
322 | value = &line[strlen ("@INLINE@ ")]; | ||
323 | if ('/' == *value) | ||
324 | inline_path = GNUNET_strdup (value); | ||
325 | else | ||
326 | GNUNET_asprintf (&inline_path, | ||
327 | "%s/%s", | ||
328 | basedir, | ||
329 | value); | ||
330 | /* We compute the canonical, absolute path first, | ||
331 | so that relative imports resolve properly with symlinked | ||
332 | config files. */ | ||
333 | inline_realpath = realpath (inline_path, | ||
334 | NULL); | ||
335 | GNUNET_free (inline_path); | ||
336 | if (NULL == inline_realpath) | ||
337 | { | ||
338 | /* Couldn't even resolve path of included file. */ | ||
339 | GNUNET_break (0); | ||
340 | ret = GNUNET_SYSERR; /* failed to parse included config */ | ||
341 | break; | ||
342 | } | ||
343 | if (GNUNET_OK != | ||
344 | GNUNET_CONFIGURATION_parse (cfg, | ||
345 | inline_realpath)) | ||
346 | { | ||
347 | GNUNET_free (inline_realpath); | ||
348 | ret = GNUNET_SYSERR; /* failed to parse included config */ | ||
349 | break; | ||
350 | } | ||
351 | GNUNET_free (inline_realpath); | ||
350 | continue; | 352 | continue; |
351 | } | 353 | } |
352 | if (('[' == line[0]) && (']' == line[line_size - 1])) | 354 | if (('[' == line[0]) && (']' == line[line_size - 1])) |