GNU bug report logs - #67937
30.0.50; auth-source-pass relies on epa-file being enabled

Previous Next

Package: emacs;

Reported by: Arsen Arsenović <arsen <at> aarsen.me>

Date: Wed, 20 Dec 2023 17:02:02 UTC

Severity: normal

Found in version 30.0.50

Full log


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

From: Arsen Arsenović <arsen <at> aarsen.me>
To: Michael Albinus <michael.albinus <at> gmx.de>
Cc: damien <at> cassou.me, Eli Zaretskii <eliz <at> gnu.org>, 67937 <at> debbugs.gnu.org,
 jp <at> neverwas.me
Subject: Re: bug#67937: 30.0.50; auth-source-pass relies on epa-file being
 enabled
Date: Fri, 29 Dec 2023 09:27:59 +0100
[Message part 1 (text/plain, inline)]
Hi Michael,

Michael Albinus <michael.albinus <at> gmx.de> writes:

> Arsen Arsenović <arsen <at> aarsen.me> writes:
>
>> Hi Michael,
>
>>> No, auth-source-pass should not enable it on its own I believe. It
>>> should fire an error, which hopefully produces a backtrace. This
>>> backtrace would help us to understand, what's up.
>>
>> I doubt that it would produce a useful backtrace, because I doubt a
>> well-behaved let-binding is causing an error (as I said, when I notice
>> this bug, epa-file stops working everywhere, even long after a potential
>> let-binding would've been unbound, implying that it gets unset via some
>> other means).
>
> But we shall try it.

So I did.  With the diff below, I ran into an issue: the error emitted
in it is caught.

I believe that the check utilized below is correct for the
check-and-error solution.

--8<---------------cut here---------------start------------->8---
diff --git a/lisp/auth-source-pass.el b/lisp/auth-source-pass.el
index 0f51755a250..4da15a65259 100644
--- a/lisp/auth-source-pass.el
+++ b/lisp/auth-source-pass.el
@@ -195,10 +195,13 @@ auth-source-pass--get-attr
 (defun auth-source-pass--read-entry (entry)
   "Return a string with the file content of ENTRY."
   (with-temp-buffer
-    (insert-file-contents (expand-file-name
-                           (format "%s.gpg" entry)
-                           auth-source-pass-filename))
-    (buffer-substring-no-properties (point-min) (point-max))))
+    (let ((fname (format "%s.gpg" entry)))
+      (if (not (find-file-name-handler fname 'insert-file-contents))
+          (error "auth-source-pass requires a handler for .gpg files"))
+      (insert-file-contents (expand-file-name
+                             fname
+                             auth-source-pass-filename))
+      (buffer-substring-no-properties (point-min) (point-max)))))

 (defun auth-source-pass-parse-entry (entry)
   "Return an alist of the data associated with ENTRY.
--8<---------------cut here---------------end--------------->8---

>> Nonetheless, it is worth a shot.  I will inject a check into my
>> currently running Emacs and see what happens.
>>
>> I think erroring is an acceptable solution, though (but I do not think
>> the same of returning nil).
>
> Would be OK for me. Please add a hint to the error, that the user shall
> contact the Emacs department about. In case your patch arrives the repository.
>
>> I'm also not sure how complex the heuristic for emitting this error
>> would be.  (memq epa-file-handler file-name-handler-alist) is not
>> adequate as non-EPA handlers for PGP files could be active and/or
>> preferred.
>
> Well, it could be a starter. As you said, you have observed
> file-name-handler-alist being nil, so this test would be good enough for now.
>
> We have also (find-file-name-handler FILENAME 'insert-file-contents)
> But the interpretation of the result is a little bit more tricky.
>
>> I'm willing to implement a solution if you know a better heuristic.
>
> Let's start with what we have. Thanks!
>
>> Thanks, have a lovely day.
>>
>> Arsen Arsenović
>
> Best regards, Michael.


--
Arsen Arsenović
[signature.asc (application/pgp-signature, inline)]

This bug report was last modified 206 days ago.

Previous Next


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