diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2016-09-28 18:06:19 +0200 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2016-09-28 18:24:14 +0200 |
commit | 7c6b07376e6628fe63a0ad36c39b0916b83ac313 (patch) | |
tree | 542e06e4078381a19a22c73f998a530e987f44f2 | |
parent | eb598190a3c6b9f9aa8fa91c04b0a3b39fe8e48e (diff) | |
download | NetworkManager-bg/config-show-default.tar.gz |
config: add default values in the output of NM --print-configbg/config-show-default
There isn't an easy way to determine the effective value of some
configuration keys as their default value can be set at build
time. For such keys the user has to search in logs or look at the
manual page if available.
This adds the default values to the output of 'NetworkManager
--print-config':
[main]
# plugins=ifcfg-rh,ifupdown,ifnet,ibft
# auth-polkit=true
dns=dnsmasq
rc-manager=symlink
[logging]
# backend=journal
-rw-r--r-- | src/nm-config-data.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/nm-config-data.c b/src/nm-config-data.c index 23c4cecdc9..1900d2d938 100644 --- a/src/nm-config-data.c +++ b/src/nm-config-data.c @@ -526,6 +526,17 @@ _nm_config_data_log_sort (const char **pa, const char **pb, gpointer dummy) return 0; } +static struct { + char *group; + char *key; + char *default_value; +} default_values[] = { + { "main", "plugins", NM_CONFIG_PLUGINS_DEFAULT }, + { "main", "rc-manager", NM_CONFIG_DEFAULT_DNS_RC_MANAGER }, + { "main", "auth-polkit", NM_CONFIG_DEFAULT_AUTH_POLKIT }, + { "logging", "backend", NM_CONFIG_LOGGING_BACKEND_DEFAULT }, +}; + void nm_config_data_log (const NMConfigData *self, const char *prefix, @@ -535,7 +546,7 @@ nm_config_data_log (const NMConfigData *self, NMConfigDataPrivate *priv; gs_strfreev char **groups = NULL; gsize ngroups; - guint g, k; + guint g, k, i; FILE *stream = print_stream; g_return_if_fail (NM_IS_CONFIG_DATA (self)); @@ -582,6 +593,15 @@ nm_config_data_log (const NMConfigData *self, _LOG (stream, prefix, ""); _LOG (stream, prefix, "[%s]%s", group, is_atomic && !stream ? " # atomic section" : ""); + /* Print default values as comments */ + for (i = 0; i < G_N_ELEMENTS (default_values); i++) { + if ( nm_streq (default_values[i].group, group) + && !g_key_file_has_key (priv->keyfile, group, default_values[i].key, NULL)) { + _LOG (stream, prefix, "%s# %s=%s", key_prefix, default_values[i].key, + default_values[i].default_value); + } + } + keys = g_key_file_get_keys (priv->keyfile, group, NULL, NULL); for (k = 0; keys && keys[k]; k++) { const char *key = keys[k]; |