[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet] branch master updated: fall back to /etc if user config can't b
From: |
gnunet |
Subject: |
[gnunet] branch master updated: fall back to /etc if user config can't be found |
Date: |
Wed, 28 Jul 2021 15:51:02 +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 2cdd91d55 fall back to /etc if user config can't be found
2cdd91d55 is described below
commit 2cdd91d55b1ac965d4f4075cf3c094ee5ac53818
Author: Florian Dold <florian@dold.me>
AuthorDate: Wed Jul 28 15:47:39 2021 +0200
fall back to /etc if user config can't be found
---
src/util/configuration.c | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/src/util/configuration.c b/src/util/configuration.c
index 3bb08e6c0..f091c4674 100644
--- a/src/util/configuration.c
+++ b/src/util/configuration.c
@@ -1918,12 +1918,45 @@ GNUNET_CONFIGURATION_default (void)
char *cfgname = NULL;
struct GNUNET_CONFIGURATION_Handle *cfg;
+ /* FIXME: Why are we doing this? Needs some commentary! */
GNUNET_OS_init (dpd);
+
cfg = GNUNET_CONFIGURATION_create ();
+
+ /* First, try user configuration. */
if (NULL != xdg)
GNUNET_asprintf (&cfgname, "%s/%s", xdg, pd->config_file);
else
cfgname = GNUNET_strdup (pd->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);
+ }
+ if (GNUNET_OK != GNUNET_DISK_file_test (cfgname))
+ {
+ GNUNET_free (cfgname);
+ GNUNET_asprintf (&cfgname, "/etc/%s/%s", pd->project_dirname,
+ pd->config_file);
+ }
+ if (GNUNET_OK != GNUNET_DISK_file_test (cfgname))
+ {
+ LOG (GNUNET_ERROR_TYPE_ERROR,
+ "Unable to top-level configuration file.\n");
+ GNUNET_OS_init (pd);
+ GNUNET_CONFIGURATION_destroy (cfg);
+ GNUNET_free (cfgname);
+ return NULL;
+ }
+
+ /* We found a configuration file that looks good, try to load it. */
+
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Loading top-level configuration from '%s'\n",
+ cfgname);
if (GNUNET_OK !=
GNUNET_CONFIGURATION_load (cfg, cfgname))
{
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnunet] branch master updated: fall back to /etc if user config can't be found,
gnunet <=