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

c7fac9
From 87e7f4ea023cac3b4573ea0c7012b77c588f35ae Mon Sep 17 00:00:00 2001
c7fac9
From: Ray Strode <rstrode@redhat.com>
c7fac9
Date: Mon, 17 Jul 2017 16:48:03 -0400
c7fac9
Subject: [PATCH 2/2] gdmUtil: enable support for GDM's ChoiceList PAM
c7fac9
 extension
c7fac9
c7fac9
This commit hooks up support for GDM's ChoiceList PAM extension.
c7fac9
---
c7fac9
 js/gdm/authPrompt.js  | 74 ++++++++++++++++++++++++++++++++++++++++++-
c7fac9
 js/gdm/loginDialog.js |  5 +++
c7fac9
 js/gdm/util.js        | 28 ++++++++++++++++
c7fac9
 js/ui/unlockDialog.js |  9 +++++-
c7fac9
 4 files changed, 114 insertions(+), 2 deletions(-)
c7fac9
c7fac9
diff --git a/js/gdm/authPrompt.js b/js/gdm/authPrompt.js
c7fac9
index e44281117..27a55246a 100644
c7fac9
--- a/js/gdm/authPrompt.js
c7fac9
+++ b/js/gdm/authPrompt.js
c7fac9
@@ -9,6 +9,7 @@ const Signals = imports.signals;
c7fac9
 const St = imports.gi.St;
c7fac9
 
c7fac9
 const Animation = imports.ui.animation;
c7fac9
+const AuthList = imports.gdm.authList;
c7fac9
 const Batch = imports.gdm.batch;
c7fac9
 const GdmUtil = imports.gdm.util;
c7fac9
 const Meta = imports.gi.Meta;
