diff options
author | Thomas Haller <thaller@redhat.com> | 2015-06-07 00:02:20 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2015-06-13 12:26:38 +0200 |
commit | fbf6d2e299766e0b6722746545eab364ca94c878 (patch) | |
tree | a581365e2768aa3d97eda1669122fcd53b17a903 | |
parent | 3927fd2a0c0f73ce9e1c08d6f4d2ea65c2ddd1bf (diff) | |
download | NetworkManager-fbf6d2e299766e0b6722746545eab364ca94c878.tar.gz |
config: fix setting default configuration for 'main.plugins'
'main.plugins' is the only configuration options for which we
have a default value and which we always want to set.
This property has a compile time default and can be set via command line,
fix the logic to set the value.
The proper way is:
- first set it (always) to the compile time default
- then read the configuration files, which potentially modify
the value.
- finally, if set via command line, overwrite it because
command line always wins.
Also comment-out the setting from our default file in
"contrib/fedora/rpm/NetworkManager.conf". We don't really need it to be
configured there, as we have a compile time default. Commenting it out
makes this clearer to the user.
Note that we cannot drop "10-ibft-plugin.conf" snippet from
NetworkManager package, because many users might have an old
"NetworkManager.conf" file with "plugin=ifcfg-rh".
-rw-r--r-- | contrib/fedora/rpm/NetworkManager.conf | 2 | ||||
-rw-r--r-- | src/nm-config.c | 22 |
2 files changed, 12 insertions, 12 deletions
diff --git a/contrib/fedora/rpm/NetworkManager.conf b/contrib/fedora/rpm/NetworkManager.conf index 9901b03935..0352aa1087 100644 --- a/contrib/fedora/rpm/NetworkManager.conf +++ b/contrib/fedora/rpm/NetworkManager.conf @@ -19,7 +19,7 @@ # the previous one. [main] -plugins=ifcfg-rh,ibft +#plugins=ifcfg-rh,ibft [logging] #level=DEBUG diff --git a/src/nm-config.c b/src/nm-config.c index 666fc246ef..473eabd95f 100644 --- a/src/nm-config.c +++ b/src/nm-config.c @@ -631,13 +631,13 @@ read_entire_config (const NMConfigCmdLineOptions *cli, char **out_config_description, GError **error) { - GKeyFile *keyfile = nm_config_create_keyfile (); + GKeyFile *keyfile; gs_unref_ptrarray GPtrArray *system_confs = NULL; gs_unref_ptrarray GPtrArray *confs = NULL; guint i; gs_free char *o_config_main_file = NULL; - char **plugins_tmp; GString *str; + char **plugins_default; g_return_val_if_fail (config_dir, NULL); g_return_val_if_fail (system_config_dir, NULL); @@ -645,6 +645,14 @@ read_entire_config (const NMConfigCmdLineOptions *cli, g_return_val_if_fail (out_config_description && !*out_config_description, NULL); g_return_val_if_fail (!error || !*error, FALSE); + /* create a default configuration file. */ + keyfile = nm_config_create_keyfile (); + + plugins_default = g_strsplit (CONFIG_PLUGINS_DEFAULT, ",", -1); + if (plugins_default && plugins_default[0]) + g_key_file_set_string_list (keyfile, "main", "plugins", (const char *const*) plugins_default, g_strv_length (plugins_default)); + g_strfreev (plugins_default); + system_confs = _get_config_dir_files (system_config_dir); confs = _get_config_dir_files (config_dir); @@ -682,18 +690,10 @@ read_entire_config (const NMConfigCmdLineOptions *cli, /* Merge settings from command line. They overwrite everything read from * config files. */ - if (cli && cli->plugins && cli->plugins[0]) + if (cli && cli->plugins) g_key_file_set_value (keyfile, "main", "plugins", cli->plugins); - plugins_tmp = g_key_file_get_string_list (keyfile, "main", "plugins", NULL, NULL); - if (!plugins_tmp) { - if (STRLEN (CONFIG_PLUGINS_DEFAULT) > 0) - g_key_file_set_value (keyfile, "main", "plugins", CONFIG_PLUGINS_DEFAULT); - } else - g_strfreev (plugins_tmp); - if (cli && cli->configure_and_quit) g_key_file_set_value (keyfile, "main", "configure-and-quit", "true"); - if (cli && cli->connectivity_uri && cli->connectivity_uri[0]) g_key_file_set_value (keyfile, "connectivity", "uri", cli->connectivity_uri); if (cli && cli->connectivity_interval >= 0) |