summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2016-09-28 18:06:19 +0200
committerBeniamino Galvani <bgalvani@redhat.com>2016-09-28 22:13:50 +0200
commit8d757fee38e898a2e6ad95ae67dd7ab8e2f75162 (patch)
tree5ca54a3812a28649262ccc0c686efb105a6e2a57
parenteb598190a3c6b9f9aa8fa91c04b0a3b39fe8e48e (diff)
downloadNetworkManager-bg/config-show-default-bgo772144.tar.gz
config: add default values to 'NM --print-config' outputbg/config-show-default-bgo772144
There isn't an easy way to determine the effective value of some configuration options as their default value can be set at build time; the user has to search in logs or look at the manual page when available. This adds those default values that can be changed at build time to the output of 'NetworkManager --print-config': [main] # plugins=ifcfg-rh,ifupdown,ifnet,ibft # rc-manager=symlink # auth-polkit=true dns=dnsmasq ... [logging] # backend=journal ...
-rw-r--r--src/nm-config-data.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/nm-config-data.c b/src/nm-config-data.c
index 23c4cecdc9..482520c575 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 {
+ const char *group;
+ const char *key;
+ const char *value;
+} default_values[] = {
+ { NM_CONFIG_KEYFILE_GROUP_MAIN, "plugins", NM_CONFIG_PLUGINS_DEFAULT },
+ { NM_CONFIG_KEYFILE_GROUP_MAIN, "rc-manager", NM_CONFIG_DEFAULT_DNS_RC_MANAGER },
+ { NM_CONFIG_KEYFILE_GROUP_MAIN, "auth-polkit", NM_CONFIG_DEFAULT_AUTH_POLKIT },
+ { NM_CONFIG_KEYFILE_GROUP_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].value);
+ }
+ }
+
keys = g_key_file_get_keys (priv->keyfile, group, NULL, NULL);
for (k = 0; keys && keys[k]; k++) {
const char *key = keys[k];