Page MenuHome GnuPG

pinentry Emacs support assumes socket location at ${TMPDIR}/emacs${UID}, fails to connect (need to respect XDG_RUNTIME_DIR)
Open, NormalPublic

Description

On my system, with Emacs 29.0.50 (but this applies
to earlier versions too - see https://bugs.gentoo.org/794649),
Emacs respects XDG_RUNTIME_DIR, so my socket
is at /run/user/1000/emacs/server.

There's a relevant upstream report at https://debbugs.gnu.org/33847.

Per comment in pinentry-emacs.c:

- We only use a Unix domain socket, while emacsclient has an
  ability to use a TCP socket.  The socket file is located at
  ${TMPDIR-/tmp}/emacs$(id -u)/pinentry (i.e., under the same
  directory as the socket file used by emacsclient, so the same
  permission and file owner settings apply).

pinentry indeed tries to access that path and gives up if it fails:

$ pinentry-emacs
stat: No such file or directory
$ strace pinentry-emacs
[...]
getuid()                                = 1000
geteuid()                               = 1000
getuid()                                = 1000
newfstatat(AT_FDCWD, "/tmp/emacs1000/pinentry", 0x7ffd344d2e50, 0) = -1 ENOENT (No such file or directory)
dup(2)                                  = 3
fcntl(3, F_GETFL)                       = 0x8002 (flags O_RDWR|O_LARGEFILE)
newfstatat(3, "", {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0x1d), ...}, AT_EMPTY_PATH) = 0
write(3, "stat: No such file or directory\n", 32stat: No such file or directory
) = 32
close(3)                                = 0
munmap(0x7f0f2a999000, 16384)           = 0
exit_group(1)                           = ?
+++ exited with 1 +++

Details

Revisions and Commits

Event Timeline

thesamesam set External Link to https://bugs.gentoo.org/794649).
thesamesam changed External Link from https://bugs.gentoo.org/794649) to https://bugs.gentoo.org/794649.
thesamesam changed External Link from https://bugs.gentoo.org/794649 to https://debbugs.gnu.org/33847.
thesamesam updated the task description. (Show Details)
werner triaged this task as Normal priority.Aug 25 2022, 9:16 AM
werner edited projects, added Feature Request; removed Bug Report.
werner added a subscriber: werner.

Let's turn this into a feature request.

Frankly, I see no reason why one should use the Emacs Pinentry hack given that one is already running on a GUI system (as per XDG stuff). BTW, I do everything with Emacs and xterms.

pinentry-emacs is obsolete. It's for older Emacs (<= 25, IIUC) which had lisp/pinentry.el.
For Emacs 26 and newer, you can simply use epa-pinentry-mode having the value of loopback.