diff --git a/src/settings/nm-settings.c b/src/settings/nm-settings.c index e9d3eaf24d..959ca94614 100644 --- a/src/settings/nm-settings.c +++ b/src/settings/nm-settings.c @@ -70,6 +70,13 @@ #include "nm-config.h" #include "NetworkManagerUtils.h" +#define LOG(level, ...) \ + G_STMT_START { \ + nm_log ((level), LOGD_CORE, \ + "settings: " _NM_UTILS_MACRO_FIRST(__VA_ARGS__) \ + _NM_UTILS_MACRO_REST(__VA_ARGS__)); \ + } G_STMT_END + /* LINKER CRACKROCK */ #define EXPORT(sym) void * __export_##sym = &sym; @@ -620,17 +627,20 @@ load_plugins (NMSettings *self, const char **plugins, GError **error) for (iter = plugins; iter && *iter; iter++) { GModule *plugin; char *full_name, *path; - const char *pname = *iter; + gs_free char *pname = NULL; GObject *obj; GObject * (*factory_func) (void); - /* strip leading spaces */ - while (g_ascii_isspace (*pname)) - pname++; + pname = g_strdup (*iter); + g_strstrip (pname); - /* ifcfg-fedora was renamed ifcfg-rh; handle old configs here */ - if (!strcmp (pname, "ifcfg-fedora")) - pname = "ifcfg-rh"; + if (!*pname) + continue; + + if (!*pname || strchr (pname, '/')) { + LOG (LOGL_WARN, "ignore invalid plugin \"%s\"", pname); + continue; + } obj = find_plugin (list, pname); if (obj) @@ -650,18 +660,18 @@ load_plugins (NMSettings *self, const char **plugins, GError **error) plugin = g_module_open (path, G_MODULE_BIND_LOCAL); if (!plugin) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, - "Could not load plugin '%s': %s", - pname, g_module_error ()); + LOG (LOGL_WARN, "Could not load plugin '%s': %s", + pname, g_module_error ()); g_free (full_name); g_free (path); - success = FALSE; - break; + continue; } g_free (full_name); g_free (path); + /* errors after this point are fatal, because we loaded the shared library already. */ + if (!g_module_symbol (plugin, "nm_system_config_factory", (gpointer) (&factory_func))) { g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "Could not find plugin '%s' factory function.",