gnunet-svn
[Top][All Lists]
Advanced

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

[gnunet] branch master updated: config: resolve realpath of parent confi


From: gnunet
Subject: [gnunet] branch master updated: config: resolve realpath of parent config file, fix docs
Date: Mon, 26 Jul 2021 20:33:47 +0200

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

dold pushed a commit to branch master
in repository gnunet.

The following commit(s) were added to refs/heads/master by this push:
     new 28dfb1220 config: resolve realpath of parent config file, fix docs
28dfb1220 is described below

commit 28dfb1220bd257ba29fc2ae786c6952cc086c561
Author: Florian Dold <florian@dold.me>
AuthorDate: Mon Jul 26 20:30:28 2021 +0200

    config: resolve realpath of parent config file, fix docs
---
 src/include/gnunet_configuration_lib.h |  7 +++----
 src/util/configuration.c               | 32 +++++++++++++++++++-------------
 2 files changed, 22 insertions(+), 17 deletions(-)

diff --git a/src/include/gnunet_configuration_lib.h 
b/src/include/gnunet_configuration_lib.h
index 21a5ab810..68ed570a3 100644
--- a/src/include/gnunet_configuration_lib.h
+++ b/src/include/gnunet_configuration_lib.h
@@ -144,16 +144,15 @@ GNUNET_CONFIGURATION_serialize (const struct 
GNUNET_CONFIGURATION_Handle *cfg,
  * @param cfg configuration to update
  * @param mem the memory block of serialized configuration
  * @param size the size of the memory block
- * @param allow_inline set to the base directory if we recursively load 
configuration
- *          from inlined configurations; NULL if not and raise warnings
- *          when we come across them
+ * @param source_filename source filename, will be used
+ *        to resolve relative @INLINE@ statements
  * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
  */
 enum GNUNET_GenericReturnValue
 GNUNET_CONFIGURATION_deserialize (struct GNUNET_CONFIGURATION_Handle *cfg,
                                   const char *mem,
                                   size_t size,
-                                  const char *basedir);
+                                  const char *source_filename);
 
 
 /**
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
    * #GNUNET_SYSERR on error (i.e. last save failed)
    */
   enum GNUNET_GenericReturnValue dirty;
+
+  /**
+   * Name of the entry point configuration file.
+   */
+  char *main_filename;
 };
 
 
@@ -230,7 +235,7 @@ enum GNUNET_GenericReturnValue
 GNUNET_CONFIGURATION_deserialize (struct GNUNET_CONFIGURATION_Handle *cfg,
                                   const char *mem,
                                   size_t size,
-                                  const char *basedir)
+                                  const char *source_filename)
 {
   char *line;
   char *line_orig;
@@ -310,10 +315,11 @@ GNUNET_CONFIGURATION_deserialize (struct 
GNUNET_CONFIGURATION_Handle *cfg,
     {
       char *inline_path;
 
-      if (NULL == basedir)
+      if (NULL == source_filename)
       {
         LOG (GNUNET_ERROR_TYPE_DEBUG,
-             "Ignoring parsing @INLINE@ configurations, not allowed!\n");
+             "Refusing to parse @INLINE@ configurations, "
+             "not allowed without source filename!\n");
         ret = GNUNET_SYSERR;
         break;
       }
@@ -326,22 +332,26 @@ GNUNET_CONFIGURATION_deserialize (struct 
GNUNET_CONFIGURATION_Handle *cfg,
         /* We compute the canonical, absolute path first,
            so that relative imports resolve properly with symlinked
            config files.  */
-        char *basedir_realpath;
+        char *source_realpath;
+        char *endsep;
 
-        basedir_realpath = realpath (basedir,
-                                     NULL);
-        if (NULL == basedir_realpath)
+        source_realpath = realpath (source_filename,
+                                    NULL);
+        if (NULL == source_realpath)
         {
           /* Couldn't even resolve path of base dir. */
           GNUNET_break (0);
           ret = GNUNET_SYSERR;       /* failed to parse included config */
           break;
         }
+        endsep = strrchr (source_realpath, '/');
+        GNUNET_assert (NULL != endsep);
+        *endsep = '\0';
         GNUNET_asprintf (&inline_path,
                          "%s/%s",
-                         basedir_realpath,
+                         source_realpath,
                          value);
-        free (basedir_realpath);
+        free (source_realpath);
       }
       if (GNUNET_OK !=
           GNUNET_CONFIGURATION_parse (cfg,
@@ -415,7 +425,6 @@ GNUNET_CONFIGURATION_parse (struct 
GNUNET_CONFIGURATION_Handle *cfg,
   size_t fs;
   char *fn;
   char *mem;
-  char *endsep;
   int dirty;
   enum GNUNET_GenericReturnValue ret;
   ssize_t sret;
@@ -451,9 +460,6 @@ GNUNET_CONFIGURATION_parse (struct 
GNUNET_CONFIGURATION_Handle *cfg,
     return GNUNET_SYSERR;
   }
   LOG (GNUNET_ERROR_TYPE_DEBUG, "Deserializing contents of file `%s'\n", fn);
-  endsep = strrchr (fn, (int) '/');
-  if (NULL != endsep)
-    *endsep = '\0';
   ret = GNUNET_CONFIGURATION_deserialize (cfg,
                                           mem,
                                           fs,

-- 
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]