aboutsummaryrefslogtreecommitdiff
Make GnuPG automatically find a pinentry installed by Guix. Try using
$HOME or, if that variable is not set, use the system password database,
or fall back to looking in "/".

More information:

https://bugs.gnu.org/24076

diff --git a/common/homedir.c b/common/homedir.c
index 4b6e46e88..f7ae68ba5 100644
--- a/common/homedir.c
+++ b/common/homedir.c
@@ -33,6 +33,7 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <unistd.h>
+#include <pwd.h>
 
 #ifdef HAVE_W32_SYSTEM
 #include <winsock2.h>   /* Due to the stupid mingw64 requirement to
@@ -67,6 +68,10 @@
  * gnupg_homedir and gnupg_set_homedir.  Malloced.  */
 static char *the_gnupg_homedir;
 
+/* The user's home directory. Used in Guix to help GnuPG find the
+ * pinentry. */
+static char *the_user_homedir;
+
 /* Flag indicating that home directory is not the default one.  */
 static byte non_default_homedir;
 
@@ -509,6 +514,25 @@ gnupg_homedir (void)
   return the_gnupg_homedir;
 }
 
+/* Return the user's home directory */
+const char *
+user_homedir (void)
+{
+  const char *dir;
+  dir = getenv("HOME");
+  if (dir == NULL)
+    {
+       struct passwd *pw = NULL;
+       pw = getpwuid (getuid ());
+       if (pw != NULL)
+         dir = pw->pw_dir;
+       else
+         dir = "/";
+    }
+  if (!the_user_homedir)
+    the_user_homedir = make_absfilename (dir, NULL);
+  return the_user_homedir;
+}
 
 /* Return whether the home dir is the default one.  */
 int
@@ -971,6 +995,7 @@ get_default_pinentry_name (int reset)
   } names[] = {
     /* The first entry is what we return in case we found no
        other pinentry.  */
+    { user_homedir, "/.guix-profile/bin/pinentry" },
     { gnupg_bindir, DIRSEP_S "pinentry" EXEEXT_S },
 #ifdef HAVE_W32_SYSTEM
     /* Try Gpg4win directory (with bin and without.) */
ers to could be unclear at first. * doc/guix.texi (Running Guix in a VM): Use the original image file name instead of /tmp/qemu-image. * po/doc/guix-manual.de.po, po/doc/guix-manual.es.po, po/doc/guix-manual.fr.po, po/doc/guix-manual.pt_BR.po, po/doc/guix-manual.ru.po, po/doc/guix-manual.zh_CN.po: Adjust accordingly. Ludovic Courtès 2022-12-04nls: Update translations....po/packages/vi.po: New file. po/packages/LINGUAS: Add it. Julien Lepiller 2022-11-04nls: Update translations....* po/guix/lt.po: New file. * po/guix/LINGUAS: Add lt. Julien Lepiller 2022-10-08po: Fix syntax error in French translation....* po/doc/guix-manual.fr.po: Add missing space. Ricardo Wurmus 2022-10-08po: Fix syntax error in German translation....* po/doc/guix-manual.de.po: Remove double wrapping of @uref. Ricardo Wurmus 2022-10-06nls: Update translations.Julien Lepiller 2022-09-04nls: Update translations.Julien Lepiller 2022-08-10nls: Update translations....po/guix/bn.po: New file. po/guix/LINGUAS: Add it. Julien Lepiller 2022-07-09nls: Update translations....po/guix/tr.po: New file. po/guix/LINGUAS: Add it. Julien Lepiller 2022-06-04nls: Update translations....po/packages/tr.po: New file. po/packages/LINGUAS: Add it. Julien Lepiller 2022-05-01nls: Update translations....po/guix/ja.po: New file. po/guix/LINGUAS: Add it. Julien Lepiller 2022-04-02nls: Update translations....* po/packages/fi.po: New file. * po/packages/LINGUAS: Add it. Julien Lepiller 2022-04-02nls: Enforce translation thresholds....* po/doc/guix-cookbook.es.po: Remove file. * po/doc/guix-cookbook.fa.po: Remove file. * po/doc/guix-cookbook.fi.po: Remove file. * po/doc/guix-cookbook.pt_BR.po: Remove file. * po/doc/guix-cookbook.ru.po: Remove file. * po/doc/guix-cookbook.uk.po: Remove file. * po/doc/guix-cookbook.zh_Hans.po: Remove file. * po/doc/guix-manual.fa.po: Remove file. * po/doc/guix-manual.fi.po: Remove file. * po/doc/guix-manual.it.po: Remove file. * po/doc/guix-manual.ko.po: Remove file. * po/doc/guix-manual.sk.po: Remove file. * po/doc/local.mk: Remove them. * doc/local.mk: Remove them. Julien Lepiller 2022-03-01nls: Update translations....* po/doc/guix-cookbook.uk.po: New file. * po/doc/local.mk: Add uk cookbook. * doc/local.mk: Add uk cookbook. * po/guix/fa.po: New file. * po/guix/uk.po: New file. * po/guix/LINGUAS: Add fa and uk. Julien Lepiller 2022-02-04nls: Update translations....* po/doc/guix-cookbook.pt_BR.po: New file. * po/doc/local.mk: Add it. * doc/local.mk: Add pt_BR cookbook. Julien Lepiller 2022-01-09nls: Update translations....* po/doc/guix-cookbook.fi.po: New file. * po/doc/guix-manual.fi.po: New file. * po/doc/local.mk: Add them. * doc/local.mk: Add them. * po/guix/fi.po: New file. * po/guix/LINGUAS: Add it. Julien Lepiller 2021-12-04nls: Update translations.Julien Lepiller 2021-11-06nls: Update translations....* po/doc/guix-cookbook.es.po: New file. * po/doc/local.mk: Add 'es' cookbook. * doc/local.mk: Add 'es' cookbook. Julien Lepiller 2021-10-17nls: Update translations.Julien Lepiller 2021-09-02nls: Update translations....* po/packages/it.po: New file. * po/packages/LINGUAS: Add `it'. * po/*/*.po: Update translations. Julien Lepiller 2021-08-04nls: Update translations....* po/doc/guix-cookbook.ru.po: New file. * po/doc/guix-cookbook.sk.po: New file. * po/*/*.po: Update translations. * doc/local.mk (COOKBOOK_LANGUAGES): Add ru and sk. (info_TEXINFOS): Add Russian and Slovak cookbooks. * po/doc/local.mk (DOC_COOKBOOK_PO_FILES): Add Russian and Slovak po files. Julien Lepiller