Blame SOURCES/0004-shellEntry-Support-lockdown-of-Show-Text-menu-in-pas.patch

a3db19
From ee64cd773bdeef845d02dc84063f926d77090dec Mon Sep 17 00:00:00 2001
a3db19
From: Ray Strode <rstrode@redhat.com>
a3db19
Date: Wed, 21 Aug 2019 15:06:46 -0400
a3db19
Subject: [PATCH 4/4] shellEntry: Support lockdown of "Show Text" menu in
a3db19
 password entries
a3db19
a3db19
Some deployments require being able to prevent users from showing
a3db19
the password they're currently typing.
a3db19
a3db19
This commit adds support for that kind of lockdown.
a3db19
a3db19
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/687
a3db19
---
a3db19
 js/ui/shellEntry.js | 14 +++++++++++---
a3db19
 1 file changed, 11 insertions(+), 3 deletions(-)
a3db19
a3db19
diff --git a/js/ui/shellEntry.js b/js/ui/shellEntry.js
a3db19
index 765cede06..c45e4545a 100644
a3db19
--- a/js/ui/shellEntry.js
a3db19
+++ b/js/ui/shellEntry.js
a3db19
@@ -1,81 +1,89 @@
a3db19
 // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
a3db19
 
a3db19
-const { Clutter, GObject, Pango, Shell, St } = imports.gi;
a3db19
+const { Clutter, Gio, GObject, Pango, Shell, St } = imports.gi;
a3db19
 
a3db19
 const BoxPointer = imports.ui.boxpointer;
a3db19
 const Main = imports.ui.main;
a3db19
 const Params = imports.misc.params;
a3db19
 const PopupMenu = imports.ui.popupMenu;
a3db19
 const Tweener = imports.ui.tweener;
a3db19
 
a3db19
+const LOCKDOWN_SCHEMA = 'org.gnome.desktop.lockdown';
a3db19
+const DISABLE_SHOW_PASSWORD_KEY = 'disable-show-password';
a3db19
+
a3db19
 var EntryMenu = class extends PopupMenu.PopupMenu {
a3db19
     constructor(entry) {
a3db19
         super(entry, 0, St.Side.TOP);
a3db19
 
a3db19
+        this._lockdownSettings = new Gio.Settings({ schema_id: LOCKDOWN_SCHEMA });
a3db19
+        this._lockdownSettings.connect('changed::' + DISABLE_SHOW_PASSWORD_KEY, this._resetPasswordItem.bind(this));
a3db19
+
a3db19
         this._entry = entry;
a3db19
         this._clipboard = St.Clipboard.get_default();
a3db19
 
a3db19
         // Populate menu
a3db19
         let item;
a3db19
         item = new PopupMenu.PopupMenuItem(_("Copy"));
a3db19
         item.connect('activate', this._onCopyActivated.bind(this));
a3db19
         this.addMenuItem(item);
a3db19
         this._copyItem = item;
a3db19
 
a3db19
         item = new PopupMenu.PopupMenuItem(_("Paste"));
a3db19
         item.connect('activate', this._onPasteActivated.bind(this));
a3db19
         this.addMenuItem(item);
a3db19
         this._pasteItem = item;
a3db19
 
a3db19
         this._passwordItem = null;
a3db19
 
a3db19
         Main.uiGroup.add_actor(this.actor);
a3db19
         this.actor.hide();
a3db19
     }
a3db19
 
a3db19
     _makePasswordItem() {
a3db19
         let item = new PopupMenu.PopupMenuItem('');
a3db19
         item.connect('activate', this._onPasswordActivated.bind(this));
a3db19
         this.addMenuItem(item);
a3db19
         this._passwordItem = item;
a3db19
         this._updatePasswordItem();
a3db19
     }
a3db19
 
a3db19
     _resetPasswordItem() {
a3db19
-        if (!this.isPassword) {
a3db19
+        let passwordDisabled = this._lockdownSettings.get_boolean(DISABLE_SHOW_PASSWORD_KEY);
a3db19
+
a3db19
+        if (!this.isPassword || passwordDisabled) {
a3db19
             if (this._passwordItem) {
a3db19
                 this._passwordItem.destroy();
a3db19
                 this._passwordItem = null;
a3db19
             }
a3db19
             this._entry.clutter_text.set_password_char('\u25cf');
a3db19
-        } else {
a3db19
+        } else if (this.isPassword && !passwordDisabled) {
a3db19
             if (!this._passwordItem)
a3db19
                 this._makePasswordItem();
a3db19
         }
a3db19
     }
a3db19
 
a3db19
     get isPassword() {
a3db19
         return this._entry.input_purpose == Clutter.InputContentPurpose.PASSWORD;
a3db19
     }
a3db19
 
a3db19
     set isPassword(v) {
a3db19
         if (v == this.isPassword)
a3db19
             return;
a3db19
 
a3db19
         if (v)
a3db19
             this._entry.input_purpose = Clutter.InputContentPurpose.PASSWORD;
a3db19
         else
a3db19
             this._entry.input_purpose = Clutter.InputContentPurpose.NORMAL;
a3db19
 
a3db19
         this._resetPasswordItem();
a3db19
     }
a3db19
 
a3db19
     open(animate) {
a3db19
         this._updatePasteItem();
a3db19
         this._updateCopyItem();
a3db19
         if (this._passwordItem)
a3db19
             this._updatePasswordItem();
a3db19
 
a3db19
         super.open(animate);
a3db19
         this._entry.add_style_pseudo_class('focus');
a3db19
 
a3db19
-- 
a3db19
2.27.0
a3db19