aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorAlessio Vanni <vannilla@firemail.cc>2021-10-30 16:07:08 +0200
committerAlessio Vanni <vannilla@firemail.cc>2021-10-30 16:11:48 +0200
commit62bd4ad64ebf1567c05170353dd7c60813c4f284 (patch)
treea976a4dc2c35e2b5701e438a4846632bc136a6ad /src/util
parent6a642f8f6060018115be1bf66826fc1c4676a015 (diff)
downloadgnunet-62bd4ad64ebf1567c05170353dd7c60813c4f284.tar.gz
gnunet-62bd4ad64ebf1567c05170353dd7c60813c4f284.zip
-fix subtle bug in GNUNET_CONFIGURATION_default
Apparently this was there since the beginning and it wasn't caught earlier merely due to a coincidence. Basically, it was looking at the caller's values instead of GNUnet's and even when I used this function in personal projects, it just happened that I was calling this function before setting the new project data, so the two environments ended up being the same. It didn't cause any issues because it was still returning GNUnet's own configuration, meaning everything else worked as expected, but naturally if one were to move the call later on it would break. Also add a comment to answer the FIXME.
Diffstat (limited to 'src/util')
-rw-r--r--src/util/configuration.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/util/configuration.c b/src/util/configuration.c
index 09a3a7d93..d9d6721cc 100644
--- a/src/util/configuration.c
+++ b/src/util/configuration.c
@@ -2383,31 +2383,34 @@ GNUNET_CONFIGURATION_default (void)
2383 char *cfgname = NULL; 2383 char *cfgname = NULL;
2384 struct GNUNET_CONFIGURATION_Handle *cfg; 2384 struct GNUNET_CONFIGURATION_Handle *cfg;
2385 2385
2386 /* FIXME: Why are we doing this? Needs some commentary! */ 2386 /* Makes sure function implicitly looking at the installation directory (for
2387 example GNUNET_CONFIGURATION_load further down) use GNUnet's environment
2388 instead of the caller's. It's done at the start to make sure as many
2389 functions as possible are directed to the proper paths. */
2387 GNUNET_OS_init (dpd); 2390 GNUNET_OS_init (dpd);
2388 2391
2389 cfg = GNUNET_CONFIGURATION_create (); 2392 cfg = GNUNET_CONFIGURATION_create ();
2390 2393
2391 /* First, try user configuration. */ 2394 /* First, try user configuration. */
2392 if (NULL != xdg) 2395 if (NULL != xdg)
2393 GNUNET_asprintf (&cfgname, "%s/%s", xdg, pd->config_file); 2396 GNUNET_asprintf (&cfgname, "%s/%s", xdg, dpd->config_file);
2394 else 2397 else
2395 cfgname = GNUNET_strdup (pd->user_config_file); 2398 cfgname = GNUNET_strdup (dpd->user_config_file);
2396 2399
2397 /* If user config doesn't exist, try in 2400 /* If user config doesn't exist, try in
2398 /etc/<projdir>/<cfgfile> and /etc/<cfgfile> */ 2401 /etc/<projdir>/<cfgfile> and /etc/<cfgfile> */
2399 if (GNUNET_OK != GNUNET_DISK_file_test (cfgname)) 2402 if (GNUNET_OK != GNUNET_DISK_file_test (cfgname))
2400 { 2403 {
2401 GNUNET_free (cfgname); 2404 GNUNET_free (cfgname);
2402 GNUNET_asprintf (&cfgname, "/etc/%s", pd->config_file); 2405 GNUNET_asprintf (&cfgname, "/etc/%s", dpd->config_file);
2403 } 2406 }
2404 if (GNUNET_OK != GNUNET_DISK_file_test (cfgname)) 2407 if (GNUNET_OK != GNUNET_DISK_file_test (cfgname))
2405 { 2408 {
2406 GNUNET_free (cfgname); 2409 GNUNET_free (cfgname);
2407 GNUNET_asprintf (&cfgname, 2410 GNUNET_asprintf (&cfgname,
2408 "/etc/%s/%s", 2411 "/etc/%s/%s",
2409 pd->project_dirname, 2412 dpd->project_dirname,
2410 pd->config_file); 2413 dpd->config_file);
2411 } 2414 }
2412 if (GNUNET_OK != GNUNET_DISK_file_test (cfgname)) 2415 if (GNUNET_OK != GNUNET_DISK_file_test (cfgname))
2413 { 2416 {