From d1333cb2490f0ca3279305785c0471237f78e8a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Tue, 8 Jun 2021 00:17:48 +0200 Subject: [PATCH] status/network: Consider network-control action NetworkManager installs a `network-control` polkit action that can be used to disallow network configuration, except that we happily ignore it. Add it to the conditions that turn a network section insensitive. Part-of: --- js/ui/status/network.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/js/ui/status/network.js b/js/ui/status/network.js index 3a1d47aa1..3d336ed7e 100644 --- a/js/ui/status/network.js +++ b/js/ui/status/network.js @@ -1,6 +1,6 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- /* exported NMApplet */ -const { Clutter, Gio, GLib, GObject, Meta, NM, St } = imports.gi; +const { Clutter, Gio, GLib, GObject, Meta, NM, Polkit, St } = imports.gi; const Signals = imports.signals; const Animation = imports.ui.animation; @@ -1750,12 +1750,23 @@ class Indicator extends PanelMenu.SystemIndicator { this._client.connect('connection-added', this._connectionAdded.bind(this)); this._client.connect('connection-removed', this._connectionRemoved.bind(this)); + try { + this._configPermission = await Polkit.Permission.new( + 'org.freedesktop.NetworkManager.network-control', null, null); + } catch (e) { + log('No permission to control network connections: %s'.format(e.toString())); + this._configPermission = null; + } + Main.sessionMode.connect('updated', this._sessionUpdated.bind(this)); this._sessionUpdated(); } _sessionUpdated() { - let sensitive = !Main.sessionMode.isLocked && !Main.sessionMode.isGreeter; + const sensitive = + !Main.sessionMode.isLocked && + !Main.sessionMode.isGreeter && + this._configPermission && this._configPermission.allowed; this.menu.setSensitive(sensitive); }