gnunet-svn
[Top][All Lists]
Advanced

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

[gnunet] branch master updated: config: resolve symlinks for @INLINE@-ed


From: gnunet
Subject: [gnunet] branch master updated: config: resolve symlinks for @INLINE@-ed files
Date: Mon, 26 Jul 2021 19:37:37 +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 16fe9a808 config: resolve symlinks for @INLINE@-ed files
16fe9a808 is described below

commit 16fe9a808202ba33e944a2ca6bdef0f4e4f3aeb7
Author: Florian Dold <florian@dold.me>
AuthorDate: Mon Jul 26 19:33:38 2021 +0200

    config: resolve symlinks for @INLINE@-ed files
    
    Otherwise, relative includes won't work properly.
---
 src/util/configuration.c | 68 +++++++++++++++++++++++++-----------------------
 1 file changed, 35 insertions(+), 33 deletions(-)

diff --git a/src/util/configuration.c b/src/util/configuration.c
index d0090ae53..8ca3681af 100644
--- a/src/util/configuration.c
+++ b/src/util/configuration.c
@@ -308,45 +308,47 @@ GNUNET_CONFIGURATION_deserialize (struct 
GNUNET_CONFIGURATION_Handle *cfg,
                           "@INLINE@ ",
                           strlen ("@INLINE@ ")))
     {
-      /* @INLINE@ value */
-      value = &line[strlen ("@INLINE@ ")];
-      if (NULL != basedir)
-      {
-        if ('/' == *value)
-        {
-          if (GNUNET_OK !=
-              GNUNET_CONFIGURATION_parse (cfg,
-                                          value))
-          {
-            ret = GNUNET_SYSERR;       /* failed to parse included config */
-            break;
-          }
-        }
-        else
-        {
-          char *fn;
-
-          GNUNET_asprintf (&fn, "%s/%s",
-                           basedir,
-                           value);
-          if (GNUNET_OK !=
-              GNUNET_CONFIGURATION_parse (cfg,
-                                          fn))
-          {
-            GNUNET_free (fn);
-            ret = GNUNET_SYSERR;       /* failed to parse included config */
-            break;
-          }
-          GNUNET_free (fn);
-        }
-      }
-      else
+      char *inline_path;
+      char *inline_realpath;
+
+      if (NULL == basedir)
       {
         LOG (GNUNET_ERROR_TYPE_DEBUG,
              "Ignoring parsing @INLINE@ configurations, not allowed!\n");
         ret = GNUNET_SYSERR;
         break;
       }
+      /* FIXME: also trim space and end of line comment? */
+      value = &line[strlen ("@INLINE@ ")];
+      if ('/' == *value)
+        inline_path = GNUNET_strdup (value);
+      else
+        GNUNET_asprintf (&inline_path,
+                         "%s/%s",
+                         basedir,
+                         value);
+      /* We compute the canonical, absolute path first,
+         so that relative imports resolve properly with symlinked
+         config files.  */
+      inline_realpath = realpath (inline_path,
+                                  NULL);
+      GNUNET_free (inline_path);
+      if (NULL == inline_realpath)
+      {
+        /* Couldn't even resolve path of included file. */
+        GNUNET_break (0);
+        ret = GNUNET_SYSERR;       /* failed to parse included config */
+        break;
+      }
+      if (GNUNET_OK !=
+          GNUNET_CONFIGURATION_parse (cfg,
+                                      inline_realpath))
+      {
+        GNUNET_free (inline_realpath);
+        ret = GNUNET_SYSERR;       /* failed to parse included config */
+        break;
+      }
+      GNUNET_free (inline_realpath);
       continue;
     }
     if (('[' == line[0]) && (']' == line[line_size - 1]))

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