From 4d1f090aedf05c0e2955d431638e311d1e18a52f Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Sat, 4 Nov 2017 20:41:45 +0100 Subject: libnm: register empty NMClient and NetworkManager when loading libnm with GIR Register empty "NMClient" and "NetworkManager" GIR modules as soon as libnm is loaded witch gnome-introspection. This prevents the real modules from being loaded because they would in turn load libnm-glib and abort() and crash. In particular this prevents the GNOME shell from crashing with libnm-glib abort and allows gracefully disabling the extensions which use the obsolete library. Test: $ cat test.js const NM = imports.gi.NM; print (NM.SecretAgentGetSecretsFlags.ALLOW_INTERACTION); const NMClient = imports.gi.NMClient; print (NMClient.SecretAgentGetSecretsFlags.ALLOW_INTERACTION); Before: $ gjs test.js 1 (gjs:16253): libnm-util-ERROR **: libnm symbols detected; Mixing libnm with libnm-util/libnm-glib is not supported Trace/breakpoint trap (core dumped) $ After: $ gjs test.js 1 Gjs-Message: JS WARNING: [test.js 5]: reference to undefined property "SecretAgentGetSecretsFlags" (gjs:16228): Gjs-WARNING **: JS ERROR: TypeError: NMClient.SecretAgentGetSecretsFlags is undefined @test.js:5:1 JS_EvaluateScript() failed --- Makefile.am | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'Makefile.am') diff --git a/Makefile.am b/Makefile.am index cda851a094..58be8ef91c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -858,6 +858,7 @@ nodist_libnminclude_HEADERS += \ noinst_LTLIBRARIES += libnm/libnm-utils.la libnm_libnm_utils_la_CPPFLAGS = \ + $(INTROSPECTION_CFLAGS) \ $(libnm_lib_cppflags) libnm_libnm_utils_la_SOURCES = \ @@ -956,6 +957,23 @@ libnm/libnm.typelib: libnm/libnm.gir $(INTROSPECTION_COMPILER) --includedir=$(srcdir)/libnm-core --includedir=$(builddir)/libnm-core --includedir=$(srcdir)/libnm --includedir=$(builddir)/libnm $< -o $@ INTROSPECTION_GIRS += libnm/NM-1.0.gir + +if WITH_FAKE_TYPELIBS + +libnm/fake-typelib/NetworkManager.typelib: libnm/fake-typelib/NetworkManager.gir + $(AM_V_GEN) $(INTROSPECTION_COMPILER) $< -o $@ + +libnm/fake-typelib/NMClient.typelib: libnm/fake-typelib/NMClient.gir + $(AM_V_GEN) $(INTROSPECTION_COMPILER) $< -o $@ + +libnm/fake-typelib/typelibs.c: libnm/fake-typelib/typelibs.gresource.xml libnm/fake-typelib/NetworkManager.typelib libnm/fake-typelib/NMClient.typelib + $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) $< --target=$@ --sourcedir=$(srcdir)/libnm/fake-typelib --generate-source --manual-register --internal + +libnm_libnm_utils_la_SOURCES += \ + libnm/fake-typelib/typelibs.c + +endif + endif if HAVE_INTROSPECTION -- cgit v1.2.1