libnm: register empty NMClient and NetworkManager when loading libnm with GIR

System Internals / NetworkManager - Lubomir Rintel [v3.sk] - 6 November 2017 10:47 EST

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

4d1f090ae libnm: register empty NMClient and NetworkManager when loading libnm with GIR
.gitignore | 3 +-
Makefile.am | 18 +++++++
configure.ac | 20 ++++++--
libnm/fake-typelib/NMClient.gir | 9 ++++
libnm/fake-typelib/NetworkManager.gir | 10 ++++
libnm/fake-typelib/typelibs.gresource.xml | 7 +++
libnm/nm-libnm-utils.c | 82 +++++++++++++++++++++++++++++++
7 files changed, 145 insertions(+), 4 deletions(-)

Upstream: cgit.freedesktop.org


  • Share