Here's the patch we're currently applying in Debian.
(Credits: dkg)
From: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
Date: Fri, 2 Sep 2016 08:46:23 -0400
Subject: use fake pinentry (Closes: #835075)
This allows us to run the tests against all versions of GnuPG.
---
t/30.inline-decrypt.t | 7 +++++++
t/fake-pinentry.pl | 16 ++++++++++++++++
t/import_keys.pl | 9 +++++++++
3 files changed, 32 insertions(+)
create mode 100755 t/fake-pinentry.pl
diff --git a/t/30.inline-decrypt.t b/t/30.inline-decrypt.t
index bb38ee2..8b74e1c 100644
--- a/t/30.inline-decrypt.t
+++ b/t/30.inline-decrypt.t
@@ -4,6 +4,8 @@ use Test::More;
use Mail::GnuPG;
use MIME::Entity;
use File::Temp qw(tempdir);
+use Cwd;
+use IO::File;
use strict;
@@ -25,6 +27,11 @@ unless ( 0 == system("gpg --version 2>&1 >/dev/null") ) {
}
my $tmpdir = tempdir( "mgtXXXXX", CLEANUP => 1);
+my $agentconf = IO::File->new("> $tmpdir/gpg-agent.conf");
+if (defined $agentconf) {
+ print $agentconf "pinentry-program ".getcwd."/t/fake-pinentry.pl\n";
+ $agentconf->close;
+}
unless ( 0 == system("gpg --homedir $tmpdir --trusted-key 0x49539D60EFEA4EAD --import t/test-key.pgp 2>&1 >/dev/null")) {
plan skip_all => "unable to import testing keys";
diff --git a/t/fake-pinentry.pl b/t/fake-pinentry.pl
new file mode 100755
index 0000000..c138b5d
--- /dev/null
+++ b/t/fake-pinentry.pl
@@ -0,0 +1,16 @@
+#!/usr/bin/perl -w
+use strict;
+use warnings;
+
+# turn off buffering
+$| = 1;
+
+print "OK This is only for test suites, and should never be used in production\n";
+while (<STDIN>) {
+ chomp;
+ next if (/^$/);
+ print ("D passphrase\n") if (/^getpin/i);
+ print "OK\n";
+ exit if (/^bye/i);
+}
+1;
diff --git a/t/import_keys.pl b/t/import_keys.pl
index 06ee759..df69111 100644
--- a/t/import_keys.pl
+++ b/t/import_keys.pl
@@ -1,3 +1,6 @@
+use IO::File;
+use Cwd;
+
sub import_keys($){
my $filename=shift;
@@ -10,6 +13,12 @@ sub import_keys($){
}
my $gpghome = tempdir( "mgtXXXXX", CLEANUP => 1);
+ my $agentconf = IO::File->new("> $gpghome/gpg-agent.conf");
+ if (defined $agentconf) {
+ print $agentconf "pinentry-program ".getcwd."/t/fake-pinentry.pl\n";
+ $agentconf->close;
+ }
+
unless ( 0 == system("gpg --homedir $gpghome $trusted --import $filename 2>&1 >/dev/null")) {
return undef;
}