GNOME Bugzilla – Bug 692937
Gnome shell prompt automatically completes
Last modified: 2020-11-15 07:10:51 UTC
So, Emacs has this nice feature which Tim Janik posted about on G+ here: https://plus.google.com/u/0/110781595661917803096/posts/SuWskgkJqRL I've been using it to store passwords - bit better than clear text obviously. :) It works fine for *opening* files, but not for *saving*. I have to unset GPG_AGENT_INFO before starting Emacs to use the Emacs built in save file with password/verify password functionality to make any changes. Quite easy to reproduce. 1. $ emacs foo.gpg 2. Write some content 3. Save the file 4. Enter password first time when prompted (by GNOME shell dialog) You should see an error in the Emacs window that it couldn't save the file. The Emacs messages window says: """ Saving file /home/martyn/foo.gpg... stdin: 0% (0/0) byte-code: Opening output file: Encrypt failed: ((exit)) """ -- What's expected to happen is, a second password request comes up to *verify* the password and then the file is saved if the passwords match.
Do you see a second prompt come up quickly and flicker away? You can try to reproduce this simply by doing: $ gpg --encrypt --symmetric
When testing today, even the first prompt didn't show properly. It flashes up and disappears before I can enter anything. This is all from Emacs. There is no way to specify the gpg command line AFAICS. If I try gpg --encrypt --symmetric foo.gpg or even without the foo.gpg, it does the exact same thing. The GNOME dialog flashes up once but doesn't give me a chance to insert any text. So it does look like the same behaviour using your command line there yes.
So this is due to gnome-shell prompts automatically completing. Here's what happens. The shell prompt listens to a key-release-event in order to complete its default action. If the user pressed <enter> as the last action before a prompt is displayed, then the key-release-event of that <enter> key press completes the shell prompt. In the case of emacs and gpg, two prompts are being displayed, an initial passphrase prompt and a confirmation prompt. The second one is catching the key-release-event of pressing enter on the first one. Pretty wild. You can see that if you're not pressing enter at the exact time a prompt is displayed (ie: use the mouse, or in the case of a shell command: sleep 1; my command), then everything works as expected. I thought there was another bug for this that I filed about polkit prompts doing the same thing... But I can't find it now, so let's use this one.
Created attachment 235954 [details] [review] modalDialog: Fix auto-completion of prompts immediately upon display Shell modal dialogs can take their action on a certain key's key-release-event. For example on <enter> the affirmative action is usually run. Make sure that the key was also pressed on the dialog and we're not seeing a spurious key-release-event from a key that was pressed before the dialog was displayed. This patch needs testing. Will do once jhbuild gets that far.
Tested. The patch fixes the problem for me.
Hi! I am using gnome-shell 3.6.3 and am also hit by this bug; would it be possible to have a similar patch for version 3.6.3 as well? That would be very much appreciated. Thanks!
Hi! I tired to rebase the above patch to version 3.6.3. Please let me know if this is the correct way to do this:- Index: gnome-shell-3.6.3/js/ui/modalDialog.js =================================================================== --- gnome-shell-3.6.3.orig/js/ui/modalDialog.js +++ gnome-shell-3.6.3/js/ui/modalDialog.js @@ -57,8 +57,10 @@ const ModalDialog = new Lang.Class({ this._group.connect('destroy', Lang.bind(this, this._onGroupDestroy)); - this._actionKeys = {}; - this._group.connect('key-release-event', Lang.bind(this, this._onKeyReleaseEvent)); + this._pressedKey = null; + this._actionKeys = {}; + this._group.connect('key-press-event', Lang.bind(this, this._onKeyPressEvent)); + this._group.connect('key-release-event', Lang.bind(this, this._onKeyReleaseEvent)); this._backgroundBin = new St.Bin(); this._monitorConstraint = new Layout.MonitorConstraint(); @@ -186,10 +188,19 @@ const ModalDialog = new Lang.Class({ }, + _onKeyPressEvent: function(object, event) { + this._pressedKey = event.get_key_symbol(); + }, + _onKeyReleaseEvent: function(object, event) { + let pressedKey = this._pressedKey; + this._pressedKey = null; + let symbol = event.get_key_symbol(); + if (symbol != pressedKey) + return false; + let action = this._actionKeys[symbol]; - if (action) { action(); return true;
Tested rebased patch on my system (with gnome-shell 3.6.3), seems to fix the problem.
Atri. Thanks for doing that. I didn't test the GNOME 3.6 patch, but it does indeed look right. I would suggest attaching the rebased patch with a proper commit message to this bug. There do seem to be several needless whitespace changes that would be easier to spot when attached.
Created attachment 237272 [details] [review] Rebased patch for version 3.6.3 Attached rebased patch for gnome-shell-3.6.3 for review. Thanks!
Hi Stef! Could you please review the rebased patch for 3.6.3 attached with comment 10 above? Thanks!
Review of attachment 235954 [details] [review]: I had a similar patch before finding you already did this. OK.
Attachment 235954 [details] pushed as 7b705dd - modalDialog: Fix auto-completion of prompts immediately upon display
Comment on attachment 237272 [details] [review] Rebased patch for version 3.6.3 Looks good. Although it's probably Jasper's call whether this goes in the gnome-3-6 branch.
It is unclear whether there will be another 3.6.x release, but assuming that the patch has been tested, I'm fine with it being pushed to the gnome-3-6 branch.
Pushed to gnome-3-6 branch. Have been running this with gnome-shell 3.6.3 and it does the trick.
(In reply to comment #16) > Pushed to gnome-3-6 branch. Have been running this with gnome-shell 3.6.3 > and it does the trick. Thanks, Stef, for the review and the push to gnome-3-6 branch.
this patch may be causing issues. see bug 695154
On Gnome 3.8.4 I frequently run into problems with the Gnome Shell password prompt. It repeatedly rejects my password, but then after a while it starts accepting it. It is very random and hard to pin down. Sometimes it rejects the first time and accepts it the second time. Sometimes on the third time. Occasionally it works on the first try. Sometimes it just keeps rejecting it. (Yes, I am typing my password correctly.) I usually open programs by searching applications menu and hitting enter, if that makes any difference.
Hello, I think I have this problem when trying to start gparted. But I am new to Linux and dont know how to apply that patch. I am using gnome-shell 3.6.3.1 ( I think ;) ) Can someone help?
*** Bug 690592 has been marked as a duplicate of this bug. ***