From 8233e282046e27de57de75f175e131a974087618 Mon Sep 17 00:00:00 2001 From: Alessio Vanni Date: Sat, 24 Apr 2021 17:29:42 +0200 Subject: Swap gnunet-config's default behaviour for the rewrite flag With the previous default, a configuration file could keep values different from the defaults even when the user did not explicitly edit that option, potentially leading to buggy behaviour. For example: GNUnet's version X+1 changes the default value for a certain option A, but anyone who has edited the configuration file with version X or earlier, would still have got the old default for A even when updating to version X+1. It was possible to write only the edited parts, but that required explicitly passing the `--rewrite' (or `-w') flag. The default behaviour has now been swapped so that the resulting file contains only differences, while a "frozen" configuration is generated with the `--rewrite' flag. Also, as it's a minor change: a function used internally by the logging component was using translated strings to check the requested log level. This behaviour is buggy as passing an untranslated string to e.g. `GNUNET_log_setup', while the current locale is different and a translation for that string exists, would generate a different log level than the one requested. --- src/util/common_logging.c | 16 ++++++++-------- src/util/gnunet-config.c | 11 ++++++----- 2 files changed, 14 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/util/common_logging.c b/src/util/common_logging.c index b30175543..48cc6fe3b 100644 --- a/src/util/common_logging.c +++ b/src/util/common_logging.c @@ -246,27 +246,27 @@ static int gnunet_force_log_present; /** * Convert a textual description of a loglevel - * to the respective GNUNET_GE_KIND. + * to the respective enumeration type. * * @param log loglevel to parse - * @return GNUNET_GE_INVALID if log does not parse + * @return GNUNET_ERROR_TYPE_INVALID if log does not parse */ static enum GNUNET_ErrorType get_type (const char *log) { if (NULL == log) return GNUNET_ERROR_TYPE_UNSPECIFIED; - if (0 == strcasecmp (log, _ ("DEBUG"))) + if (0 == strcasecmp (log, "DEBUG")) return GNUNET_ERROR_TYPE_DEBUG; - if (0 == strcasecmp (log, _ ("INFO"))) + if (0 == strcasecmp (log, "INFO")) return GNUNET_ERROR_TYPE_INFO; - if (0 == strcasecmp (log, _ ("MESSAGE"))) + if (0 == strcasecmp (log, "MESSAGE")) return GNUNET_ERROR_TYPE_MESSAGE; - if (0 == strcasecmp (log, _ ("WARNING"))) + if (0 == strcasecmp (log, "WARNING")) return GNUNET_ERROR_TYPE_WARNING; - if (0 == strcasecmp (log, _ ("ERROR"))) + if (0 == strcasecmp (log, "ERROR")) return GNUNET_ERROR_TYPE_ERROR; - if (0 == strcasecmp (log, _ ("NONE"))) + if (0 == strcasecmp (log, "NONE")) return GNUNET_ERROR_TYPE_NONE; return GNUNET_ERROR_TYPE_INVALID; } diff --git a/src/util/gnunet-config.c b/src/util/gnunet-config.c index 2b279dda2..4d050cdd3 100644 --- a/src/util/gnunet-config.c +++ b/src/util/gnunet-config.c @@ -65,10 +65,11 @@ static int list_sections; static int global_ret; /** - * Should we generate a configuration file that is clean and - * only contains the deltas to the defaults? + * Should the generated configuration file contain the whole configuration, or + * just the differences with the defaults? + * If set to a non-zero value, the full configuration will be written to file. */ -static int rewrite; +static int rewrite = 0; /** @@ -157,7 +158,7 @@ run (void *cls, GNUNET_free (name); return; } - if (rewrite) + if (!rewrite) { struct GNUNET_CONFIGURATION_Handle *def; @@ -315,7 +316,7 @@ main (int argc, char *const *argv) 'w', "rewrite", gettext_noop ( - "write configuration file that only contains delta to defaults"), + "write the full configuration file, including default values"), &rewrite), GNUNET_GETOPT_OPTION_END }; int ret; -- cgit v1.2.3