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.
This commit is contained in:
@@ -134,7 +134,7 @@ test "$enable_ifupdown" = "yes" && distro_plugins="$distro_plugins,ifu
|
|||||||
test "$enable_ifnet" = "yes" && distro_plugins="$distro_plugins,ifnet"
|
test "$enable_ifnet" = "yes" && distro_plugins="$distro_plugins,ifnet"
|
||||||
distro_plugins="${distro_plugins#,}"
|
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
|
if test "${enable_config_plugin_ibft}" = yes; then
|
||||||
AC_DEFINE(WITH_SETTINGS_PLUGIN_IBFT, 1, [Whether compilation of ibft setting plugin is enabled])
|
AC_DEFINE(WITH_SETTINGS_PLUGIN_IBFT, 1, [Whether compilation of ibft setting plugin is enabled])
|
||||||
else
|
else
|
||||||
|
@@ -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) },
|
{ "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) },
|
{ "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) },
|
{ "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 },
|
{ "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 },
|
{ "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;
|
guint i;
|
||||||
gs_free char *o_config_main_file = NULL;
|
gs_free char *o_config_main_file = NULL;
|
||||||
GString *str;
|
GString *str;
|
||||||
char **plugins_default;
|
|
||||||
|
|
||||||
g_return_val_if_fail (config_dir, NULL);
|
g_return_val_if_fail (config_dir, NULL);
|
||||||
g_return_val_if_fail (system_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. */
|
/* create a default configuration file. */
|
||||||
keyfile = nm_config_create_keyfile ();
|
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);
|
system_confs = _get_config_dir_files (system_config_dir);
|
||||||
confs = _get_config_dir_files (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),
|
priv->plugins = _nm_utils_strv_cleanup (g_key_file_get_string_list (keyfile, NM_CONFIG_KEYFILE_GROUP_MAIN, "plugins", NULL, NULL),
|
||||||
TRUE, TRUE, TRUE);
|
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);
|
priv->monitor_connection_files = nm_config_keyfile_get_boolean (keyfile, NM_CONFIG_KEYFILE_GROUP_MAIN, "monitor-connection-files", FALSE);
|
||||||
|
|
||||||
|
@@ -2292,11 +2292,19 @@ nm_settings_start (NMSettings *self, GError **error)
|
|||||||
GDBusProxy *proxy;
|
GDBusProxy *proxy;
|
||||||
GVariant *variant;
|
GVariant *variant;
|
||||||
GError *local_error = NULL;
|
GError *local_error = NULL;
|
||||||
|
const char **plugins;
|
||||||
|
gs_strfreev char **plugins_default = NULL;
|
||||||
|
|
||||||
priv = NM_SETTINGS_GET_PRIVATE (self);
|
priv = NM_SETTINGS_GET_PRIVATE (self);
|
||||||
|
|
||||||
/* Load the plugins; fail if a plugin is not found. */
|
/* 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);
|
g_object_unref (self);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user