Add patch to make portal helper optional

Unfortunately we do not have consensus on whether or how to upstream
this, so it will be a downstream patch for now.
This commit is contained in:
Michael Catanzaro 2023-11-09 10:55:29 -06:00
parent 6937b62ca2
commit 38630fcfc5
2 changed files with 50 additions and 0 deletions

View File

@ -12,6 +12,9 @@ Source0: https://download.gnome.org/sources/gnome-shell/45/%{name}-%{tarb
# Replace Epiphany with Firefox in the default favourite apps list # Replace Epiphany with Firefox in the default favourite apps list
Patch: gnome-shell-favourite-apps-firefox.patch Patch: gnome-shell-favourite-apps-firefox.patch
# No portal helper if WebKitGTK is not installed
Patch: optional-portal-helper.patch
# Some users might have a broken PAM config, so we really need this # Some users might have a broken PAM config, so we really need this
# downstream patch to stop trying on configuration errors. # downstream patch to stop trying on configuration errors.
Patch: 0001-gdm-Work-around-failing-fingerprint-auth.patch Patch: 0001-gdm-Work-around-failing-fingerprint-auth.patch

View File

@ -0,0 +1,47 @@
diff --git a/js/portalHelper/main.js b/js/portalHelper/main.js
index 7000089fa..d9a768a3f 100644
--- a/js/portalHelper/main.js
+++ b/js/portalHelper/main.js
@@ -3,7 +3,13 @@ import Gio from 'gi://Gio';
import GLib from 'gi://GLib';
import GObject from 'gi://GObject';
import Gtk from 'gi://Gtk?version=4.0';
-import WebKit from 'gi://WebKit?version=6.0';
+
+let WebKit;
+try {
+ WebKit = (await import('gi://WebKit?version=6.0')).default;
+} catch {
+ WebKit = null;
+}
import * as Gettext from 'gettext';
import {programInvocationName, programArgs} from 'system';
@@ -365,5 +371,9 @@ class WebPortalHelper extends Adw.Application {
Gettext.bindtextdomain(Config.GETTEXT_PACKAGE, Config.LOCALEDIR);
Gettext.textdomain(Config.GETTEXT_PACKAGE);
-const app = new WebPortalHelper();
-await app.runAsync([programInvocationName, ...programArgs]);
+if (WebKit) {
+ const app = new WebPortalHelper();
+ await app.runAsync([programInvocationName, ...programArgs]);
+} else {
+ log('WebKit typelib is not installed, captive portal helper will be disabled');
+}
diff --git a/js/ui/status/network.js b/js/ui/status/network.js
index 322d7d91a..afca42e31 100644
--- a/js/ui/status/network.js
+++ b/js/ui/status/network.js
@@ -2147,7 +2147,9 @@ class Indicator extends SystemIndicator {
await this._portalHelperProxy.init_async(
GLib.PRIORITY_DEFAULT, null);
} catch (e) {
- console.error(`Error launching the portal helper: ${e.message}`);
+ // Timeout is expected if WebKit is unavailable
+ if (!error.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.TIMED_OUT))
+ console.error(`Error launching the portal helper: ${e.message}`);
}
}