[gnome-shell] ShellUserVerifier: fix cancellation



commit 703417a76090f582eab470b124420b8b6e5d1e92
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Sun Aug 26 14:54:02 2012 +0200

    ShellUserVerifier: fix cancellation
    
    Ensure that all async callbacks check and ignore G_IO_ERROR_CANCELLED.
    Ensure that all runs of authentication have their own GCancellable, so
    that .begin() can be called multiple times on the same user verifier.
    Check for fingerprint reader when beginning authentication, and not
    when reset by GDM.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=682544

 js/gdm/util.js        |   54 +++++++++++++++++++++++++++++++++---------------
 js/ui/unlockDialog.js |    1 +
 2 files changed, 38 insertions(+), 17 deletions(-)
---
diff --git a/js/gdm/util.js b/js/gdm/util.js
index d07d1b2..d2e537a 100644
--- a/js/gdm/util.js
+++ b/js/gdm/util.js
@@ -79,18 +79,17 @@ const ShellUserVerifier = new Lang.Class({
 
         this._settings = new Gio.Settings({ schema: LOGIN_SCREEN_SCHEMA });
 
-        this._cancellable = new Gio.Cancellable();
-
         this._fprintManager = new Fprint.FprintManager();
-        this._checkForFingerprintReader();
-
         this._realmManager = new Realmd.Manager();
     },
 
     begin: function(userName, hold) {
+        this._cancellable = new Gio.Cancellable();
         this._hold = hold;
         this._userName = userName;
 
+        this._checkForFingerprintReader();
+
         if (userName) {
             // If possible, reauthenticate an already running session,
             // so any session specific credentials get updated appropriately
@@ -102,15 +101,18 @@ const ShellUserVerifier = new Lang.Class({
     },
 
     cancel: function() {
-        this._cancellable.cancel();
+        if (this._cancellable)
+            this._cancellable.cancel();
 
         if (this._userVerifier)
             this._userVerifier.call_cancel_sync(null);
-        this._cancellable = new Gio.Cancellable();
     },
 
     clear: function() {
-        this._cancellable.cancel();
+        if (this._cancellable) {
+            this._cancellable.cancel();
+            this._cancellable = null;
+        }
 
         if (this._userVerifier) {
             this._userVerifier.run_dispose();
@@ -144,11 +146,12 @@ const ShellUserVerifier = new Lang.Class({
             this._hold.release();
         } catch (e) {
             if (this._reauthOnly) {
-                logError(e, 'Failed to open reauthentication channel');
+                if (e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED))
+                    return;
 
-                this._hold.release();
+                logError(e, 'Failed to open reauthentication channel');
                 this.emit('verification-failed');
-
+                this._hold.release();
                 return;
             }
 
@@ -159,10 +162,14 @@ const ShellUserVerifier = new Lang.Class({
     },
 
     _userVerifierGot: function(client, result) {
-        this._userVerifier = client.get_user_verifier_finish(result);
+        try {
+            this._userVerifier = client.get_user_verifier_finish(result);
+        } catch(e if e.matches(Gio.IOErrorEnum, Gio.ErrorEnum.CANCELLED)) {
+            return;
+        }
+
         this._connectSignals();
         this._beginVerification();
-
         this._hold.release();
     },
 
@@ -184,7 +191,12 @@ const ShellUserVerifier = new Lang.Class({
                                                                 this._userName,
                                                                 this._cancellable,
                                                                 Lang.bind(this, function(obj, result) {
-                obj.call_begin_verification_for_user_finish(result);
+                try {
+                    obj.call_begin_verification_for_user_finish(result);
+                } catch(e if e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED)) {
+                    return;
+                }
+
                 this._hold.release();
             }));
 
@@ -195,7 +207,12 @@ const ShellUserVerifier = new Lang.Class({
                                                                     this._userName,
                                                                     this._cancellable,
                                                                     Lang.bind(this, function(obj, result) {
-                    obj.call_begin_verification_for_user_finish(result);
+                    try {
+                        obj.call_begin_verification_for_user_finish(result);
+                    } catch(e if e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED)) {
+                        return;
+                    }
+
                     this._hold.release();
                 }));
             }
@@ -203,7 +220,12 @@ const ShellUserVerifier = new Lang.Class({
             this._userVerifier.call_begin_verification(PASSWORD_SERVICE_NAME,
                                                        this._cancellable,
                                                        Lang.bind(this, function(obj, result) {
-                obj.call_begin_verification_finish(result);
+                try {
+                    obj.call_begin_verification_finish(result);
+                } catch(e if e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED)) {
+                    return;
+                }
+
                 this._hold.release();
             }));
         }
@@ -271,8 +293,6 @@ const ShellUserVerifier = new Lang.Class({
         this._userVerifier.run_dispose();
         this._userVerifier = null;
 
-        this._checkForFingerprintReader();
-
         this.emit('reset');
     },
 
diff --git a/js/ui/unlockDialog.js b/js/ui/unlockDialog.js
index a4d666d..da10cec 100644
--- a/js/ui/unlockDialog.js
+++ b/js/ui/unlockDialog.js
@@ -166,6 +166,7 @@ const UnlockDialog = new Lang.Class({
     },
 
     _reset: function() {
+        this._userVerifier.clear();
         this._userVerifier.begin(this._userName, new Batch.Hold());
     },
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]