Blame SOURCES/gdm-networking.patch

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