summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2021-08-29 23:35:56 +0200
committerChristian Grothoff <christian@grothoff.org>2021-08-29 23:36:02 +0200
commit34822f004386e6e727a8a8917f91bce367457b84 (patch)
tree1cb032352c67df6009bb716104b3ff1f8a0aba4b /src
parent63e3d9645a0f14bd280d939a0802f4b639d4aa93 (diff)
-do load default configuration even if 'gnunet.conf' does not exist
Diffstat (limited to 'src')
-rw-r--r--src/util/configuration.c7
-rw-r--r--src/util/program.c72
2 files changed, 38 insertions, 41 deletions
diff --git a/src/util/configuration.c b/src/util/configuration.c
index 62c06ae23..09a3a7d93 100644
--- a/src/util/configuration.c
+++ b/src/util/configuration.c
@@ -2363,13 +2363,6 @@ GNUNET_CONFIGURATION_default_filename (void)
GNUNET_free (cfg_fn);
GNUNET_asprintf (&cfg_fn,
- "/etc/%s",
- pd->config_file);
- if (GNUNET_OK == GNUNET_DISK_file_test_read (cfg_fn))
- return cfg_fn;
- GNUNET_free (cfg_fn);
-
- GNUNET_asprintf (&cfg_fn,
"/etc/%s/%s",
pd->project_dirname,
pd->config_file);
diff --git a/src/util/program.c b/src/util/program.c
index a79e07d19..b9da14572 100644
--- a/src/util/program.c
+++ b/src/util/program.c
@@ -244,12 +244,23 @@ GNUNET_PROGRAM_run2 (int argc,
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Loading configuration from entry point specified as option (%s)\n",
cc.cfgfile);
- if ((GNUNET_YES != GNUNET_DISK_file_test (cc.cfgfile)) ||
- (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (cfg, cc.cfgfile)))
+ if (GNUNET_YES !=
+ GNUNET_DISK_file_test (cc.cfgfile))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _ (
- "Unreadable or malformed configuration file `%s', exit ...\n"),
+ _ ("Unreadable configuration file `%s', exiting ...\n"),
+ cc.cfgfile);
+ ret = GNUNET_SYSERR;
+ GNUNET_free (allopts);
+ GNUNET_free (lpfx);
+ goto cleanup;
+ }
+ if (GNUNET_SYSERR ==
+ GNUNET_CONFIGURATION_load (cfg,
+ cc.cfgfile))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _ ("Malformed configuration file `%s', exiting ...\n"),
cc.cfgfile);
ret = GNUNET_SYSERR;
GNUNET_free (allopts);
@@ -259,38 +270,31 @@ GNUNET_PROGRAM_run2 (int argc,
}
else
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Loading configuration default entry point (%s)\n",
- cc.cfgfile);
- if ((NULL != cfg_fn) && (GNUNET_YES == GNUNET_DISK_file_test (cfg_fn)))
+ if ( (NULL != cfg_fn) &&
+ (GNUNET_YES !=
+ GNUNET_DISK_file_test (cfg_fn)) )
{
- if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (cfg, cfg_fn))
- {
- GNUNET_log (
- GNUNET_ERROR_TYPE_ERROR,
- _ (
- "Unreadable or malformed default configuration file `%s', exit ...\n"),
- cfg_fn);
- ret = GNUNET_SYSERR;
- GNUNET_free (allopts);
- GNUNET_free (lpfx);
- goto cleanup;
- }
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _ ("Unreadable configuration file `%s'. Exiting ...\n"),
+ cfg_fn);
+ ret = GNUNET_SYSERR;
+ GNUNET_free (allopts);
+ GNUNET_free (lpfx);
+ goto cleanup;
}
- else if (NULL != cfg_fn)
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Loading configuration from entry point `%s'\n",
+ cc.cfgfile);
+ if (GNUNET_SYSERR ==
+ GNUNET_CONFIGURATION_load (cfg,
+ cfg_fn))
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Loading configuration without entry point\n");
- GNUNET_free (cfg_fn);
- if (GNUNET_OK != GNUNET_CONFIGURATION_load (cfg, NULL))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _ ("Unreadable or malformed configuration, exit ...\n"));
- ret = GNUNET_SYSERR;
- GNUNET_free (allopts);
- GNUNET_free (lpfx);
- goto cleanup;
- }
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _ ("Malformed configuration. Exiting ...\n"));
+ ret = GNUNET_SYSERR;
+ GNUNET_free (allopts);
+ GNUNET_free (lpfx);
+ goto cleanup;
}
}
GNUNET_free (allopts);
@@ -346,7 +350,7 @@ GNUNET_PROGRAM_run2 (int argc,
cc.task (cc.task_cls, cc.args, cc.cfgfile, cc.cfg);
}
ret = GNUNET_OK;
- cleanup:
+cleanup:
GNUNET_CONFIGURATION_destroy (cfg);
GNUNET_free (cc.cfgfile);
GNUNET_free (cfg_fn);