c7fac9
@@ -61,6 +62,7 @@ var AuthPrompt = new Lang.Class({
c7fac9
 
c7fac9
         this._userVerifier.connect('ask-question', this._onAskQuestion.bind(this));
c7fac9
         this._userVerifier.connect('show-message', this._onShowMessage.bind(this));
c7fac9
+        this._userVerifier.connect('show-choice-list', this._onShowChoiceList.bind(this));
c7fac9
         this._userVerifier.connect('verification-failed', this._onVerificationFailed.bind(this));
c7fac9
         this._userVerifier.connect('verification-complete', this._onVerificationComplete.bind(this));
c7fac9
         this._userVerifier.connect('reset', this._onReset.bind(this));
c7fac9
@@ -123,6 +125,28 @@ var AuthPrompt = new Lang.Class({
c7fac9
 
c7fac9
         this.actor.add(this._timedLoginIndicator);
c7fac9
 
c7fac9
+        this._authList = new AuthList.AuthList();
c7fac9
+        this._authList.connect('activate', (list, key) => {
c7fac9
+            this._authList.actor.reactive = false;
c7fac9
+            Tweener.addTween(this._authList.actor,
c7fac9
+                             { opacity: 0,
c7fac9
+                               time: MESSAGE_FADE_OUT_ANIMATION_TIME,
c7fac9
+                               transition: 'easeOutQuad',
c7fac9
+                               onComplete: () => {
c7fac9
+                                   this._authList.clear();
c7fac9
+                                   this._authList.actor.hide();
c7fac9
+                                   this._userVerifier.selectChoice(this._queryingService, key);
c7fac9
+
c7fac9
+                               }
c7fac9
+                             });
c7fac9
+        });
c7fac9
+        this._authList.actor.hide();
c7fac9
+        this.actor.add(this._authList.actor,
c7fac9
+                       { expand: true,
c7fac9
+                         x_fill: true,
c7fac9
+                         y_fill: false,
c7fac9
+                         x_align: St.Align.START });
c7fac9
+
c7fac9
         this._message = new St.Label({ opacity: 0,
c7fac9
                                        styleClass: 'login-dialog-message' });
c7fac9
         this._message.clutter_text.line_wrap = true;
c7fac9
@@ -266,6 +290,21 @@ var AuthPrompt = new Lang.Class({
c7fac9
         this.emit('prompted');
c7fac9
     },
c7fac9
 
c7fac9
+    _onShowChoiceList(userVerifier, serviceName, promptMessage, choiceList) {
c7fac9
+        if (this._queryingService)
c7fac9
+            this.clear();
c7fac9
+
c7fac9
+        this._queryingService = serviceName;
c7fac9
+
c7fac9
+        if (this._preemptiveAnswer)
c7fac9
+            this._preemptiveAnswer = null;
c7fac9
+
c7fac9
+        this.nextButton.label = _("Next");
c7fac9
+        this.setChoiceList(promptMessage, choiceList);
c7fac9
+        this.updateSensitivity(true);
c7fac9
+        this.emit('prompted');
c7fac9
+    },
c7fac9
+
c7fac9
     _onOVirtUserAuthenticated() {
c7fac9
         if (this.verificationStatus != AuthPromptStatus.VERIFICATION_SUCCEEDED)
c7fac9
             this.reset();
c7fac9
@@ -394,6 +433,8 @@ var AuthPrompt = new Lang.Class({
c7fac9
     clear() {
c7fac9
         this._entry.text = '';
c7fac9
         this.stopSpinning();
c7fac9
+        this._authList.clear();
c7fac9
+        this._authList.actor.hide();
c7fac9
     },
c7fac9
 
c7fac9
     setPasswordChar(passwordChar) {
c7fac9
@@ -409,12 +450,42 @@ var AuthPrompt = new Lang.Class({
c7fac9
 
c7fac9
         this._label.set_text(question);
c7fac9
 
c7fac9
+        this._authList.actor.hide();
c7fac9
         this._label.show();
c7fac9
         this._entry.show();
c7fac9
 
c7fac9
         this._entry.grab_key_focus();
c7fac9
     },
c7fac9
 
c7fac9
+    _fadeInChoiceList() {
c7fac9
+       this._authList.actor.opacity = 0;
c7fac9
+       this._authList.actor.show();
c7fac9
+       this._authList.actor.reactive = false;
c7fac9
+       Tweener.addTween(this._authList.actor,
c7fac9
+                        { opacity: 255,
c7fac9
+                          time: MESSAGE_FADE_OUT_ANIMATION_TIME,
c7fac9
+                          transition: 'easeOutQuad',
c7fac9
+                          onComplete: () => {
c7fac9
+                              this._authList.actor.reactive = true;
c7fac9
+                          }
c7fac9
+                        });
c7fac9
+    },
c7fac9
+
c7fac9
+    setChoiceList(promptMessage, choiceList) {
c7fac9
+        this._authList.clear();
c7fac9
+        this._authList.label.text = promptMessage;
c7fac9
+        for (let key in choiceList) {
c7fac9
+            let text = choiceList[key];
c7fac9
+            this._authList.addItem(key, text);
c7fac9
+        }
c7fac9
+
c7fac9
+        this._label.hide();
c7fac9
+        this._entry.hide();
c7fac9
+        if (this._message.text == "")
c7fac9
+            this._message.hide();
c7fac9
+        this._fadeInChoiceList();
c7fac9
+    },
c7fac9
+
c7fac9
     getAnswer() {
c7fac9
         let text;
c7fac9
 
c7fac9
@@ -450,6 +521,7 @@ var AuthPrompt = new Lang.Class({
c7fac9
         else
c7fac9
             this._message.remove_style_class_name('login-dialog-message-hint');
c7fac9
 
c7fac9
+        this._message.show();
c7fac9
         if (message) {
c7fac9
             Tweener.removeTweens(this._message);
c7fac9
             this._message.text = message;
c7fac9
@@ -465,7 +537,7 @@ var AuthPrompt = new Lang.Class({
c7fac9
     },
c7fac9
 
c7fac9
     updateSensitivity(sensitive) {
c7fac9
-        this._updateNextButtonSensitivity(sensitive && (this._entry.text.length > 0 || this.verificationStatus == AuthPromptStatus.VERIFYING));
c7fac9
+        this._updateNextButtonSensitivity(sensitive && !this._authList.actor.visible && (this._entry.text.length > 0 || this.verificationStatus == AuthPromptStatus.VERIFYING));
c7fac9
         this._entry.reactive = sensitive;
c7fac9
         this._entry.clutter_text.editable = sensitive;
c7fac9
     },
c7fac9
diff --git a/js/gdm/loginDialog.js b/js/gdm/loginDialog.js
c7fac9
index 65d9edf1a..912c0e0ca 100644
c7fac9
--- a/js/gdm/loginDialog.js
c7fac9
+++ b/js/gdm/loginDialog.js
c7fac9
@@ -418,6 +418,11 @@ var LoginDialog = new Lang.Class({
c7fac9
         this._userManager = AccountsService.UserManager.get_default()
c7fac9
         this._gdmClient = new Gdm.Client();
c7fac9
 
c7fac9
+        try {
c7fac9
+            this._gdmClient.set_enabled_extensions([Gdm.UserVerifierChoiceList.interface_info().name]);
c7fac9
+        } catch(e) {
c7fac9
+        }
c7fac9
+
c7fac9
         this._settings = new Gio.Settings({ schema_id: GdmUtil.LOGIN_SCREEN_SCHEMA });
c7fac9
 
c7fac9
         this._settings.connect('changed::' + GdmUtil.BANNER_MESSAGE_KEY,
c7fac9
diff --git a/js/gdm/util.js b/js/gdm/util.js
c7fac9
index f5f9d5e5d..04a0cb9bf 100644
c7fac9
--- a/js/gdm/util.js
c7fac9
+++ b/js/gdm/util.js
c7fac9
@@ -200,6 +200,10 @@ var ShellUserVerifier = new Lang.Class({
c7fac9
         if (this._userVerifier) {
c7fac9
             this._userVerifier.run_dispose();
c7fac9
             this._userVerifier = null;
c7fac9
+            if (this._userVerifierChoiceList) {
c7fac9
+                this._userVerifierChoiceList.run_dispose();
c7fac9
+                this._userVerifierChoiceList = null;
c7fac9
+            }
c7fac9
         }
c7fac9
     },
c7fac9
 
c7fac9
@@ -227,6 +231,10 @@ var ShellUserVerifier = new Lang.Class({
c7fac9
         this._oVirtCredentialsManager = null;
c7fac9
     },
c7fac9
 
c7fac9
+    selectChoice(serviceName, key) {
c7fac9
+        this._userVerifierChoiceList.call_select_choice(serviceName, key, this._cancellable, null);
c7fac9
+    },
c7fac9
+
c7fac9
     answerQuery(serviceName, answer) {
c7fac9
         if (!this.hasPendingMessages) {
c7fac9
             this._userVerifier.call_answer_query(serviceName, answer, this._cancellable, null);
c7fac9
@@ -367,6 +375,11 @@ var ShellUserVerifier = new Lang.Class({
c7fac9
             return;
c7fac9
         }
c7fac9
 
c7fac9
+        if (client.get_user_verifier_choice_list)
c7fac9
+            this._userVerifierChoiceList = client.get_user_verifier_choice_list();
c7fac9
+        else
c7fac9
+            this._userVerifierChoiceList = null;
c7fac9
+
c7fac9
         this.reauthenticating = true;
c7fac9
         this._connectSignals();
c7fac9
         this._beginVerification();
c7fac9
@@ -384,6 +397,11 @@ var ShellUserVerifier = new Lang.Class({
c7fac9
             return;
c7fac9
         }
c7fac9
 
c7fac9
+        if (client.get_user_verifier_choice_list)
c7fac9
+            this._userVerifierChoiceList = client.get_user_verifier_choice_list();
c7fac9
+        else
c7fac9
+            this._userVerifierChoiceList = null;
c7fac9
+
c7fac9
         this._connectSignals();
c7fac9
         this._beginVerification();
c7fac9
         this._hold.release();
c7fac9
@@ -397,6 +415,9 @@ var ShellUserVerifier = new Lang.Class({
c7fac9
         this._userVerifier.connect('conversation-stopped', this._onConversationStopped.bind(this));
c7fac9
         this._userVerifier.connect('reset', this._onReset.bind(this));
c7fac9
         this._userVerifier.connect('verification-complete', this._onVerificationComplete.bind(this));
c7fac9
+
c7fac9
+        if (this._userVerifierChoiceList)
c7fac9
+            this._userVerifierChoiceList.connect('choice-query', this._onChoiceListQuery.bind(this));
c7fac9
     },
c7fac9
 
c7fac9
     _getForegroundService() {
c7fac9
@@ -473,6 +494,13 @@ var ShellUserVerifier = new Lang.Class({
c7fac9
             this._startService(FINGERPRINT_SERVICE_NAME);
c7fac9
     },
c7fac9
 
c7fac9
+    _onChoiceListQuery(client, serviceName, promptMessage, list) {
c7fac9
+        if (!this.serviceIsForeground(serviceName))
c7fac9
+            return;
c7fac9
+
c7fac9
+        this.emit('show-choice-list', serviceName, promptMessage, list.deep_unpack());
c7fac9
+    },
c7fac9
+
c7fac9
     _onInfo(client, serviceName, info) {
c7fac9
         if (this.serviceIsForeground(serviceName)) {
c7fac9
             this._queueMessage(info, MessageType.INFO);
c7fac9
diff --git a/js/ui/unlockDialog.js b/js/ui/unlockDialog.js
c7fac9
index 1adaf417e..b5272be20 100644
c7fac9
--- a/js/ui/unlockDialog.js
c7fac9
+++ b/js/ui/unlockDialog.js
c7fac9
@@ -51,7 +51,14 @@ var UnlockDialog = new Lang.Class({
c7fac9
                                              y_expand: true });
c7fac9
         this.actor.add_child(this._promptBox);
c7fac9
 
c7fac9
-        this._authPrompt = new AuthPrompt.AuthPrompt(new Gdm.Client(), AuthPrompt.AuthPromptMode.UNLOCK_ONLY);
c7fac9
+        this._gdmClient = new Gdm.Client();
c7fac9
+
c7fac9
+        try {
c7fac9
+            this._gdmClient.set_enabled_extensions([Gdm.UserVerifierChoiceList.interface_info().name]);
c7fac9
+        } catch(e) {
c7fac9
+        }
c7fac9
+
c7fac9
+        this._authPrompt = new AuthPrompt.AuthPrompt(this._gdmClient, AuthPrompt.AuthPromptMode.UNLOCK_ONLY);
c7fac9
         this._authPrompt.connect('failed', this._fail.bind(this));
c7fac9
         this._authPrompt.connect('cancelled', this._fail.bind(this));
c7fac9
         this._authPrompt.connect('reset', this._onReset.bind(this));
c7fac9
-- 
c7fac9
2.20.1
c7fac9