aboutsummaryrefslogtreecommitdiff
path: root/src/util/configuration.c
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2021-07-26 20:30:28 +0200
committerFlorian Dold <florian@dold.me>2021-07-26 20:30:28 +0200
commit28dfb1220bd257ba29fc2ae786c6952cc086c561 (patch)
treeff475f9f88fde4ebdcd7e57f3bdb694956aad621 /src/util/configuration.c
parent51e5fab47cb0e9c45600fca44eecd80f8087c8f8 (diff)
downloadgnunet-28dfb1220bd257ba29fc2ae786c6952cc086c561.tar.gz
gnunet-28dfb1220bd257ba29fc2ae786c6952cc086c561.zip
config: resolve realpath of parent config file, fix docs
Diffstat (limited to 'src/util/configuration.c')
-rw-r--r--src/util/configuration.c32
1 files changed, 19 insertions, 13 deletions
diff --git a/src/util/configuration.c b/src/util/configuration.c
index 506df5e1f..4a1af10d3 100644
--- a/src/util/configuration.c
+++ b/src/util/configuration.c
@@ -94,6 +94,11 @@ struct GNUNET_CONFIGURATION_Handle
94 * #GNUNET_SYSERR on error (i.e. last save failed) 94 * #GNUNET_SYSERR on error (i.e. last save failed)
95 */ 95 */
96 enum GNUNET_GenericReturnValue dirty; 96 enum GNUNET_GenericReturnValue dirty;
97
98 /**
99 * Name of the entry point configuration file.
100 */
101 char *main_filename;
97}; 102};
98 103
99 104
@@ -230,7 +235,7 @@ enum GNUNET_GenericReturnValue
230GNUNET_CONFIGURATION_deserialize (struct GNUNET_CONFIGURATION_Handle *cfg, 235GNUNET_CONFIGURATION_deserialize (struct GNUNET_CONFIGURATION_Handle *cfg,
231 const char *mem, 236 const char *mem,
232 size_t size, 237 size_t size,
233 const char *basedir) 238 const char *source_filename)
234{ 239{
235 char *line; 240 char *line;
236 char *line_orig; 241 char *line_orig;
@@ -310,10 +315,11 @@ GNUNET_CONFIGURATION_deserialize (struct GNUNET_CONFIGURATION_Handle *cfg,
310 { 315 {
311 char *inline_path; 316 char *inline_path;
312 317
313 if (NULL == basedir) 318 if (NULL == source_filename)
314 { 319 {
315 LOG (GNUNET_ERROR_TYPE_DEBUG, 320 LOG (GNUNET_ERROR_TYPE_DEBUG,
316 "Ignoring parsing @INLINE@ configurations, not allowed!\n"); 321 "Refusing to parse @INLINE@ configurations, "
322 "not allowed without source filename!\n");
317 ret = GNUNET_SYSERR; 323 ret = GNUNET_SYSERR;
318 break; 324 break;
319 } 325 }
@@ -326,22 +332,26 @@ GNUNET_CONFIGURATION_deserialize (struct GNUNET_CONFIGURATION_Handle *cfg,
326 /* We compute the canonical, absolute path first, 332 /* We compute the canonical, absolute path first,
327 so that relative imports resolve properly with symlinked 333 so that relative imports resolve properly with symlinked
328 config files. */ 334 config files. */
329 char *basedir_realpath; 335 char *source_realpath;
336 char *endsep;
330 337
331 basedir_realpath = realpath (basedir, 338 source_realpath = realpath (source_filename,
332 NULL); 339 NULL);
333 if (NULL == basedir_realpath) 340 if (NULL == source_realpath)
334 { 341 {
335 /* Couldn't even resolve path of base dir. */ 342 /* Couldn't even resolve path of base dir. */
336 GNUNET_break (0); 343 GNUNET_break (0);
337 ret = GNUNET_SYSERR; /* failed to parse included config */ 344 ret = GNUNET_SYSERR; /* failed to parse included config */
338 break; 345 break;
339 } 346 }
347 endsep = strrchr (source_realpath, '/');
348 GNUNET_assert (NULL != endsep);
349 *endsep = '\0';
340 GNUNET_asprintf (&inline_path, 350 GNUNET_asprintf (&inline_path,
341 "%s/%s", 351 "%s/%s",
342 basedir_realpath, 352 source_realpath,
343 value); 353 value);
344 free (basedir_realpath); 354 free (source_realpath);
345 } 355 }
346 if (GNUNET_OK != 356 if (GNUNET_OK !=
347 GNUNET_CONFIGURATION_parse (cfg, 357 GNUNET_CONFIGURATION_parse (cfg,
@@ -415,7 +425,6 @@ GNUNET_CONFIGURATION_parse (struct GNUNET_CONFIGURATION_Handle *cfg,
415 size_t fs; 425 size_t fs;
416 char *fn; 426 char *fn;
417 char *mem; 427 char *mem;
418 char *endsep;
419 int dirty; 428 int dirty;
420 enum GNUNET_GenericReturnValue ret; 429 enum GNUNET_GenericReturnValue ret;
421 ssize_t sret; 430 ssize_t sret;
@@ -451,9 +460,6 @@ GNUNET_CONFIGURATION_parse (struct GNUNET_CONFIGURATION_Handle *cfg,
451 return GNUNET_SYSERR; 460 return GNUNET_SYSERR;
452 } 461 }
453 LOG (GNUNET_ERROR_TYPE_DEBUG, "Deserializing contents of file `%s'\n", fn); 462 LOG (GNUNET_ERROR_TYPE_DEBUG, "Deserializing contents of file `%s'\n", fn);
454 endsep = strrchr (fn, (int) '/');
455 if (NULL != endsep)
456 *endsep = '\0';
457 ret = GNUNET_CONFIGURATION_deserialize (cfg, 463 ret = GNUNET_CONFIGURATION_deserialize (cfg,
458 mem, 464 mem,
459 fs, 465 fs,