Subject: Re: bug#24076: [PATCH] gnu: GnuPG: Really use ~/.guix-profile/bin/pinentry by default.

From: Ludovic Courtès <[email-masked]>
Date: Sun, 29 Mar 2020 16:57:33 +0200

Hi Leo!

Leo Famulari <[email-masked]> skribis:

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

Thanks for fixing it, and apologies for the mistake!

> ++/* Return the user's home directory */
> ++const char *
> ++user_homedir (void)
> ++{
> ++  const char *dir;
> ++  dir = getenv("HOME");

Here I’d add:

  if (dir == NULL)
    {
       struct password *pw;
       pw = getpwuid (getuid ());
       if (pw != NULL)
         dir = pw->pw_dir;
       else
         dir = "/";
    }

Otherwise LGTM!

Ludo’.