aboutsummaryrefslogtreecommitdiff
path: root/src/util/configuration.c
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2021-07-26 19:33:38 +0200
committerFlorian Dold <florian@dold.me>2021-07-26 19:33:48 +0200
commit16fe9a808202ba33e944a2ca6bdef0f4e4f3aeb7 (patch)
treea9bfc04cc7d6a25816a26fbeaa6dc1d490a4d371 /src/util/configuration.c
parent302e97b0180fa4703fc144467cfa78e59e3dd9e0 (diff)
downloadgnunet-16fe9a808202ba33e944a2ca6bdef0f4e4f3aeb7.tar.gz
gnunet-16fe9a808202ba33e944a2ca6bdef0f4e4f3aeb7.zip
config: resolve symlinks for @INLINE@-ed files
Otherwise, relative includes won't work properly.
Diffstat (limited to 'src/util/configuration.c')
-rw-r--r--src/util/configuration.c68
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]))