From ad5acb8fccb8b9ec4ca1c7874a59c8e4b08ecc8a Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Wed, 15 May 2024 09:34:49 -0400 Subject: [PATCH] Fix error handling in fingerprint code --- fix-fingerprint-failure-handling.patch | 101 +++++++++++++++++++++++++ gnome-shell.spec | 1 + 2 files changed, 102 insertions(+) create mode 100644 fix-fingerprint-failure-handling.patch diff --git a/fix-fingerprint-failure-handling.patch b/fix-fingerprint-failure-handling.patch new file mode 100644 index 0000000..98ccb94 --- /dev/null +++ b/fix-fingerprint-failure-handling.patch @@ -0,0 +1,101 @@ +From 01302cee25955aecc2b3f391d48e36f8c8b6b322 Mon Sep 17 00:00:00 2001 +From: rpm-build +Date: Wed, 15 May 2024 09:14:09 -0400 +Subject: [PATCH] gdm/util: Make sure error is GError before checking it + +The fingerprint device fetching code has a generic error handler, +that assumes the passed in error is GError. If it's not a +GError it will fail trying to use GError specific methods. + +This commit adds some validation checking. +--- + js/gdm/util.js | 19 ++++++++++--------- + 1 file changed, 10 insertions(+), 9 deletions(-) + +diff --git a/js/gdm/util.js b/js/gdm/util.js +index efc5a1f..9f39367 100644 +--- a/js/gdm/util.js ++++ b/js/gdm/util.js +@@ -369,69 +369,70 @@ export class ShellUserVerifier extends Signals.EventEmitter { + + const fprintDeviceProxy = this._getFingerprintDeviceProxy(devicePath); + fprintDeviceProxy.init(null); + this._setFingerprintReaderType(fprintDeviceProxy['scan-type']); + } else { + // Ensure fingerprint service starts, but do not wait for it + const cancellable = this._cancellable; + await fprintManager.init_async(GLib.PRIORITY_DEFAULT, cancellable); + await this._updateFingerprintReaderType(fprintManager, cancellable); + this._fprintManager = fprintManager; + } + } catch (e) { + this._handleFingerprintError(e); + } + } + + _getFingerprintDeviceProxy(devicePath) { + return new Gio.DBusProxy({ + g_connection: Gio.DBus.system, + g_name: 'net.reactivated.Fprint', + g_object_path: devicePath, + g_interface_name: FprintDeviceInfo.name, + g_interface_info: FprintDeviceInfo, + g_flags: Gio.DBusProxyFlags.DO_NOT_CONNECT_SIGNALS, + }); + } + + _handleFingerprintError(e) { + this._fingerprintReaderType = FingerprintReaderType.NONE; + +- if (e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED)) +- return; +- if (e.matches(Gio.DBusError, Gio.DBusError.SERVICE_UNKNOWN)) +- return; +- +- if (Gio.DBusError.is_remote_error(e) && +- Gio.DBusError.get_remote_error(e) === +- 'net.reactivated.Fprint.Error.NoSuchDevice') +- return; ++ if (e instanceof GLib.Error) { ++ if (e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED)) ++ return; ++ if (e.matches(Gio.DBusError, Gio.DBusError.SERVICE_UNKNOWN)) ++ return; ++ if (Gio.DBusError.is_remote_error(e) && ++ Gio.DBusError.get_remote_error(e) === ++ 'net.reactivated.Fprint.Error.NoSuchDevice') ++ return; ++ } + + logError(e, 'Failed to interact with fprintd service'); + } + + async _checkForFingerprintReader() { + if (!this._fprintManager) { + this._updateDefaultService(); + return; + } + + if (this._fingerprintReaderType !== FingerprintReaderType.NONE) + return; + + await this._updateFingerprintReaderType(this._fprintManager, this._cancellable); + } + + async _updateFingerprintReaderType(fprintManager, cancellable) { + // Wrappers don't support null cancellable, so let's ignore it in case + const args = cancellable ? [cancellable] : []; + const [devicePath] = await fprintManager.GetDefaultDeviceAsync(...args); + const fprintDeviceProxy = this._getFingerprintDeviceProxy(devicePath); + await fprintDeviceProxy.init_async(GLib.PRIORITY_DEFAULT, cancellable); + this._setFingerprintReaderType(fprintDeviceProxy['scan-type']); + this._updateDefaultService(); + + if (this._userVerifier && + !this._activeServices.has(FINGERPRINT_SERVICE_NAME)) { + if (!this._hold?.isAcquired()) + this._hold = new Batch.Hold(); + await this._maybeStartFingerprintVerification(); +-- +2.44.0 + diff --git a/gnome-shell.spec b/gnome-shell.spec index 9d79320..ec2280b 100644 --- a/gnome-shell.spec +++ b/gnome-shell.spec @@ -32,6 +32,7 @@ Patch: enforce-smartcard-at-unlock.patch Patch: disable-unlock-entry-until-question.patch Patch: 0001-loginDialog-make-info-messages-themed.patch Patch: fix-stuck-prompt.patch +Patch: fix-fingerprint-failure-handling.patch # Extensions Patch: 0001-extensionDownloader-Refuse-to-override-system-extens.patch