From mboxrd@z Thu Jan 1 00:00:00 1970 From: Leo Famulari Subject: bug#24076: [PATCH] gnu: GnuPG: Really use ~/.guix-profile/bin/pinentry by default. Date: Fri, 27 Mar 2020 18:48:01 -0400 Message-ID: References: <20160726180507.21e5e8e0@scratchpost.org> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:53680) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jHxmh-00037M-Cn for bug-guix@gnu.org; Fri, 27 Mar 2020 18:49:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jHxmg-0005Z1-BR for bug-guix@gnu.org; Fri, 27 Mar 2020 18:49:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:55741) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jHxmg-0005Ys-6c for bug-guix@gnu.org; Fri, 27 Mar 2020 18:49:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jHxmg-0004Zv-37 for bug-guix@gnu.org; Fri, 27 Mar 2020 18:49:02 -0400 In-Reply-To: <20160726180507.21e5e8e0@scratchpost.org> Sender: "Debbugs-submit" Resent-Message-ID: List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+gcggb-bug-guix=m.gmane-mx.org@gnu.org Sender: "bug-Guix" To: 24076@debbugs.gnu.org This is a followup to commit c7af9d0b5ebaa1fdb08ff5d8a56004998bcd8103. This patch does as expected for me! But it's been some years since I wrote C code, so I copy existing functions and fought through compiler errors to write this — please give a close review. * gnu/packages/patches/gnupg-default-pinentry.patch: Use $HOME to find the user's Guix profile and installed pinentry. --- .../patches/gnupg-default-pinentry.patch | 39 +++++++++++++++---- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/gnu/packages/patches/gnupg-default-pinentry.patch b/gnu/packages/patches/gnupg-default-pinentry.patch index 272f4b53dc..5a3189b98a 100644 --- a/gnu/packages/patches/gnupg-default-pinentry.patch +++ b/gnu/packages/patches/gnupg-default-pinentry.patch @@ -1,15 +1,40 @@ -Default to the pinentry program installed in ~/.guix-profile. - diff --git a/common/homedir.c b/common/homedir.c -index e9e75d0..74e0aaf 100644 +index 4b6e46e88..de71e97b1 100644 --- a/common/homedir.c +++ b/common/homedir.c -@@ -968,7 +968,7 @@ get_default_pinentry_name (int reset) +@@ -67,6 +67,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 +513,16 @@ 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 (!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 +985,7 @@ get_default_pinentry_name (int reset) } names[] = { /* The first entry is what we return in case we found no other pinentry. */ -- { gnupg_bindir, DIRSEP_S "pinentry" EXEEXT_S }, -+ { gnupg_homedir, "/.guix-profile/bin/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.) */ - { w32_rootdir, "\\..\\Gpg4win\\bin\\pinentry.exe" }, -- 2.26.0