summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2014-10-21 10:10:35 +0200
committerThomas Haller <thaller@redhat.com>2014-10-29 15:19:15 +0100
commitb2123a397a99ac88d894ae00650f31f9bcb45c10 (patch)
tree143e2f5ef3b671d741ea4fb8ac0bc1ebf93c98af
parent4545b6cb1e87d1262ece4a3def17b74af4062758 (diff)
downloadNetworkManager-b2123a397a99ac88d894ae00650f31f9bcb45c10.tar.gz
settings: accept missing settings plugins
Signed-off-by: Thomas Haller <thaller@redhat.com>
-rw-r--r--src/settings/nm-settings.c34
1 files changed, 22 insertions, 12 deletions
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);
+
+ if (!*pname)
+ continue;
- /* ifcfg-fedora was renamed ifcfg-rh; handle old configs here */
- if (!strcmp (pname, "ifcfg-fedora"))
- pname = "ifcfg-rh";
+ 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.",