Blame SOURCES/0002-gdmUtil-enable-support-for-GDM-s-ChoiceList-PAM-exte.patch

671c89
From c3ab03f8721ea96df6ac91c0393ed13ba750ab7e Mon Sep 17 00:00:00 2001
671c89
From: Ray Strode <rstrode@redhat.com>
671c89
Date: Mon, 17 Jul 2017 16:48:03 -0400
671c89
Subject: [PATCH 2/2] gdmUtil: enable support for GDM's ChoiceList PAM
671c89
 extension
671c89
671c89
This commit hooks up support for GDM's ChoiceList PAM extension.
671c89
---
671c89
 js/gdm/authPrompt.js  | 74 ++++++++++++++++++++++++++++++++++++++++++-
671c89
 js/gdm/loginDialog.js |  5 +++
671c89
 js/gdm/util.js        | 28 ++++++++++++++++
671c89
 js/ui/unlockDialog.js |  9 +++++-
671c89
 4 files changed, 114 insertions(+), 2 deletions(-)
671c89
671c89
diff --git a/js/gdm/authPrompt.js b/js/gdm/authPrompt.js
671c89
index cf77b3f26..71069e93b 100644
671c89
--- a/js/gdm/authPrompt.js
671c89
+++ b/js/gdm/authPrompt.js
671c89
@@ -4,6 +4,7 @@ const { Clutter, GLib, Pango, Shell, St } = imports.gi;
671c89
 const Signals = imports.signals;
671c89
 
671c89
 const Animation = imports.ui.animation;
671c89
+const AuthList = imports.gdm.authList;
671c89
 const Batch = imports.gdm.batch;
671c89
 const GdmUtil = imports.gdm.util;
671c89
 const Meta = imports.gi.Meta;
