GNU bug report logs - #6568
23.2; easypg opens blank buffer when password is incorrect

Previous Next

Package: emacs;

Reported by: Leo <sdl.web <at> gmail.com>

Date: Mon, 5 Jul 2010 16:01:02 UTC

Severity: normal

Merged with 8792

Found in versions 23.2, 23.3

Fixed in version 24.1

Done: Daiki Ueno <ueno <at> unixuser.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 6568 in the body.
You can then email your comments to 6568 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6568; Package emacs. (Mon, 05 Jul 2010 16:01:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Leo <sdl.web <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 05 Jul 2010 16:01:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Leo <sdl.web <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Cc: Daiki Ueno <ueno <at> unixuser.org>
Subject: 23.2; easypg opens blank buffer when password is incorrect
Date: Mon, 05 Jul 2010 17:00:17 +0100
Assume you have an encrypted file test.gpg and try to open it in emacs.
At the password prompt, type in an incorrect one. A blank buffer is
still opened.

The tricky thing is if you save back the contents in that buffer
(because accidentally you think you have typed in a correct password),
the original content will be gone.

It seems better for easypg not to open a blank buffer when password is
incorrect.

Leo




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6568; Package emacs. (Tue, 06 Jul 2010 08:45:03 GMT) Full text and rfc822 format available.

Message #8 received at 6568 <at> debbugs.gnu.org (full text, mbox):

From: Daiki Ueno <ueno <at> unixuser.org>
To: Leo <sdl.web <at> gmail.com>
Cc: 6568 <at> debbugs.gnu.org
Subject: Re: bug#6568: 23.2;
	easypg opens blank buffer when password is incorrect
Date: Tue, 06 Jul 2010 17:47:02 +0900
[Message part 1 (text/plain, inline)]
Leo <sdl.web <at> gmail.com> writes:

> Assume you have an encrypted file test.gpg and try to open it in emacs.
> At the password prompt, type in an incorrect one. A blank buffer is
> still opened.
>
> The tricky thing is if you save back the contents in that buffer
> (because accidentally you think you have typed in a correct password),
> the original content will be gone.
>
> It seems better for easypg not to open a blank buffer when password is
> incorrect.

Basically agree.  I have worndered for a long time how to implement
this, because error handling in find-file is too complex to control.

One idea is to re-throw the error in find-file-not-found-functions
(patch attached).  I'm not sure if this approach is palatable as other
basic Emacs commands.  Anyway, testing would be much appreciated.

[epa-file-no-select-empty.diff (text/x-patch, inline)]
=== modified file 'lisp/epa-file.el'
--- lisp/epa-file.el	2010-01-13 08:35:10 +0000
+++ lisp/epa-file.el	2010-07-06 08:36:24 +0000
@@ -101,6 +101,14 @@
     (insert (epa-file--decode-coding-string string (or coding-system-for-read
 						       'undecided)))))
 
+(defvar epa-file-error nil)
+(defun epa-file--find-file-not-found-function ()
+  (save-window-excursion
+    (let ((error (copy-sequence epa-file-error)))
+      (ignore (kill-buffer))
+      (signal 'file-error
+	      (cons "Opening input file" (cdr error))))))
+
 (defvar last-coding-system-used)
 (defun epa-file-insert-file-contents (file &optional visit beg end replace)
   (barf-if-buffer-read-only)
@@ -126,11 +134,16 @@
 	(progn
 	  (if replace
 	      (goto-char (point-min)))
+	  (add-hook 'find-file-not-found-functions
+		    'epa-file--find-file-not-found-function
+		    nil t)
 	  (condition-case error
 	      (setq string (epg-decrypt-file context local-file nil))
 	    (error
 	     (if (setq entry (assoc file epa-file-passphrase-alist))
 		 (setcdr entry nil))
+	     (make-local-variable 'epa-file-error)
+	     (setq epa-file-error error)
 	     (signal 'file-error
 		     (cons "Opening input file" (cdr error)))))
 	  (make-local-variable 'epa-file-encrypt-to)

[Message part 3 (text/plain, inline)]
Regards,
-- 
Daiki Ueno

Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6568; Package emacs. (Tue, 06 Jul 2010 09:22:02 GMT) Full text and rfc822 format available.

Message #11 received at 6568 <at> debbugs.gnu.org (full text, mbox):

From: Leo <sdl.web <at> gmail.com>
To: Daiki Ueno <ueno <at> unixuser.org>
Cc: 6568 <at> debbugs.gnu.org
Subject: Re: bug#6568: 23.2;
	easypg opens blank buffer when password is incorrect
Date: Tue, 06 Jul 2010 10:21:04 +0100
On 2010-07-06 09:47 +0100, Daiki Ueno wrote:
> Basically agree.  I have worndered for a long time how to implement
> this, because error handling in find-file is too complex to control.
>
> One idea is to re-throw the error in find-file-not-found-functions
> (patch attached).  I'm not sure if this approach is palatable as other
> basic Emacs commands.  Anyway, testing would be much appreciated.
>
> === modified file 'lisp/epa-file.el'
> --- lisp/epa-file.el	2010-01-13 08:35:10 +0000
> +++ lisp/epa-file.el	2010-07-06 08:36:24 +0000
[patch omitted]

Thank you for your prompt action on the bug. Much appreciated.

I have just tested the patch with emacs 23.2 and as far as I can see the
blank buffer is still opened with incorrect passwords or typing C-g at
the password prompt.

Is it plausible to just signal a 'password-error?

BTW, both the magic file and find file functions seem overly complex to
me.

Leo




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6568; Package emacs. (Wed, 07 Jul 2010 09:18:01 GMT) Full text and rfc822 format available.

Message #14 received at 6568 <at> debbugs.gnu.org (full text, mbox):

From: Daiki Ueno <ueno <at> unixuser.org>
To: Leo <sdl.web <at> gmail.com>
Cc: 6568 <at> debbugs.gnu.org
Subject: Re: bug#6568: 23.2;
	easypg opens blank buffer when password is incorrect
Date: Wed, 07 Jul 2010 18:20:28 +0900
Leo <sdl.web <at> gmail.com> writes:

> On 2010-07-06 09:47 +0100, Daiki Ueno wrote:
> I have just tested the patch with emacs 23.2 and as far as I can see the
> blank buffer is still opened with incorrect passwords or typing C-g at
> the password prompt.

Hmm, using the same version and having epa-file.el manually eval'ed, it
works for me.

> Is it plausible to just signal a 'password-error?

No - because epa-file-insert-file-contents may be called not only from
find-file but also from functions which expect file-error rather than
password-error.

Regards,
-- 
Daiki Ueno




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6568; Package emacs. (Wed, 07 Jul 2010 09:54:02 GMT) Full text and rfc822 format available.

Message #17 received at 6568 <at> debbugs.gnu.org (full text, mbox):

From: Leo <sdl.web <at> gmail.com>
To: Daiki Ueno <ueno <at> unixuser.org>
Cc: 6568 <at> debbugs.gnu.org
Subject: Re: bug#6568: 23.2;
	easypg opens blank buffer when password is incorrect
Date: Wed, 07 Jul 2010 10:53:50 +0100
On 2010-07-07 10:20 +0100, Daiki Ueno wrote:
> Leo <sdl.web <at> gmail.com> writes:
>
>> On 2010-07-06 09:47 +0100, Daiki Ueno wrote:
>> I have just tested the patch with emacs 23.2 and as far as I can see the
>> blank buffer is still opened with incorrect passwords or typing C-g at
>> the password prompt.
>
> Hmm, using the same version and having epa-file.el manually eval'ed, it
> works for me.

The patch seems to work beautifully. Thanks.

What I did last time was 'emacs -q -L EMACS_SRC/lisp' but I might have
compiled the wrong elisp file. Sorry about this.

>> Is it plausible to just signal a 'password-error?
>
> No - because epa-file-insert-file-contents may be called not only from
> find-file but also from functions which expect file-error rather than
> password-error.
>
> Regards,

Regards,

Leo




Reply sent to Daiki Ueno <ueno <at> unixuser.org>:
You have taken responsibility. (Thu, 08 Jul 2010 01:18:01 GMT) Full text and rfc822 format available.

Notification sent to Leo <sdl.web <at> gmail.com>:
bug acknowledged by developer. (Thu, 08 Jul 2010 01:18:01 GMT) Full text and rfc822 format available.

Message #22 received at 6568-close <at> debbugs.gnu.org (full text, mbox):

From: Daiki Ueno <ueno <at> unixuser.org>
To: Chong Yidong <cyd <at> stupidchicken.com>
Cc: 6568-close <at> debbugs.gnu.org
Subject: Re: bug#6568: 23.2;
	easypg opens blank buffer when password is incorrect
Date: Thu, 08 Jul 2010 10:20:05 +0900
Chong Yidong <cyd <at> stupidchicken.com> writes:

> Looks fine to me.  Please go ahead and check in when you're ready,
> thanks.

Done as r100747.  Thanks,
-- 
Daiki Ueno




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 05 Aug 2010 11:24:03 GMT) Full text and rfc822 format available.

bug unarchived. Request was from Daiki Ueno <ueno <at> unixuser.org> to control <at> debbugs.gnu.org. (Fri, 03 Jun 2011 04:23:01 GMT) Full text and rfc822 format available.

Forcibly Merged 6568 8792. Request was from Daiki Ueno <ueno <at> unixuser.org> to control <at> debbugs.gnu.org. (Fri, 03 Jun 2011 04:23:02 GMT) Full text and rfc822 format available.

bug Marked as fixed in versions 24.1. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Sat, 04 Jun 2011 19:15:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 03 Jul 2011 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 13 years and 359 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.