a3db19
From ed0699886f49e5dd8d6ca9ffb60ba17cd76a810f Mon Sep 17 00:00:00 2001
a3db19
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
a3db19
Date: Mon, 7 Jun 2021 17:49:57 +0200
a3db19
Subject: [PATCH 1/5] status/network: Disable modem connection when windows
a3db19
 aren't allowed
a3db19
a3db19
The item launches the corresponding Settings panel when activated, which
a3db19
doesn't work when windows are disabled by the session mode. Rather than
a3db19
failing silently, turn the item insensitive.
a3db19
---
a3db19
 js/ui/status/network.js | 12 ++++++++++++
a3db19
 1 file changed, 12 insertions(+)
a3db19
a3db19
diff --git a/js/ui/status/network.js b/js/ui/status/network.js
a3db19
index b3bb7589c..3ad7b04dd 100644
a3db19
--- a/js/ui/status/network.js
a3db19
+++ b/js/ui/status/network.js
a3db19
@@ -514,6 +514,10 @@ var NMDeviceModem = class extends NMConnectionDevice {
a3db19
                 this._iconChanged();
a3db19
             });
a3db19
         }
a3db19
+
a3db19
+        this._sessionUpdatedId =
a3db19
+            Main.sessionMode.connect('updated', this._sessionUpdated.bind(this));
a3db19
+        this._sessionUpdated();
a3db19
     }
a3db19
 
a3db19
     get category() {
a3db19
@@ -525,6 +529,10 @@ var NMDeviceModem = class extends NMConnectionDevice {
a3db19
                     'connect-3g', this._device.get_path()]);
a3db19
     }
a3db19
 
a3db19
+    _sessionUpdated() {
a3db19
+        this._autoConnectItem.sensitive = Main.sessionMode.hasWindows;
a3db19
+    }
a3db19
+
a3db19
     destroy() {
a3db19
         if (this._operatorNameId) {
a3db19
             this._mobileDevice.disconnect(this._operatorNameId);
a3db19
@@ -534,6 +542,10 @@ var NMDeviceModem = class extends NMConnectionDevice {
a3db19
             this._mobileDevice.disconnect(this._signalQualityId);
a3db19
             this._signalQualityId = 0;
a3db19
         }
a3db19
+        if (this._sessionUpdatedId) {
a3db19
+            Main.sessionMode.disconnect(this._sessionUpdatedId);
a3db19
+            this._sessionUpdatedId = 0;
a3db19
+        }
a3db19
 
a3db19
         super.destroy();
a3db19
     }
a3db19
-- 
a3db19
2.31.1
a3db19
a3db19
a3db19
From 59d52e1591e1522fff22320c657496ca978a7926 Mon Sep 17 00:00:00 2001
a3db19
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
a3db19
Date: Mon, 7 Jun 2021 18:28:32 +0200
a3db19
Subject: [PATCH 2/5] status/network: Only list wifi networks that can be
a3db19
 activated
a3db19
a3db19
Setting up a connection for an Enterprise WPA(2) encrypted wireless
a3db19
network requires Settings. That's not available when windows are
a3db19
disabled via the session mode, so filter out affected entries.
a3db19
---
a3db19
 js/ui/status/network.js | 29 ++++++++++++++++++++++++++++-
a3db19
 1 file changed, 28 insertions(+), 1 deletion(-)
a3db19
a3db19
diff --git a/js/ui/status/network.js b/js/ui/status/network.js
a3db19
index 3ad7b04dd..c023022a7 100644
a3db19
--- a/js/ui/status/network.js
a3db19
+++ b/js/ui/status/network.js
a3db19
@@ -1,5 +1,5 @@
a3db19
 // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
a3db19
-const { Clutter, Gio, GLib, GObject, NM, St } = imports.gi;
a3db19
+const { Clutter, Gio, GLib, GObject, Meta, NM, St } = imports.gi;
a3db19
 const Mainloop = imports.mainloop;
a3db19
 const Signals = imports.signals;
a3db19
 
a3db19
@@ -751,6 +751,11 @@ var NMWirelessDialog = class extends ModalDialog.ModalDialog {
a3db19
             this._scanTimeoutId = 0;
a3db19
         }
a3db19
 
a3db19
+        if (this._syncVisibilityId) {
a3db19
+            Meta.later_remove(this._syncVisibilityId);
a3db19
+            this._syncVisibilityId = 0;
a3db19
+        }
a3db19
+
a3db19
         super.destroy();
a3db19
     }
