Commit 13c21baf authored by Thomas Haller's avatar Thomas Haller

settings: ensure no duplicate plugin instances in load_plugin()

parent 8bb6ab55
...@@ -625,7 +625,7 @@ unrecognized_specs_changed (NMSystemConfigInterface *config, ...@@ -625,7 +625,7 @@ unrecognized_specs_changed (NMSystemConfigInterface *config,
nm_system_config_interface_get_unrecognized_specs); nm_system_config_interface_get_unrecognized_specs);
} }
static void static gboolean
add_plugin (NMSettings *self, NMSystemConfigInterface *plugin) add_plugin (NMSettings *self, NMSystemConfigInterface *plugin)
{ {
NMSettingsPrivate *priv; NMSettingsPrivate *priv;
...@@ -633,11 +633,16 @@ add_plugin (NMSettings *self, NMSystemConfigInterface *plugin) ...@@ -633,11 +633,16 @@ add_plugin (NMSettings *self, NMSystemConfigInterface *plugin)
char *pinfo = NULL; char *pinfo = NULL;
const char *path; const char *path;
g_return_if_fail (NM_IS_SETTINGS (self)); g_return_val_if_fail (NM_IS_SETTINGS (self), FALSE);
g_return_if_fail (NM_IS_SYSTEM_CONFIG_INTERFACE (plugin)); g_return_val_if_fail (NM_IS_SYSTEM_CONFIG_INTERFACE (plugin), FALSE);
priv = NM_SETTINGS_GET_PRIVATE (self); priv = NM_SETTINGS_GET_PRIVATE (self);
if (g_slist_find (priv->plugins, plugin)) {
/* don't add duplicates. */
return FALSE;
}
priv->plugins = g_slist_append (priv->plugins, g_object_ref (plugin)); priv->plugins = g_slist_append (priv->plugins, g_object_ref (plugin));
nm_system_config_interface_init (plugin, NULL); nm_system_config_interface_init (plugin, NULL);
...@@ -652,6 +657,8 @@ add_plugin (NMSettings *self, NMSystemConfigInterface *plugin) ...@@ -652,6 +657,8 @@ add_plugin (NMSettings *self, NMSystemConfigInterface *plugin)
NM_PRINT_FMT_QUOTED (path, " (", path, ")", "")); NM_PRINT_FMT_QUOTED (path, " (", path, ")", ""));
g_free (pname); g_free (pname);
g_free (pinfo); g_free (pinfo);
return TRUE;
} }
static GObject * static GObject *
...@@ -686,7 +693,8 @@ add_keyfile_plugin (NMSettings *self) ...@@ -686,7 +693,8 @@ add_keyfile_plugin (NMSettings *self)
keyfile_plugin = nm_settings_keyfile_plugin_new (); keyfile_plugin = nm_settings_keyfile_plugin_new ();
g_assert (keyfile_plugin); g_assert (keyfile_plugin);
add_plugin (self, NM_SYSTEM_CONFIG_INTERFACE (keyfile_plugin)); if (!add_plugin (self, NM_SYSTEM_CONFIG_INTERFACE (keyfile_plugin)))
g_return_if_reached ();
} }
static gboolean static gboolean
...@@ -808,8 +816,10 @@ load_plugin: ...@@ -808,8 +816,10 @@ load_plugin:
g_object_weak_ref (obj, (GWeakNotify) g_module_close, plugin); g_object_weak_ref (obj, (GWeakNotify) g_module_close, plugin);
g_object_set_data_full (obj, PLUGIN_MODULE_PATH, path, g_free); g_object_set_data_full (obj, PLUGIN_MODULE_PATH, path, g_free);
path = NULL; path = NULL;
add_plugin (self, NM_SYSTEM_CONFIG_INTERFACE (obj)); if (add_plugin (self, NM_SYSTEM_CONFIG_INTERFACE (obj)))
list = g_slist_append (list, obj); list = g_slist_append (list, obj);
else
g_object_unref (obj);
} }
next: next:
if (add_ibft && !strcmp (pname, "ifcfg-rh")) { if (add_ibft && !strcmp (pname, "ifcfg-rh")) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment