diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2016-09-28 17:31:34 +0200 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2016-10-04 14:50:01 +0200 |
commit | fb2ca0ce3dadae8154d2ad8b611538323be137ac (patch) | |
tree | 734dee4ce8d77b176bd70e9d7be783b5b36a63f7 | |
parent | 984d4f068456390352ab16416a55e835027ba66e (diff) | |
download | NetworkManager-fb2ca0ce3dadae8154d2ad8b611538323be137ac.tar.gz |
config: don't set default plugins in nm-config keyfile
Like all other keys that can have a default value, substitute the
default only when needed. In this way, we can tell later if the
value comes from configuration file or if it's the default value.
Also, rename CONFIG_PLUGINS_DEFAULT to NM_CONFIG_PLUGINS_DEFAULT.
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | src/nm-config.c | 10 | ||||
-rw-r--r-- | src/settings/nm-settings.c | 10 |
3 files changed, 11 insertions, 11 deletions
diff --git a/configure.ac b/configure.ac index 570aae3984..79b9a10753 100644 --- a/configure.ac +++ b/configure.ac @@ -134,7 +134,7 @@ test "$enable_ifupdown" = "yes" && distro_plugins="$distro_plugins,ifu test "$enable_ifnet" = "yes" && distro_plugins="$distro_plugins,ifnet" distro_plugins="${distro_plugins#,}" -AC_DEFINE_UNQUOTED(CONFIG_PLUGINS_DEFAULT, "$config_plugins_default", [Default configuration option for main.plugins setting]) +AC_DEFINE_UNQUOTED(NM_CONFIG_PLUGINS_DEFAULT, "$config_plugins_default", [Default configuration option for main.plugins setting]) if test "${enable_config_plugin_ibft}" = yes; then AC_DEFINE(WITH_SETTINGS_PLUGIN_IBFT, 1, [Whether compilation of ibft setting plugin is enabled]) else diff --git a/src/nm-config.c b/src/nm-config.c index 0ef7fc2090..9615353bd9 100644 --- a/src/nm-config.c +++ b/src/nm-config.c @@ -512,7 +512,7 @@ nm_config_cmd_line_options_add_to_entries (NMConfigCmdLineOptions *cli, { "intern-config", 0, 0, G_OPTION_ARG_FILENAME, &cli->intern_config_file, N_("Internal config file location"), N_(DEFAULT_INTERN_CONFIG_FILE) }, { "state-file", 0, 0, G_OPTION_ARG_FILENAME, &cli->state_file, N_("State file location"), N_(DEFAULT_STATE_FILE) }, { "no-auto-default", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_FILENAME, &cli->no_auto_default_file, N_("State file for no-auto-default devices"), N_(DEFAULT_NO_AUTO_DEFAULT_FILE) }, - { "plugins", 0, 0, G_OPTION_ARG_STRING, &cli->plugins, N_("List of plugins separated by ','"), N_(CONFIG_PLUGINS_DEFAULT) }, + { "plugins", 0, 0, G_OPTION_ARG_STRING, &cli->plugins, N_("List of plugins separated by ','"), N_(NM_CONFIG_PLUGINS_DEFAULT) }, { "configure-and-quit", 0, 0, G_OPTION_ARG_NONE, &cli->configure_and_quit, N_("Quit after initial configuration"), NULL }, { "debug", 'd', 0, G_OPTION_ARG_NONE, &cli->is_debug, N_("Don't become a daemon, and log to stderr"), NULL }, @@ -947,7 +947,6 @@ read_entire_config (const NMConfigCmdLineOptions *cli, guint i; gs_free char *o_config_main_file = NULL; GString *str; - char **plugins_default; g_return_val_if_fail (config_dir, NULL); g_return_val_if_fail (system_config_dir, NULL); @@ -958,11 +957,6 @@ read_entire_config (const NMConfigCmdLineOptions *cli, /* create a default configuration file. */ keyfile = nm_config_create_keyfile (); - plugins_default = g_strsplit (CONFIG_PLUGINS_DEFAULT, ",", -1); - if (plugins_default && plugins_default[0]) - nm_config_keyfile_set_string_list (keyfile, NM_CONFIG_KEYFILE_GROUP_MAIN, "plugins", (const char *const*) plugins_default, -1); - g_strfreev (plugins_default); - system_confs = _get_config_dir_files (system_config_dir); confs = _get_config_dir_files (config_dir); @@ -2305,8 +2299,6 @@ init_sync (GInitable *initable, GCancellable *cancellable, GError **error) priv->plugins = _nm_utils_strv_cleanup (g_key_file_get_string_list (keyfile, NM_CONFIG_KEYFILE_GROUP_MAIN, "plugins", NULL, NULL), TRUE, TRUE, TRUE); - if (!priv->plugins) - priv->plugins = g_new0 (char *, 1); priv->monitor_connection_files = nm_config_keyfile_get_boolean (keyfile, NM_CONFIG_KEYFILE_GROUP_MAIN, "monitor-connection-files", FALSE); diff --git a/src/settings/nm-settings.c b/src/settings/nm-settings.c index 3f2e38c3a6..aafb543750 100644 --- a/src/settings/nm-settings.c +++ b/src/settings/nm-settings.c @@ -2292,11 +2292,19 @@ nm_settings_start (NMSettings *self, GError **error) GDBusProxy *proxy; GVariant *variant; GError *local_error = NULL; + const char **plugins; + gs_strfreev char **plugins_default = NULL; priv = NM_SETTINGS_GET_PRIVATE (self); /* Load the plugins; fail if a plugin is not found. */ - if (!load_plugins (self, nm_config_get_plugins (priv->config), error)) { + plugins = nm_config_get_plugins (priv->config); + if (!plugins) { + plugins_default = g_strsplit (NM_CONFIG_PLUGINS_DEFAULT, ",", -1); + plugins = (const char **) plugins_default; + } + + if (!load_plugins (self, plugins, error)) { g_object_unref (self); return FALSE; } |