gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnunet] branch master updated: -fix subtle bug in GNUNET_CONFIGURATION_


From: gnunet
Subject: [gnunet] branch master updated: -fix subtle bug in GNUNET_CONFIGURATION_default
Date: Sat, 30 Oct 2021 16:13:20 +0200

This is an automated email from the git hooks/post-receive script.

alessio-vanni pushed a commit to branch master
in repository gnunet.

The following commit(s) were added to refs/heads/master by this push:
     new 62bd4ad64 -fix subtle bug in GNUNET_CONFIGURATION_default
62bd4ad64 is described below

commit 62bd4ad64ebf1567c05170353dd7c60813c4f284
Author: Alessio Vanni <vannilla@firemail.cc>
AuthorDate: Sat Oct 30 16:07:08 2021 +0200

    -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.
---
 src/util/configuration.c | 15 +++++++++------
 1 file 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)
   char *cfgname = NULL;
   struct GNUNET_CONFIGURATION_Handle *cfg;
 
-  /* FIXME:  Why are we doing this?  Needs some commentary! */
+  /* Makes sure function implicitly looking at the installation directory (for
+     example GNUNET_CONFIGURATION_load further down) use GNUnet's environment
+     instead of the caller's.  It's done at the start to make sure as many
+     functions as possible are directed to the proper paths. */
   GNUNET_OS_init (dpd);
 
   cfg = GNUNET_CONFIGURATION_create ();
 
   /* First, try user configuration. */
   if (NULL != xdg)
-    GNUNET_asprintf (&cfgname, "%s/%s", xdg, pd->config_file);
+    GNUNET_asprintf (&cfgname, "%s/%s", xdg, dpd->config_file);
   else
-    cfgname = GNUNET_strdup (pd->user_config_file);
+    cfgname = GNUNET_strdup (dpd->user_config_file);
 
   /* If user config doesn't exist, try in
      /etc/<projdir>/<cfgfile> and /etc/<cfgfile> */
   if (GNUNET_OK != GNUNET_DISK_file_test (cfgname))
   {
     GNUNET_free (cfgname);
-    GNUNET_asprintf (&cfgname, "/etc/%s", pd->config_file);
+    GNUNET_asprintf (&cfgname, "/etc/%s", dpd->config_file);
   }
   if (GNUNET_OK != GNUNET_DISK_file_test (cfgname))
   {
     GNUNET_free (cfgname);
     GNUNET_asprintf (&cfgname,
                      "/etc/%s/%s",
-                     pd->project_dirname,
-                     pd->config_file);
+                     dpd->project_dirname,
+                     dpd->config_file);
   }
   if (GNUNET_OK != GNUNET_DISK_file_test (cfgname))
   {

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]