Blame SOURCES/gdm-networking.patch

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