From 14037478633c15a38a63d46af5f7d28bc00fd376 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Wed, 12 Jun 2024 13:13:41 +0200 Subject: [PATCH] build: Add option to disable portal-helper The portal login window uses WebKit, which is a security-sensitive component that not all vendors want to support. Support that case with a build option, and update the captive portal handler to use the user's default browser if the portal-helper is disabled. Part-of: --- data/icons/meson.build | 10 +++++++++- data/meson.build | 2 +- js/meson.build | 14 ++++++++------ js/misc/config.js.in | 2 ++ js/misc/meson.build | 1 + js/ui/status/network.js | 13 ++++++++++--- meson.build | 5 +++++ meson_options.txt | 6 ++++++ src/meson.build | 2 +- 9 files changed, 43 insertions(+), 12 deletions(-) diff --git a/data/icons/meson.build b/data/icons/meson.build index eff6e4b53..277df017b 100644 --- a/data/icons/meson.build +++ b/data/icons/meson.build @@ -1 +1,9 @@ -install_subdir('hicolor', install_dir: icondir) +excluded_icons=[] +if not have_portal_helper + excluded_icons += [ + 'scalable/apps/org.gnome.Shell.CaptivePortal.svg', + 'symbolic/apps/org.gnome.Shell.CaptivePortal-symbolic.svg', + ] +endif +install_subdir('hicolor', + install_dir: icondir, exclude_files: excluded_icons) diff --git a/data/meson.build b/data/meson.build index 8654dfeca..ed13b6bae 100644 --- a/data/meson.build +++ b/data/meson.build @@ -6,7 +6,7 @@ desktop_files = [ ] service_files = [] -if have_networkmanager +if have_portal_helper desktop_files += 'org.gnome.Shell.PortalHelper.desktop' service_files += 'org.gnome.Shell.PortalHelper.service' endif diff --git a/js/meson.build b/js/meson.build index 4809f82b8..e594e2362 100644 --- a/js/meson.build +++ b/js/meson.build @@ -8,9 +8,11 @@ js_resources = gnome.compile_resources( dependencies: [config_js] ) -portal_resources = gnome.compile_resources( - 'portal-resources', 'portal-resources.gresource.xml', - source_dir: ['.', meson.current_build_dir()], - c_name: 'portal_js_resources', - dependencies: [config_js] -) +if have_portal_helper + portal_resources = gnome.compile_resources( + 'portal-resources', 'portal-resources.gresource.xml', + source_dir: ['.', meson.current_build_dir()], + c_name: 'portal_js_resources', + dependencies: [config_js] + ) +endif diff --git a/js/misc/config.js.in b/js/misc/config.js.in index ad8d46d84..ce319e0f8 100644 --- a/js/misc/config.js.in +++ b/js/misc/config.js.in @@ -7,6 +7,8 @@ export const PACKAGE_NAME = '@PACKAGE_NAME@'; export const PACKAGE_VERSION = '@PACKAGE_VERSION@'; /* 1 if networkmanager is available, 0 otherwise */ export const HAVE_NETWORKMANAGER = @HAVE_NETWORKMANAGER@; +/* 1 if portal helper is enabled, 0 otherwise */ +export const HAVE_PORTAL_HELPER = @HAVE_PORTAL_HELPER@; /* gettext package */ export const GETTEXT_PACKAGE = '@GETTEXT_PACKAGE@'; /* locale dir */ diff --git a/js/misc/meson.build b/js/misc/meson.build index 5aceefac4..5fc8ca433 100644 --- a/js/misc/meson.build +++ b/js/misc/meson.build @@ -4,6 +4,7 @@ jsconf.set('PACKAGE_VERSION', meson.project_version()) jsconf.set('GETTEXT_PACKAGE', meson.project_name()) jsconf.set('LIBMUTTER_API_VERSION', mutter_api_version) jsconf.set10('HAVE_NETWORKMANAGER', have_networkmanager) +jsconf.set10('HAVE_PORTAL_HELPER', have_portal_helper) jsconf.set('datadir', datadir) jsconf.set('libexecdir', libexecdir) diff --git a/js/ui/status/network.js b/js/ui/status/network.js index 72b3431da..cdc9ba892 100644 --- a/js/ui/status/network.js +++ b/js/ui/status/network.js @@ -10,6 +10,7 @@ import Polkit from 'gi://Polkit'; import Shell from 'gi://Shell'; import St from 'gi://St'; +import * as Config from '../../misc/config.js'; import * as Main from '../main.js'; import * as PopupMenu from '../popupMenu.js'; import * as MessageTray from '../messageTray.js'; @@ -1984,7 +1985,13 @@ class CaptivePortalHandler extends Signals.EventEmitter { } _onNotificationActivated(path) { - this._launchPortalHelper(path).catch(logError); + const context = global.create_app_launch_context( + global.get_current_time(), -1); + + if (Config.HAVE_PORTAL_HELPER) + this._launchPortalHelper(path, context).catch(logError); + else + Gio.AppInfo.launch_default_for_uri(this._checkUri, context); Main.overview.hide(); Main.panel.closeCalendar(); @@ -2007,8 +2014,7 @@ class CaptivePortalHandler extends Signals.EventEmitter { } } - async _launchPortalHelper(path) { - const timestamp = global.get_current_time(); + async _launchPortalHelper(path, context) { if (!this._portalHelperProxy) { this._portalHelperProxy = new Gio.DBusProxy({ g_connection: Gio.DBus.session, @@ -2030,6 +2036,7 @@ class CaptivePortalHandler extends Signals.EventEmitter { } } + const {timestamp} = context; this._portalHelperProxy?.AuthenticateAsync(path, this._checkUri, timestamp).catch(logError); this._connectivityQueue.add(path); } diff --git a/meson.build b/meson.build index 035f54732..4721bd601 100644 --- a/meson.build +++ b/meson.build @@ -107,6 +107,11 @@ else have_networkmanager = false endif +have_portal_helper = get_option('portal_helper') +if have_portal_helper and not have_networkmanager + error('Portal helper requires networkmanager support') +endif + if get_option('camera_monitor') libpipewire_dep = dependency('libpipewire-0.3', version: pipewire_req) have_pipewire = true diff --git a/meson_options.txt b/meson_options.txt index 6e83d92f2..01e0d5803 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -40,6 +40,12 @@ option('networkmanager', description: 'Enable NetworkManager support' ) +option('portal_helper', + type: 'boolean', + value: true, + description: 'Enable build-in network portal login' +) + option('systemd', type: 'boolean', value: true, diff --git a/src/meson.build b/src/meson.build index 752104e12..a3bf54248 100644 --- a/src/meson.build +++ b/src/meson.build @@ -286,7 +286,7 @@ executable('gnome-shell', 'main.c', install: true ) -if have_networkmanager +if have_portal_helper executable('gnome-shell-portal-helper', 'gnome-shell-portal-helper.c', portal_resources, c_args: tools_cflags,