Pinentry: Inappropriate ioctl for device when getting smartcard PIN

Jacob Adams tookmund at gmail.com
Tue Jul 3 23:12:05 CEST 2018


On 06/29/2018 07:45 PM, Jacob Adams wrote:
> On 06/27/2018 04:50 PM, Jacob Adams wrote:
>> I've got another pinentry problem unfortunately.
>> The tty is owned by the correct user this time and $GPG_TTY is set
>> correctly.
>>
>> I have two gpgme contexts, one for openpgp and another for assuan
>> commands to the smartcard. Pinentry triggered by the openpgp context
>> works perfectly, but any pinentry launched in service of the assuan
>> context fails with the error in the subject. They're both using the same
>> gpg-agent launched shortly after the creation of the openpgp context
>> with gpgconf --launch gpg-agent.
>>
>> The relevant logs are available at:
>> https://salsa.debian.org/tookmund-guest/pgpcr/issues/10
>>

> It appears that tty_name is not being set, despite the fact that GPG_TTY
> is set and thus gpg-agent has this information from the previous Context.
> 
>> I'm really not sure what's going wrong here and any insight would be
>> much appreciated.

I have a solution for this but it's definitely the wrong solution.

I've applied the following patch to pinentry to fix this problem:

--- a/pinentry/pinentry-curses.c
+++ b/pinentry/pinentry-curses.c
@@ -1187,7 +1187,8 @@
       alarm (pinentry->timeout);
     }
 #endif
-
+  if (pinentry->ttyname == NULL)
+    pinentry->ttyname = getenv("GPG_TTY");
   rc = dialog_run (pinentry, pinentry->ttyname, pinentry->ttytype);
   do_touch_file (pinentry);
   return rc;

Clearly this is not the right approach as it appears that gpg-agent is
supposed to handle the GPG_TTY variable. For some reason, it is simply
not passing it on to pinentry in this one case.

I've tried to reproduce this issue in a separate program but have been
unsuccessful. However it's consistently reproducible without this patch
in my program. Does anyone have an insight into why this patch would be
required?

Thanks,
Jacob

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <https://lists.gnupg.org/pipermail/gnupg-users/attachments/20180703/d5b42f21/attachment-0001.sig>


More information about the Gnupg-users mailing list