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 +++