fix configuration parsing issue with inlines from configuration not in cwd
authorChristian Grothoff <christian@grothoff.org>
Sun, 25 Jun 2017 17:36:44 +0000 (19:36 +0200)
committerChristian Grothoff <christian@grothoff.org>
Sun, 25 Jun 2017 17:36:44 +0000 (19:36 +0200)
src/datacache/datacache.c
src/include/gnunet_configuration_lib.h
src/nat-auto/gnunet-service-nat-auto.c
src/nat-auto/nat_auto_api.c
src/set/gnunet-service-set_union.c
src/testbed/gnunet-helper-testbed.c
src/testbed/testbed_api.c
src/testbed/testbed_api_hosts.c
src/util/configuration.c

index a1869a8bd4bc851ca20fc1e8c8fb9fd2afbe6b15..92cc40b53632ecf3a8e0c34d6f53dd551eebc69e 100644 (file)
@@ -185,9 +185,9 @@ GNUNET_DATACACHE_create (const struct GNUNET_CONFIGURATION_Handle *cfg,
     }
     if (NULL == ret->filter)
     {
-       ret->filter = GNUNET_CONTAINER_bloomfilter_init (NULL,
-                                                         bf_size,
-                                                         5); /* approx. 3% false positives at max use */
+      ret->filter = GNUNET_CONTAINER_bloomfilter_init (NULL,
+                                                      bf_size,
+                                                      5); /* approx. 3% false positives at max use */
     }
   }
   ret->stats = GNUNET_STATISTICS_create ("datacache", cfg);
index c1537e4f8a68ad1cc0b68911821a431224f167a3..8a874da139a901a6e2f16a07156aead330104bca 100644 (file)
@@ -132,8 +132,8 @@ 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 #GNUNET_YES if we recursively load configuration
- *          from inlined configurations; #GNUNET_NO if not and raise warnings
+ * @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
  * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
  */
@@ -141,7 +141,7 @@ int
 GNUNET_CONFIGURATION_deserialize (struct GNUNET_CONFIGURATION_Handle *cfg,
                                  const char *mem,
                                  size_t size,
-                                 int allow_inline);
+                                 const char *basedir);
 
 
 /**
index ae570c351a4df6b18c46333948e4aa531e0cbb6c..5f10dad940d583284e3f211e6130fa73ae18d3e6 100644 (file)
@@ -310,7 +310,7 @@ handle_autoconfig_request (void *cls,
       GNUNET_CONFIGURATION_deserialize (ac->c,
                                        (const char *) &message[1],
                                        left,
-                                       GNUNET_NO))
+                                       NULL))
   {
     GNUNET_break (0);
     GNUNET_SERVICE_client_drop (ch->client);
index 8a7eaf2640035bad34463b1d56a039ebf6205b93..43a5212c88b8888e70ad264c29fbff1a3330b0c8 100644 (file)
@@ -155,7 +155,7 @@ handle_auto_result (void *cls,
       GNUNET_CONFIGURATION_deserialize (cfg,
                                        (const char *) &res[1],
                                        left,
-                                       GNUNET_NO))
+                                       NULL))
   {
     GNUNET_break (0);
     ah->arc (ah->arc_cls,
index 4ca10f0b463791b14b57667c4a56b94c0203a05a..b2983545f90149d03c74970661e8d574489305eb 100644 (file)
@@ -1467,8 +1467,6 @@ maybe_finish (struct Operation *op)
          num_demanded);
     if (0 == num_demanded)
     {
-      struct GNUNET_MQ_Envelope *ev;
-
       op->state->phase = PHASE_DONE;
       send_client_done (op);
       destroy_channel (op);
@@ -1894,8 +1892,6 @@ handle_union_p2p_full_done (void *cls,
     break;
   case PHASE_FULL_SENDING:
     {
-      struct GNUNET_MQ_Envelope *ev;
-
       LOG (GNUNET_ERROR_TYPE_DEBUG,
            "got FULL DONE, finishing\n");
       /* We sent the full set, and got the response for that.  We're done. */
