diff options
author | Florian Dold <florian.dold@gmail.com> | 2016-02-28 20:40:00 +0000 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2016-02-28 20:40:00 +0000 |
commit | 862d43bb260b87ec5cd3072a8b486c90eaab3519 (patch) | |
tree | 3539f2064eb1a1b0c21e20097f6b3f1c69e8394b /src/util/configuration_loader.c | |
parent | 232cf1d42677f94f5d0df487490878bb7fc792c4 (diff) | |
download | gnunet-862d43bb260b87ec5cd3072a8b486c90eaab3519.tar.gz gnunet-862d43bb260b87ec5cd3072a8b486c90eaab3519.zip |
Add support for $GNUNET_BASE_CONFIG
The environment variable GNUNET_BASE_CONFIG allows
specifying the directory from which all base config
files will be loaded. This is useful when ARM is
to be used to supervise things otherwise unrelated to
GNUnet. Modifying GNUNET_PREFIX is not sufficient
for this use case, since e.g. libexec files need
to be under GNUNET_PREFIX, and GNUNET_BASE_CONFIG
provides a way to only modify the base config
directory independent of where GNUnet was installed.
Diffstat (limited to 'src/util/configuration_loader.c')
-rw-r--r-- | src/util/configuration_loader.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/src/util/configuration_loader.c b/src/util/configuration_loader.c index 37cf1a75d..2caad8c05 100644 --- a/src/util/configuration_loader.c +++ b/src/util/configuration_loader.c | |||
@@ -29,7 +29,7 @@ | |||
29 | 29 | ||
30 | #define LOG(kind,...) GNUNET_log_from (kind, "util", __VA_ARGS__) | 30 | #define LOG(kind,...) GNUNET_log_from (kind, "util", __VA_ARGS__) |
31 | 31 | ||
32 | #define LOG_STRERROR_FILE(kind,syscall,filename) GNUNET_log_from_strerror_file (kind, "util", syscall, filename) | 32 | |
33 | /** | 33 | /** |
34 | * Load configuration (starts with defaults, then loads | 34 | * Load configuration (starts with defaults, then loads |
35 | * system-specific configuration). | 35 | * system-specific configuration). |
@@ -43,14 +43,21 @@ GNUNET_CONFIGURATION_load (struct GNUNET_CONFIGURATION_Handle *cfg, | |||
43 | const char *filename) | 43 | const char *filename) |
44 | { | 44 | { |
45 | char *baseconfig; | 45 | char *baseconfig; |
46 | char *ipath; | ||
47 | 46 | ||
48 | ipath = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_DATADIR); | 47 | if (NULL != (baseconfig = getenv ("GNUNET_BASE_CONFIG"))) |
49 | if (NULL == ipath) | 48 | { |
50 | return GNUNET_SYSERR; | 49 | baseconfig = GNUNET_strdup (baseconfig); |
51 | baseconfig = NULL; | 50 | } |
52 | GNUNET_asprintf (&baseconfig, "%s%s", ipath, "config.d"); | 51 | else |
53 | GNUNET_free (ipath); | 52 | { |
53 | char *ipath; | ||
54 | |||
55 | ipath = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_DATADIR); | ||
56 | if (NULL == ipath) | ||
57 | return GNUNET_SYSERR; | ||
58 | GNUNET_asprintf (&baseconfig, "%s%s", ipath, "config.d"); | ||
59 | GNUNET_free (ipath); | ||
60 | } | ||
54 | 61 | ||
55 | if (GNUNET_SYSERR == | 62 | if (GNUNET_SYSERR == |
56 | GNUNET_CONFIGURATION_load_from (cfg, | 63 | GNUNET_CONFIGURATION_load_from (cfg, |