diff --git a/libnm-core/nm-setting.c b/libnm-core/nm-setting.c index 9ce8cdb0b4..1645b4bd88 100644 --- a/libnm-core/nm-setting.c +++ b/libnm-core/nm-setting.c @@ -2057,6 +2057,21 @@ static void nm_setting_class_init (NMSettingClass *setting_class) { GObjectClass *object_class = G_OBJECT_CLASS (setting_class); + GModule *self_module; + gpointer func; + + /* loading libnm and legacy libraries libnm-util/libnm-glib at the same + * time is not supported. The reason is, that both libraries use the same + * glib type names ("NMSetting"), and glib does not support namespacing + * to allow for that. + * + * Arbitrarily, add a check here, see whether a known symbol from libnm-util + * is present. If it is, it indicates that the process is borked and we + * abort. */ + self_module = g_module_open (NULL, 0); + if (g_module_symbol (self_module, "nm_util_get_private", &func)) + g_error ("libnm-util symbols detected; Mixing libnm with libnm-util/libnm-glib is not supported"); + g_module_close (self_module); g_type_class_add_private (setting_class, sizeof (NMSettingPrivate)); diff --git a/libnm-core/nm-utils.c b/libnm-core/nm-utils.c index bea6b427b0..2c9c1fd0ef 100644 --- a/libnm-core/nm-utils.c +++ b/libnm-core/nm-utils.c @@ -236,8 +236,6 @@ static void __attribute__((constructor)) _nm_utils_init (void) { static int initialized = 0; - GModule *self; - gpointer func; if (g_atomic_int_get (&initialized) != 0) return; @@ -249,11 +247,6 @@ _nm_utils_init (void) * Hence, a poor-man guard "initialized" above is more than sufficient, * although it does not guarantee that the code is not run concurrently. */ - self = g_module_open (NULL, 0); - if (g_module_symbol (self, "nm_util_get_private", &func)) - g_error ("libnm-util symbols detected; Mixing libnm with libnm-util/libnm-glib is not supported"); - g_module_close (self); - bindtextdomain (GETTEXT_PACKAGE, NMLOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");