diff options
author | Florian Dold <florian@dold.me> | 2021-07-26 19:59:29 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2021-07-26 19:59:29 +0200 |
commit | cda72d5c4cdde29baedb57ed07be7779b3cd46fc (patch) | |
tree | 01c2ee193b4d6814b9fffb764aa2778678768c93 /src | |
parent | 473939543aec1111b19150db572d887feb1f3d20 (diff) | |
download | gnunet-cda72d5c4cdde29baedb57ed07be7779b3cd46fc.tar.gz gnunet-cda72d5c4cdde29baedb57ed07be7779b3cd46fc.zip |
config: resolve realpath of base dir, not config
Diffstat (limited to 'src')
-rw-r--r-- | src/util/configuration.c | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/src/util/configuration.c b/src/util/configuration.c index 8ca3681af..fd1ab2ecb 100644 --- a/src/util/configuration.c +++ b/src/util/configuration.c | |||
@@ -309,7 +309,6 @@ GNUNET_CONFIGURATION_deserialize (struct GNUNET_CONFIGURATION_Handle *cfg, | |||
309 | strlen ("@INLINE@ "))) | 309 | strlen ("@INLINE@ "))) |
310 | { | 310 | { |
311 | char *inline_path; | 311 | char *inline_path; |
312 | char *inline_realpath; | ||
313 | 312 | ||
314 | if (NULL == basedir) | 313 | if (NULL == basedir) |
315 | { | 314 | { |
@@ -323,32 +322,35 @@ GNUNET_CONFIGURATION_deserialize (struct GNUNET_CONFIGURATION_Handle *cfg, | |||
323 | if ('/' == *value) | 322 | if ('/' == *value) |
324 | inline_path = GNUNET_strdup (value); | 323 | inline_path = GNUNET_strdup (value); |
325 | else | 324 | else |
325 | { | ||
326 | /* We compute the canonical, absolute path first, | ||
327 | so that relative imports resolve properly with symlinked | ||
328 | config files. */ | ||
329 | char *basedir_realpath; | ||
330 | |||
331 | basedir_realpath = realpath (basedir, | ||
332 | NULL); | ||
333 | if (NULL == basedir_realpath) | ||
334 | { | ||
335 | /* Couldn't even resolve path of base dir. */ | ||
336 | GNUNET_break (0); | ||
337 | ret = GNUNET_SYSERR; /* failed to parse included config */ | ||
338 | break; | ||
339 | } | ||
326 | GNUNET_asprintf (&inline_path, | 340 | GNUNET_asprintf (&inline_path, |
327 | "%s/%s", | 341 | "%s/%s", |
328 | basedir, | 342 | basedir_realpath, |
329 | value); | 343 | 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 | } | 344 | } |
343 | if (GNUNET_OK != | 345 | if (GNUNET_OK != |
344 | GNUNET_CONFIGURATION_parse (cfg, | 346 | GNUNET_CONFIGURATION_parse (cfg, |
345 | inline_realpath)) | 347 | inline_path)) |
346 | { | 348 | { |
347 | GNUNET_free (inline_realpath); | 349 | GNUNET_free (inline_path); |
348 | ret = GNUNET_SYSERR; /* failed to parse included config */ | 350 | ret = GNUNET_SYSERR; /* failed to parse included config */ |
349 | break; | 351 | break; |
350 | } | 352 | } |
351 | GNUNET_free (inline_realpath); | 353 | GNUNET_free (inline_path); |
352 | continue; | 354 | continue; |
353 | } | 355 | } |
354 | if (('[' == line[0]) && (']' == line[line_size - 1])) | 356 | if (('[' == line[0]) && (']' == line[line_size - 1])) |