a3db19
 
a3db19
@@ -1081,9 +1086,31 @@ var NMWirelessDialog = class extends ModalDialog.ModalDialog {
a3db19
             this._itemBox.insert_child_at_index(network.item.actor, newPos);
a3db19
         }
a3db19
 
a3db19
+        this._queueSyncItemVisibility();
a3db19
         this._syncView();
a3db19
     }
a3db19
 
a3db19
+    _queueSyncItemVisibility() {
a3db19
+        if (this._syncVisibilityId)
a3db19
+            return;
a3db19
+
a3db19
+        this._syncVisibilityId = Meta.later_add(
a3db19
+            Meta.LaterType.BEFORE_REDRAW,
a3db19
+            () => {
a3db19
+                const { hasWindows } = Main.sessionMode;
a3db19
+                const { WPA2_ENT, WPA_ENT } = NMAccessPointSecurity;
a3db19
+
a3db19
+                for (const network of this._networks) {
a3db19
+                    const [firstAp] = network.accessPoints;
a3db19
+                    network.item.visible =
a3db19
+                        hasWindows ||
a3db19
+                        network.connections.length > 0 ||
a3db19
+                        (firstAp._secType !== WPA2_ENT && firstAp._secType !== WPA_ENT);
a3db19
+                }
a3db19
+                return GLib.SOURCE_REMOVE;
a3db19
+            });
a3db19
+    }
a3db19
+
a3db19
     _accessPointRemoved(device, accessPoint) {
a3db19
         let res = this._findExistingNetwork(accessPoint);
a3db19
 
a3db19
-- 
a3db19
2.31.1
a3db19
a3db19
a3db19
From 9d204cdb38bcfee214dbe0b0bf9c2073dc50fe93 Mon Sep 17 00:00:00 2001
a3db19
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
a3db19
Date: Tue, 8 Jun 2021 00:17:48 +0200
a3db19
Subject: [PATCH 3/5] status/network: Consider network-control action
a3db19
a3db19
NetworkManager installs a `network-control` polkit action that can
a3db19
be used to disallow network configuration, except that we happily
a3db19
ignore it. Add it to the conditions that turn a network section
a3db19
insensitive.
a3db19
---
a3db19
 js/ui/status/network.js | 20 +++++++++++++++++---
a3db19
 1 file changed, 17 insertions(+), 3 deletions(-)
a3db19
a3db19
diff --git a/js/ui/status/network.js b/js/ui/status/network.js
a3db19
index c023022a7..79729e01b 100644
a3db19
--- a/js/ui/status/network.js
a3db19
+++ b/js/ui/status/network.js
a3db19
@@ -1,5 +1,5 @@
a3db19
 // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
a3db19
-const { Clutter, Gio, GLib, GObject, Meta, NM, St } = imports.gi;
a3db19
+const { Clutter, Gio, GLib, GObject, Meta, NM, Polkit, St } = imports.gi;
a3db19
 const Mainloop = imports.mainloop;
a3db19
 const Signals = imports.signals;
a3db19
 
a3db19
@@ -1683,11 +1683,25 @@ var NMApplet = class extends PanelMenu.SystemIndicator {
a3db19
         this._client.connect('connection-removed', this._connectionRemoved.bind(this));
a3db19
 
a3db19
         Main.sessionMode.connect('updated', this._sessionUpdated.bind(this));
a3db19
-        this._sessionUpdated();
a3db19
+
a3db19
+        this._configPermission = null;
a3db19
+        Polkit.Permission.new(
a3db19
+            'org.freedesktop.NetworkManager.network-control', null, null,
a3db19
+            (o, res) => {
a3db19
+                try {
a3db19
+                    this._configPermission = Polkit.Permission.new_finish(res);
a3db19
+                } catch (e) {
a3db19
+                    log('No permission to control network connections: %s'.format(e.toString()));
a3db19
+                }
a3db19
+                this._sessionUpdated();
a3db19
+            });
a3db19
     }
a3db19
 
a3db19
     _sessionUpdated() {
a3db19
-        let sensitive = !Main.sessionMode.isLocked && !Main.sessionMode.isGreeter;
a3db19
+        const sensitive =
a3db19
+            !Main.sessionMode.isLocked &&
a3db19
+            !Main.sessionMode.isGreeter &&
a3db19
+            this._configPermission && this._configPermission.allowed;
a3db19
         this.menu.setSensitive(sensitive);
a3db19
     }
a3db19
 
a3db19
-- 
a3db19
2.31.1
a3db19
a3db19
a3db19
From 7d2c8aabb86b9942c99ae9b7157dbffb875acde9 Mon Sep 17 00:00:00 2001
a3db19
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
a3db19
Date: Thu, 10 Jun 2021 23:12:27 +0200
a3db19
Subject: [PATCH 4/5] sessionMode: Enable networkAgent on login screen
a3db19
a3db19
We will soon enable the network sections in the status menu on the
a3db19
login screen, so enable the network agent to handle authentication
a3db19
requests (like wifi/VPN passwords).
a3db19
---
a3db19
 js/ui/sessionMode.js | 4 +++-
a3db19
 1 file changed, 3 insertions(+), 1 deletion(-)
a3db19
a3db19
diff --git a/js/ui/sessionMode.js b/js/ui/sessionMode.js
a3db19
index 25aa75a3d..fa7f83416 100644
a3db19
--- a/js/ui/sessionMode.js
a3db19
+++ b/js/ui/sessionMode.js
a3db19
@@ -43,7 +43,9 @@ const _modes = {
a3db19
         isGreeter: true,
a3db19
         isPrimary: true,
a3db19
         unlockDialog: imports.gdm.loginDialog.LoginDialog,
a3db19
-        components: ['polkitAgent'],
a3db19
+        components: Config.HAVE_NETWORKMANAGER
a3db19
+            ? ['networkAgent', 'polkitAgent']
a3db19
+            : ['polkitAgent'],
a3db19
         panel: {
a3db19
             left: [],
a3db19
             center: ['dateMenu'],
a3db19
-- 
a3db19
2.31.1
a3db19
a3db19
a3db19
From 07ce899bcb9d30991262d6c484508e6c5fa14c85 Mon Sep 17 00:00:00 2001
a3db19
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
a3db19
Date: Tue, 8 Jun 2021 00:19:26 +0200
a3db19
Subject: [PATCH 5/5] status/network: Do not disable on login screen
a3db19
a3db19
We currently disable all network items on both the lock- and login
a3db19
screen. While it makes sense to be very restrictive on the lock screen,
a3db19
there are some (fringe) use cases for being more permissive on the
a3db19
login screen (like remote home directories only accessible via VPN).
a3db19
a3db19
There's precedence with the power-off/restart actions to be less
a3db19
restrictive on the login screen, and since we started respecting
a3db19
the `network-control` polkit action, it's possible to restore the
a3db19
old behavior if desired.
a3db19
---
a3db19
 js/ui/status/network.js | 1 -
a3db19
 1 file changed, 1 deletion(-)
a3db19
a3db19
diff --git a/js/ui/status/network.js b/js/ui/status/network.js
a3db19
index 79729e01b..914dbbd99 100644
a3db19
--- a/js/ui/status/network.js
a3db19
+++ b/js/ui/status/network.js
a3db19
@@ -1700,7 +1700,6 @@ var NMApplet = class extends PanelMenu.SystemIndicator {
a3db19
     _sessionUpdated() {
a3db19
         const sensitive =
a3db19
             !Main.sessionMode.isLocked &&
a3db19
-            !Main.sessionMode.isGreeter &&
a3db19
             this._configPermission && this._configPermission.allowed;
a3db19
         this.menu.setSensitive(sensitive);
a3db19
     }
a3db19
-- 
a3db19
2.31.1
a3db19