diff options
author | Alessio Vanni <vannilla@firemail.cc> | 2021-04-24 17:29:42 +0200 |
---|---|---|
committer | Alessio Vanni <vannilla@firemail.cc> | 2021-04-24 17:29:42 +0200 |
commit | 8233e282046e27de57de75f175e131a974087618 (patch) | |
tree | fba261f13d3a6225221a42082f561a3152969f82 | |
parent | 3cd24823660a0447e590ff352e9da7eb076b292b (diff) |
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.
-rw-r--r-- | contrib/packages/alpine/gnunet/gnunet-gns-proxy.initd | 3 | ||||
-rw-r--r-- | contrib/packages/alpine/gnunet/gnunet.xsession | 1 | ||||
-rw-r--r-- | debian/etc/X11/xinit/xinitrc.d/80-gnunet-user-services | 1 | ||||
-rw-r--r-- | debian/gnunet.postinst | 3 | ||||
-rw-r--r-- | doc/man/gnunet-config.1 | 6 | ||||
-rw-r--r-- | src/util/common_logging.c | 16 | ||||
-rw-r--r-- | src/util/gnunet-config.c | 11 |
7 files changed, 17 insertions, 24 deletions
diff --git a/contrib/packages/alpine/gnunet/gnunet-gns-proxy.initd b/contrib/packages/alpine/gnunet/gnunet-gns-proxy.initd index 3c5a22ee2..2a4dcc1c4 100644 --- a/contrib/packages/alpine/gnunet/gnunet-gns-proxy.initd +++ b/contrib/packages/alpine/gnunet/gnunet-gns-proxy.initd @@ -21,12 +21,10 @@ start() { # Customize gnunet.conf port=$((8000+$(id -u $user))) gnunet-config -c /home/$user/.config/gnunet.conf \ - --rewrite \ --section=gns-proxy \ --option=IMMEDIATE_START \ --value=YES gnunet-config -c /home/$user/.config/gnunet.conf \ - --rewrite \ --section=gns-proxy \ --option=OPTIONS \ --value="-p $port" @@ -79,7 +77,6 @@ stop() { # Disable gns-proxy in config gnunet-config -c /home/$user/.config/gnunet.conf \ - --rewrite \ --section=gns-proxy \ --option=IMMEDIATE_START \ --value=NO diff --git a/contrib/packages/alpine/gnunet/gnunet.xsession b/contrib/packages/alpine/gnunet/gnunet.xsession index 944d47a27..dead5c783 100644 --- a/contrib/packages/alpine/gnunet/gnunet.xsession +++ b/contrib/packages/alpine/gnunet/gnunet.xsession @@ -10,7 +10,6 @@ if [ "$gnunet_proxy" ]; then port=$((8000+$(id -u $user))) gnunet-config -c /home/$user/.config/gnunet.conf \ - --rewrite \ --section=gns-proxy \ --option=OPTIONS \ --value="-p $port" diff --git a/debian/etc/X11/xinit/xinitrc.d/80-gnunet-user-services b/debian/etc/X11/xinit/xinitrc.d/80-gnunet-user-services index aff1dd78c..d780b0e8e 100644 --- a/debian/etc/X11/xinit/xinitrc.d/80-gnunet-user-services +++ b/debian/etc/X11/xinit/xinitrc.d/80-gnunet-user-services @@ -9,7 +9,6 @@ if [ "$gnunet_proxy" ]; then port=$((8000+$(id -u "$user"))) gnunet-config -c "$HOME/.config/gnunet.conf" \ - --rewrite \ --section=gns-proxy \ --option=OPTIONS \ --value="-p $port" diff --git a/debian/gnunet.postinst b/debian/gnunet.postinst index 07e5202e8..b6317f5be 100644 --- a/debian/gnunet.postinst +++ b/debian/gnunet.postinst @@ -149,12 +149,10 @@ EOF fi port=$((8000+$(id -u "${users[$i]}"))) gnunet-config -c "${homedirs[$i]}/.config/gnunet.conf" \ - --rewrite \ --section=gns-proxy \ --option=IMMEDIATE_START \ --value=YES gnunet-config -c "${homedirs[$i]}/.config/gnunet.conf" \ - --rewrite \ --section=gns-proxy \ --option=OPTIONS \ --value="-p $port" @@ -180,7 +178,6 @@ if [ "$gnunet_proxy" ]; then port=$((8000+$(id -u $user))) gnunet-config -c $HOME/.config/gnunet.conf \ - --rewrite \ --section=gns-proxy \ --option=OPTIONS \ --value="-p $port" diff --git a/doc/man/gnunet-config.1 b/doc/man/gnunet-config.1 index f6166cbca..89bc3d14b 100644 --- a/doc/man/gnunet-config.1 +++ b/doc/man/gnunet-config.1 @@ -39,7 +39,7 @@ .Op Fl s Ar SECTION | Fl -section= Ns Ar SECTION .Op Fl V Ar VALUE | Fl -value Ar VALUE .Op Fl v | -version -.Op Fl W | -rewrite +.Op Fl w | -rewrite .Sh DESCRIPTION .Nm can be used to read or modify GNUnet configuration files. @@ -69,8 +69,8 @@ Configuration value to store in the given section under the given option. Must only be given together with -s and -o options. .It Fl v | -version Print GNUnet version number. -.It Fl W | -rewrite -Consider differences to defaults only. +.It Fl w | -rewrite +Write to file the full configuration, including default values, instead of just the differences. .El .Sh SEE ALSO The full documentation for gnunet is maintained as a Texinfo manual. 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; |