[gnome-shell/gnome-3-34] networkAgent: Drop VPN plugin cache
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/gnome-3-34] networkAgent: Drop VPN plugin cache
- Date: Tue, 17 Mar 2020 18:39:21 +0000 (UTC)
commit 2756806f847fc3076f6a23417ea17c4f4bd536c8
Author: Florian Müllner <fmuellner gnome org>
Date: Fri Mar 13 22:09:33 2020 +0100
networkAgent: Drop VPN plugin cache
libnm doesn't only search for plugins in the regular VPN plugin directory,
but also in the legacy location and the directory pointed to by the
NM_VPN_PLUGIN_DIR environment variable (if set).
We don't monitor the additional directories, so it's possible for our cache
to become outdated.
Instead of trying to play catch-up with libnm's internals, do what nm-applet
does and use the appropriate API to look up the plugin on each request.
https://gitlab.gnome.org/GNOME/gnome-shell/issues/2386
js/misc/config.js.in | 1 -
js/misc/meson.build | 1 -
js/ui/components/networkAgent.js | 54 +++++++++++++---------------------------
meson.build | 4 ---
4 files changed, 17 insertions(+), 43 deletions(-)
---
diff --git a/js/misc/config.js.in b/js/misc/config.js.in
index 065d7a0a2a..e54e280441 100644
--- a/js/misc/config.js.in
+++ b/js/misc/config.js.in
@@ -15,6 +15,5 @@ var LOCALEDIR = '@datadir@/locale';
/* other standard directories */
var LIBEXECDIR = '@libexecdir@';
var PKGDATADIR = '@datadir@/@PACKAGE_NAME@';
-var VPNDIR = '@vpndir@';
/* g-i package versions */
var LIBMUTTER_API_VERSION = '@LIBMUTTER_API_VERSION@'
diff --git a/js/misc/meson.build b/js/misc/meson.build
index 5a4871762a..2702c3dbc9 100644
--- a/js/misc/meson.build
+++ b/js/misc/meson.build
@@ -7,7 +7,6 @@ jsconf.set10('HAVE_BLUETOOTH', bt_dep.found())
jsconf.set10('HAVE_NETWORKMANAGER', have_networkmanager)
jsconf.set('datadir', datadir)
jsconf.set('libexecdir', libexecdir)
-jsconf.set('vpndir', vpndir)
config_js = configure_file(
input: 'config.js.in',
diff --git a/js/ui/components/networkAgent.js b/js/ui/components/networkAgent.js
index 517014bf1c..e1d688343c 100644
--- a/js/ui/components/networkAgent.js
+++ b/js/ui/components/networkAgent.js
@@ -622,14 +622,6 @@ var NetworkAgent = class {
this._vpnRequests = { };
this._notifications = { };
- this._pluginDir = Gio.file_new_for_path(Config.VPNDIR);
- try {
- let monitor = this._pluginDir.monitor(Gio.FileMonitorFlags.NONE, null);
- monitor.connect('changed', () => (this._vpnCacheBuilt = false));
- } catch (e) {
- log(`Failed to create monitor for VPN plugin dir: ${e.message}`);
- }
-
this._native.connect('new-request', this._newRequest.bind(this));
this._native.connect('cancel-request', this._cancelRequest.bind(this));
@@ -773,9 +765,7 @@ var NetworkAgent = class {
let vpnSetting = connection.get_setting_vpn();
let serviceType = vpnSetting.service_type;
- this._buildVPNServiceCache();
-
- let binary = this._vpnBinaries[serviceType];
+ let binary = this._findAuthBinary(serviceType);
if (!binary) {
log('Invalid VPN service type (cannot find authentication binary)');
@@ -791,36 +781,26 @@ var NetworkAgent = class {
this._vpnRequests[requestId] = vpnRequest;
}
- _buildVPNServiceCache() {
- if (this._vpnCacheBuilt)
- return;
-
- this._vpnCacheBuilt = true;
- this._vpnBinaries = { };
+ _findAuthBinary(serviceType) {
+ const plugin = NM.VpnPluginInfo.new_search_file(null, serviceType);
- NM.VpnPluginInfo.list_load().forEach(plugin => {
- let service = plugin.get_service();
- let fileName = plugin.get_auth_dialog();
- let supportsHints = plugin.supports_hints();
- let externalUIMode = false;
+ if (plugin === null)
+ return null;
- let prop = plugin.lookup_property('GNOME', 'supports-external-ui-mode');
- if (prop) {
- prop = prop.trim().toLowerCase();
- externalUIMode = ['true', 'yes', 'on', '1'].includes(prop);
- }
+ const fileName = plugin.get_auth_dialog();
+ if (!GLib.file_test(fileName, GLib.FileTest.IS_EXECUTABLE)) {
+ log('VPN plugin at %s is not executable'.format(fileName));
+ return null;
+ }
- if (GLib.file_test(fileName, GLib.FileTest.IS_EXECUTABLE)) {
- let binary = { fileName, externalUIMode, supportsHints };
- this._vpnBinaries[service] = binary;
+ const prop = plugin.lookup_property('GNOME', 'supports-external-ui-mode');
+ const trimmedProp = prop ? prop.trim().toLowerCase() : '';
- plugin.get_aliases().forEach(alias => {
- this._vpnBinaries[alias] = binary;
- });
- } else {
- log('VPN plugin at %s is not executable'.format(fileName));
- }
- });
+ return {
+ fileName,
+ supportsHints: plugin.supports_hints(),
+ externalUIMode: ['true', 'yes', 'on', '1'].includes(trimmedProp),
+ };
}
};
var Component = NetworkAgent;
diff --git a/meson.build b/meson.build
index 97de19758d..c9f1e2c4c3 100644
--- a/meson.build
+++ b/meson.build
@@ -115,12 +115,8 @@ if get_option('networkmanager')
nm_deps += dependency('libnm', version: nm_req)
nm_deps += dependency('libsecret-1', version: secret_req)
- vpndir = nm_deps[0].get_pkgconfig_variable('vpnservicedir')
-
have_networkmanager = true
else
- vpndir = prefix
-
have_networkmanager = false
endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]