aboutsummaryrefslogtreecommitdiff
path: root/src/util/configuration.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-06-25 19:36:44 +0200
committerChristian Grothoff <christian@grothoff.org>2017-06-25 19:36:44 +0200
commit981cc68a63c71ba11aaca84f559f3cf86a29c0ec (patch)
tree5196b264c461b609a128188e78a42b9972c845c3 /src/util/configuration.c
parent169f1c8c1db0a6d8cebf308ced1de064eadcdc4d (diff)
downloadgnunet-981cc68a63c71ba11aaca84f559f3cf86a29c0ec.tar.gz
gnunet-981cc68a63c71ba11aaca84f559f3cf86a29c0ec.zip
fix configuration parsing issue with inlines from configuration not in cwd
Diffstat (limited to 'src/util/configuration.c')
-rw-r--r--src/util/configuration.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/src/util/configuration.c b/src/util/configuration.c
index 639bd55a2..f63903b4e 100644
--- a/src/util/configuration.c
+++ b/src/util/configuration.c
@@ -145,8 +145,8 @@ GNUNET_CONFIGURATION_destroy (struct GNUNET_CONFIGURATION_Handle *cfg)
145 * @param cfg configuration to update 145 * @param cfg configuration to update
146 * @param mem the memory block of serialized configuration 146 * @param mem the memory block of serialized configuration
147 * @param size the size of the memory block 147 * @param size the size of the memory block
148 * @param allow_inline set to #GNUNET_YES if we recursively load configuration 148 * @param basedir set to path from which we recursively load configuration
149 * from inlined configurations; #GNUNET_NO if not and raise warnings 149 * from inlined configurations; NULL if not and raise warnings
150 * when we come across them 150 * when we come across them
151 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error 151 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
152 */ 152 */
@@ -154,7 +154,7 @@ int
154GNUNET_CONFIGURATION_deserialize (struct GNUNET_CONFIGURATION_Handle *cfg, 154GNUNET_CONFIGURATION_deserialize (struct GNUNET_CONFIGURATION_Handle *cfg,
155 const char *mem, 155 const char *mem,
156 size_t size, 156 size_t size,
157 int allow_inline) 157 const char *basedir)
158{ 158{
159 char *line; 159 char *line;
160 char *line_orig; 160 char *line_orig;
@@ -228,13 +228,23 @@ GNUNET_CONFIGURATION_deserialize (struct GNUNET_CONFIGURATION_Handle *cfg,
228 { 228 {
229 /* @INLINE@ value */ 229 /* @INLINE@ value */
230 value = &line[strlen ("@INLINE@ ")]; 230 value = &line[strlen ("@INLINE@ ")];
231 if (GNUNET_YES == allow_inline) 231 if (NULL != basedir)
232 { 232 {
233 if (GNUNET_OK != GNUNET_CONFIGURATION_parse (cfg, value)) 233 char *fn;
234
235 GNUNET_asprintf (&fn,
236 "%s/%s",
237 basedir,
238 value);
239 if (GNUNET_OK !=
240 GNUNET_CONFIGURATION_parse (cfg,
241 fn))
234 { 242 {
243 GNUNET_free (fn);
235 ret = GNUNET_SYSERR; /* failed to parse included config */ 244 ret = GNUNET_SYSERR; /* failed to parse included config */
236 break; 245 break;
237 } 246 }
247 GNUNET_free (fn);
238 } 248 }
239 else 249 else
240 { 250 {
@@ -311,6 +321,7 @@ GNUNET_CONFIGURATION_parse (struct GNUNET_CONFIGURATION_Handle *cfg,
311 size_t fs; 321 size_t fs;
312 char *fn; 322 char *fn;
313 char *mem; 323 char *mem;
324 char *endsep;
314 int dirty; 325 int dirty;
315 int ret; 326 int ret;
316 327
@@ -350,8 +361,14 @@ GNUNET_CONFIGURATION_parse (struct GNUNET_CONFIGURATION_Handle *cfg,
350 LOG (GNUNET_ERROR_TYPE_DEBUG, 361 LOG (GNUNET_ERROR_TYPE_DEBUG,
351 "Deserializing contents of file `%s'\n", 362 "Deserializing contents of file `%s'\n",
352 fn); 363 fn);
364 endsep = strrchr (fn, (int) '/');
365 if (NULL != endsep)
366 *endsep = '\0';
367 ret = GNUNET_CONFIGURATION_deserialize (cfg,
368 mem,
369 fs,
370 fn);
353 GNUNET_free (fn); 371 GNUNET_free (fn);
354 ret = GNUNET_CONFIGURATION_deserialize (cfg, mem, fs, GNUNET_YES);
355 GNUNET_free (mem); 372 GNUNET_free (mem);
356 /* restore dirty flag - anything we set in the meantime 373 /* restore dirty flag - anything we set in the meantime
357 * came from disk */ 374 * came from disk */