settings: add other check to ensure no duplicates in load_plugins()

We already avoid loading duplicate plugins by checking find_plugin().
That iterates the plugins @list and checks for duplicate names.
Additionally, also reject duplicates based on the @plugins list.

Also, move the check for "keyfile" before, so that all explicit
checks for (statically) known names are early and together.
This commit is contained in:
Thomas Haller 2015-08-11 10:50:17 +02:00
parent 9558560862
commit f979124dc9

View file

@ -726,10 +726,6 @@ load_plugins (NMSettings *self, const char **plugins, GError **error)
if (has_no_ibft && !strcmp (pname, "ibft"))
continue;
obj = find_plugin (list, pname);
if (obj)
continue;
/* keyfile plugin is built-in now */
if (strcmp (pname, "keyfile") == 0) {
if (!keyfile_added) {
@ -739,6 +735,17 @@ load_plugins (NMSettings *self, const char **plugins, GError **error)
continue;
}
if (_nm_utils_strv_find_first ((char **) plugins,
iter - plugins,
pname) >= 0) {
/* the plugin is already mentioned in the list previously.
* Don't load a duplicate. */
continue;
}
if (find_plugin (list, pname))
continue;
load_plugin:
{
GModule *plugin;