index d2a3a98b7a1f5ca39780c8baabe2c3b16457184b..392f257dd9b263fafceb4cba013a7435ebba86f7 100644 (file)
@@ -358,7 +358,10 @@ tokenizer_cb (void *cls,
   }
   cfg = GNUNET_CONFIGURATION_create ();
   if (GNUNET_OK !=
-      GNUNET_CONFIGURATION_deserialize (cfg, config, ul_config_size, GNUNET_NO))
+      GNUNET_CONFIGURATION_deserialize (cfg,
+                                       config, 
+                                       ul_config_size,
+                                       NULL))
   {
     LOG (GNUNET_ERROR_TYPE_WARNING,
          "Unable to deserialize config -- exiting\n");
index 0e0a5da9c9d4881ae3933f1e2daddfc9e2ed0fde..1acd0e47c94e23835d502b94f2354174b8b1040f 100644 (file)
@@ -2158,9 +2158,10 @@ GNUNET_TESTBED_extract_config_ (const struct GNUNET_MessageHeader *msg)
   }
   cfg = GNUNET_CONFIGURATION_create ();
   if (GNUNET_OK !=
-      GNUNET_CONFIGURATION_deserialize (cfg, (const char *) data,
+      GNUNET_CONFIGURATION_deserialize (cfg,
+                                       (const char *) data,
                                         (size_t) data_len,
-                                        GNUNET_NO))
+                                        NULL))
   {
     GNUNET_free (data);
     GNUNET_break_op (0);        /* De-serialization failure */
index 5d2c1cc3773c3ef80daeed2bda7e049791a2c81d..8efcab64983b5792304b6db2e282e54ca935f4fe 100644 (file)
@@ -983,7 +983,10 @@ helper_mst (void *cls,
   GNUNET_CONFIGURATION_destroy (cp->host->cfg);
   cp->host->cfg = GNUNET_CONFIGURATION_create ();
   GNUNET_assert (GNUNET_CONFIGURATION_deserialize
-                 (cp->host->cfg, config, config_size, GNUNET_NO));
+                 (cp->host->cfg,
+                 config,
+                 config_size,
+                 NULL));
   GNUNET_free (config);
   if (NULL == (hostname = GNUNET_TESTBED_host_get_hostname (cp->host)))
     hostname = "localhost";
index 639bd55a2b4329d83c311ac39e0a1dceba98f135..f63903b4e9fb668d8b900746c43713a69abb5561 100644 (file)
@@ -145,8 +145,8 @@ GNUNET_CONFIGURATION_destroy (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 #GNUNET_YES if we recursively load configuration
- *          from inlined configurations; #GNUNET_NO if not and raise warnings
+ * @param basedir set to path from which we recursively load configuration
+ *          from inlined configurations; NULL if not and raise warnings
  *          when we come across them
  * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
  */
@@ -154,7 +154,7 @@ int
 GNUNET_CONFIGURATION_deserialize (struct GNUNET_CONFIGURATION_Handle *cfg,
                                  const char *mem,
                                  size_t size,
-                                 int allow_inline)
+                                 const char *basedir)
 {
   char *line;
   char *line_orig;
@@ -228,13 +228,23 @@ GNUNET_CONFIGURATION_deserialize (struct GNUNET_CONFIGURATION_Handle *cfg,
     {
       /* @INLINE@ value */
       value = &line[strlen ("@INLINE@ ")];
-      if (GNUNET_YES == allow_inline)
+      if (NULL != basedir)
       {
-       if (GNUNET_OK != GNUNET_CONFIGURATION_parse (cfg, value))
+       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
       {
@@ -311,6 +321,7 @@ GNUNET_CONFIGURATION_parse (struct GNUNET_CONFIGURATION_Handle *cfg,
   size_t fs;
   char *fn;
   char *mem;
+  char *endsep;
   int dirty;
   int ret;
 
@@ -350,8 +361,14 @@ GNUNET_CONFIGURATION_parse (struct GNUNET_CONFIGURATION_Handle *cfg,
   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,
+                                         fn);
   GNUNET_free (fn);
-  ret = GNUNET_CONFIGURATION_deserialize (cfg, mem, fs, GNUNET_YES);
   GNUNET_free (mem);
   /* restore dirty flag - anything we set in the meantime
    * came from disk */