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

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