671c89
@@ -54,6 +55,7 @@ var AuthPrompt = class {
671c89
 
671c89
         this._userVerifier.connect('ask-question', this._onAskQuestion.bind(this));
671c89
         this._userVerifier.connect('show-message', this._onShowMessage.bind(this));
671c89
+        this._userVerifier.connect('show-choice-list', this._onShowChoiceList.bind(this));
671c89
         this._userVerifier.connect('verification-failed', this._onVerificationFailed.bind(this));
671c89
         this._userVerifier.connect('verification-complete', this._onVerificationComplete.bind(this));
671c89
         this._userVerifier.connect('reset', this._onReset.bind(this));
671c89
@@ -116,6 +118,28 @@ var AuthPrompt = class {
671c89
 
671c89
         this.actor.add(this._timedLoginIndicator);
671c89
 
671c89
+        this._authList = new AuthList.AuthList();
671c89
+        this._authList.connect('activate', (list, key) => {
671c89
+            this._authList.actor.reactive = false;
671c89
+            Tweener.addTween(this._authList.actor,
671c89
+                             { opacity: 0,
671c89
+                               time: MESSAGE_FADE_OUT_ANIMATION_TIME,
671c89
+                               transition: 'easeOutQuad',
671c89
+                               onComplete: () => {
671c89
+                                   this._authList.clear();
671c89
+                                   this._authList.actor.hide();
671c89
+                                   this._userVerifier.selectChoice(this._queryingService, key);
671c89
+
671c89
+                               }
671c89
+                             });
671c89
+        });
671c89
+        this._authList.actor.hide();
671c89
+        this.actor.add(this._authList.actor,
671c89
+                       { expand: true,
671c89
+                         x_fill: true,
671c89
+                         y_fill: false,
671c89
+                         x_align: St.Align.START });
671c89
+
671c89
         this._message = new St.Label({ opacity: 0,
671c89
                                        styleClass: 'login-dialog-message' });
671c89
         this._message.clutter_text.line_wrap = true;
671c89
@@ -258,6 +282,21 @@ var AuthPrompt = class {
671c89
         this.emit('prompted');
671c89
     }
671c89
 
671c89
+    _onShowChoiceList(userVerifier, serviceName, promptMessage, choiceList) {
671c89
+        if (this._queryingService)
671c89
+            this.clear();
671c89
+
671c89
+        this._queryingService = serviceName;
671c89
+
671c89
+        if (this._preemptiveAnswer)
671c89
+            this._preemptiveAnswer = null;
671c89
+
671c89
+        this.nextButton.label = _("Next");
671c89
+        this.setChoiceList(promptMessage, choiceList);
671c89
+        this.updateSensitivity(true);
671c89
+        this.emit('prompted');
671c89
+    }
671c89
+
671c89
     _onOVirtUserAuthenticated() {
671c89
         if (this.verificationStatus != AuthPromptStatus.VERIFICATION_SUCCEEDED)
671c89
             this.reset();
671c89
@@ -386,6 +425,8 @@ var AuthPrompt = class {
671c89
     clear() {
671c89
         this._entry.text = '';
671c89
         this.stopSpinning();
671c89
+        this._authList.clear();
671c89
+        this._authList.actor.hide();
671c89
     }
671c89
 
671c89
     setPasswordChar(passwordChar) {
671c89
@@ -401,12 +442,42 @@ var AuthPrompt = class {
671c89
 
671c89
         this._label.set_text(question);
671c89
 
671c89
+        this._authList.actor.hide();
671c89
         this._label.show();
671c89
         this._entry.show();
671c89
 
671c89
         this._entry.grab_key_focus();
671c89
     }
671c89
 
671c89
+    _fadeInChoiceList() {
671c89
+       this._authList.actor.opacity = 0;
671c89
+       this._authList.actor.show();
671c89
+       this._authList.actor.reactive = false;
671c89
+       Tweener.addTween(this._authList.actor,
671c89
+                        { opacity: 255,
671c89
+                          time: MESSAGE_FADE_OUT_ANIMATION_TIME,
671c89
+                          transition: 'easeOutQuad',
671c89
+                          onComplete: () => {
671c89
+                              this._authList.actor.reactive = true;
671c89
+                          }
671c89
+                        });
671c89
+    }
671c89
+
671c89
+    setChoiceList(promptMessage, choiceList) {
671c89
+        this._authList.clear();
671c89
+        this._authList.label.text = promptMessage;
671c89
+        for (let key in choiceList) {
671c89
+            let text = choiceList[key];
671c89
+            this._authList.addItem(key, text);
671c89
+        }
671c89
+
671c89
+        this._label.hide();
671c89
+        this._entry.hide();
671c89
+        if (this._message.text == "")
671c89
+            this._message.hide();
671c89
+        this._fadeInChoiceList();
671c89
+    }
671c89
+
671c89
     getAnswer() {
671c89
         let text;
671c89
 
671c89
@@ -442,6 +513,7 @@ var AuthPrompt = class {
671c89
         else
671c89
             this._message.remove_style_class_name('login-dialog-message-hint');
671c89
 
671c89
+        this._message.show();
671c89
         if (message) {
671c89
             Tweener.removeTweens(this._message);
671c89
             this._message.text = message;
671c89
@@ -457,7 +529,7 @@ var AuthPrompt = class {
671c89
     }
671c89
 
671c89
     updateSensitivity(sensitive) {
671c89
-        this._updateNextButtonSensitivity(sensitive && (this._entry.text.length > 0 || this.verificationStatus == AuthPromptStatus.VERIFYING));
671c89
+        this._updateNextButtonSensitivity(sensitive && !this._authList.actor.visible && (this._entry.text.length > 0 || this.verificationStatus == AuthPromptStatus.VERIFYING));
671c89
         this._entry.reactive = sensitive;
671c89
         this._entry.clutter_text.editable = sensitive;
671c89
     }
671c89
diff --git a/js/gdm/loginDialog.js b/js/gdm/loginDialog.js
671c89
index 9aaa013d8..942f5a0e5 100644
671c89
--- a/js/gdm/loginDialog.js
671c89
+++ b/js/gdm/loginDialog.js
671c89
@@ -406,6 +406,11 @@ var LoginDialog = GObject.registerClass({
671c89
         this._userManager = AccountsService.UserManager.get_default()
671c89
         this._gdmClient = new Gdm.Client();
671c89
 
671c89
+        try {
671c89
+            this._gdmClient.set_enabled_extensions([Gdm.UserVerifierChoiceList.interface_info().name]);
671c89
+        } catch(e) {
671c89
+        }
671c89
+
671c89
         this._settings = new Gio.Settings({ schema_id: GdmUtil.LOGIN_SCREEN_SCHEMA });
671c89
 
671c89
         this._settings.connect('changed::' + GdmUtil.BANNER_MESSAGE_KEY,
671c89
diff --git a/js/gdm/util.js b/js/gdm/util.js
671c89
index 6e940d2ab..9e249139d 100644
671c89
--- a/js/gdm/util.js
671c89
+++ b/js/gdm/util.js
671c89
@@ -192,6 +192,10 @@ var ShellUserVerifier = class {
671c89
         if (this._userVerifier) {
671c89
             this._userVerifier.run_dispose();
671c89
             this._userVerifier = null;
671c89
+            if (this._userVerifierChoiceList) {
671c89
+                this._userVerifierChoiceList.run_dispose();
671c89
+                this._userVerifierChoiceList = null;
671c89
+            }
671c89
         }
671c89
     }
671c89
 
671c89
@@ -219,6 +223,10 @@ var ShellUserVerifier = class {
671c89
         this._oVirtCredentialsManager = null;
671c89
     }
671c89
 
671c89
+    selectChoice(serviceName, key) {
671c89
+        this._userVerifierChoiceList.call_select_choice(serviceName, key, this._cancellable, null);
671c89
+    }
671c89
+
671c89
     answerQuery(serviceName, answer) {
671c89
         if (!this.hasPendingMessages) {
671c89
             this._userVerifier.call_answer_query(serviceName, answer, this._cancellable, null);
671c89
@@ -362,6 +370,11 @@ var ShellUserVerifier = class {
671c89
             return;
671c89
         }
671c89
 
671c89
+        if (client.get_user_verifier_choice_list)
671c89
+            this._userVerifierChoiceList = client.get_user_verifier_choice_list();
671c89
+        else
671c89
+            this._userVerifierChoiceList = null;
671c89
+
671c89
         this.reauthenticating = true;
671c89
         this._connectSignals();
671c89
         this._beginVerification();
671c89
@@ -379,6 +392,11 @@ var ShellUserVerifier = class {
671c89
             return;
671c89
         }
671c89
 
671c89
+        if (client.get_user_verifier_choice_list)
671c89
+            this._userVerifierChoiceList = client.get_user_verifier_choice_list();
671c89
+        else
671c89
+            this._userVerifierChoiceList = null;
671c89
+
671c89
         this._connectSignals();
671c89
         this._beginVerification();
671c89
         this._hold.release();
671c89
@@ -392,6 +410,9 @@ var ShellUserVerifier = class {
671c89
         this._userVerifier.connect('conversation-stopped', this._onConversationStopped.bind(this));
671c89
         this._userVerifier.connect('reset', this._onReset.bind(this));
671c89
         this._userVerifier.connect('verification-complete', this._onVerificationComplete.bind(this));
671c89
+
671c89
+        if (this._userVerifierChoiceList)
671c89
+            this._userVerifierChoiceList.connect('choice-query', this._onChoiceListQuery.bind(this));
671c89
     }
671c89
 
671c89
     _getForegroundService() {
671c89
@@ -468,6 +489,13 @@ var ShellUserVerifier = class {
671c89
             this._startService(FINGERPRINT_SERVICE_NAME);
671c89
     }
671c89
 
671c89
+    _onChoiceListQuery(client, serviceName, promptMessage, list) {
671c89
+        if (!this.serviceIsForeground(serviceName))
671c89
+            return;
671c89
+
671c89
+        this.emit('show-choice-list', serviceName, promptMessage, list.deep_unpack());
671c89
+    }
671c89
+
671c89
     _onInfo(client, serviceName, info) {
671c89
         if (this.serviceIsForeground(serviceName)) {
671c89
             this._queueMessage(info, MessageType.INFO);
671c89
diff --git a/js/ui/unlockDialog.js b/js/ui/unlockDialog.js
671c89
index 5c9d46021..4b0470f4b 100644
671c89
--- a/js/ui/unlockDialog.js
671c89
+++ b/js/ui/unlockDialog.js
671c89
@@ -33,7 +33,14 @@ var UnlockDialog = class {
671c89
                                              y_expand: true });
671c89
         this.actor.add_child(this._promptBox);
671c89
 
671c89
-        this._authPrompt = new AuthPrompt.AuthPrompt(new Gdm.Client(), AuthPrompt.AuthPromptMode.UNLOCK_ONLY);
671c89
+        this._gdmClient = new Gdm.Client();
671c89
+
671c89
+        try {
671c89
+            this._gdmClient.set_enabled_extensions([Gdm.UserVerifierChoiceList.interface_info().name]);
671c89
+        } catch(e) {
671c89
+        }
671c89
+
671c89
+        this._authPrompt = new AuthPrompt.AuthPrompt(this._gdmClient, AuthPrompt.AuthPromptMode.UNLOCK_ONLY);
671c89
         this._authPrompt.connect('failed', this._fail.bind(this));
671c89
         this._authPrompt.connect('cancelled', this._fail.bind(this));
671c89
         this._authPrompt.connect('reset', this._onReset.bind(this));
671c89
-- 
671c89
2.21.0
671c89