ppisar pushed to perl-Mail-GnuPG (master). "Adapt to gpg-agent-2.1"

notifications at fedoraproject.org notifications at fedoraproject.org
Mon May 18 14:34:10 UTC 2015


From b4be8159b22219276a677f0d28828bbd22541ec7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar at redhat.com>
Date: Wed, 13 May 2015 17:46:00 +0200
Subject: Adapt to gpg-agent-2.1


diff --git a/Mail-GnuPG-0.21-Adapt-to-gpg-agent-2.1.patch b/Mail-GnuPG-0.21-Adapt-to-gpg-agent-2.1.patch
new file mode 100644
index 0000000..a896ab3
--- /dev/null
+++ b/Mail-GnuPG-0.21-Adapt-to-gpg-agent-2.1.patch
@@ -0,0 +1,129 @@
+From ca62a09a4a2973471593dc79b14741a18ad6027c Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar at redhat.com>
+Date: Wed, 13 May 2015 17:31:53 +0200
+Subject: [PATCH] Adapt to gpg-agent-2.1
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Since gnupg2 2.1, gpg-agent does not export GPG_AGENT_INFO which is
+needed for gpg from gnupg-1.
+
+CPAN RT#102719
+
+Signed-off-by: Petr Písař <ppisar at redhat.com>
+---
+ Build.PL          |  1 +
+ lib/Mail/GnuPG.pm |  2 ++
+ t/agent.t         | 35 +++++++++++++++++++++++++++++------
+ 3 files changed, 32 insertions(+), 6 deletions(-)
+
+diff --git a/Build.PL b/Build.PL
+index b8ac716..07f4f13 100644
+--- a/Build.PL
++++ b/Build.PL
+@@ -10,6 +10,7 @@ my $build = Module::Build->new
+ 		    'David Bremner <ddb at cpan.org>'],
+    (sign => 1),
+    requires => {
++		'Cwd' => 0,
+ 		'File::Spec' => 0,
+ 		'File::Temp' => 0,
+ 		'GnuPG::Interface' => 0,
+diff --git a/lib/Mail/GnuPG.pm b/lib/Mail/GnuPG.pm
+index 23ddb20..703ec60 100644
+--- a/lib/Mail/GnuPG.pm
++++ b/lib/Mail/GnuPG.pm
+@@ -48,6 +48,8 @@ use Errno qw(EPIPE);
+    always_trust => always trust a public key
+    # FIXME: we need more things here, maybe primary key id.
+ 
++ If you use gpg-agent from GnuPG-2.1 with gpg from GnuPG-1, you have
++ to set GPG_AGENT_INFO environment variable manually.
+ 
+ =cut
+ 
+diff --git a/t/agent.t b/t/agent.t
+index 4e85b13..ac52c1e 100644
+--- a/t/agent.t
++++ b/t/agent.t
+@@ -4,6 +4,7 @@ use Test::More;
+ use File::Temp qw(tempdir);
+ use Mail::GnuPG;
+ use MIME::Entity;
++use Cwd;
+ use strict;
+ no warnings 'redefine';         # fix this later
+ 
+@@ -24,8 +25,10 @@ unless (0 == system("$preset --version 2>&1 >/dev/null")) {
+ }
+ 
+ my $tmpdir = tempdir( "mgtXXXXX", CLEANUP => 1);
++# Change HOME because gpg-preset-passphrase does not understand to --homedir.
++$ENV{HOME} = $tmpdir;
+ 
+-unless ( 0 == system("gpg --homedir $tmpdir --trusted-key 0x49539D60EFEA4EAD --import t/test-key.pgp 2>&1 >/dev/null")) {
++unless ( 0 == system("gpg --trusted-key 0x49539D60EFEA4EAD --import t/test-key.pgp 2>&1 >/dev/null")) {
+   plan skip_all => "unable to import testing keys";
+   goto end;
+ }
+@@ -35,15 +38,35 @@ unless (open AGENT, "gpg-agent  --disable-scdaemon --allow-preset --daemon|") {
+   goto end;
+ }
+ 
++# GPG-1 agent
+ my ($agent_pid,$agent_info);
+ while (<AGENT>){
+   if (m/GPG_AGENT_INFO=([^;]*);/){
+     $agent_info=$1;
+-    $ENV{'GPG_AGENT_INFO'}=$agent_info;
+-    my @parts=split(':',$agent_info);
+-    $agent_pid=$parts[1];
+   }
+ }
++# GPG-2.1 agent
++if (!defined $agent_info) {
++    unless (open(CLIENT, q{printf '/serverpid\n/subst\n/echo ${get homedir}/S.gpg-agent:${get serverpid}:1\n' | gpg-connect-agent|})) {
++        plan skip_all => "unable to obtain GPG_AGENT_INFO";
++        goto end;
++    }
++    {
++        local $/='';
++        $agent_info=<CLIENT>;
++    }
++    close(CLIENT);
++    chomp $agent_info;
++}
++# The returned socket path can be relative to $HOME, but relative paths are
++# not acceptable by gpg-1. (Seen with GPG-2.0 agent.) Make it absolute now.
++if ($agent_info =~ /([^:]+)(:.*)/) {
++    $agent_info = Cwd::abs_path($1) . $2;
++}
++diag("GPG_AGENT_INFO: $agent_info");
++$ENV{'GPG_AGENT_INFO'}=$agent_info;
++my @parts=split(':',$agent_info);
++$agent_pid=$parts[1];
+ 
+ # gpg-preset-passphrase uses the fingerprint of the subkey, rather than the id.
+ unless ( 0 == system ("$preset --preset -P passphrase " .
+@@ -58,7 +81,6 @@ plan tests => 20;
+ 
+ 
+ my $mg = new Mail::GnuPG( key => '49539D60EFEA4EAD',
+-			  keydir => $tmpdir,
+ 			  use_agent => 1);
+ 
+ isa_ok($mg,"Mail::GnuPG");
+@@ -75,7 +97,8 @@ my $me =  MIME::Entity->build(From    => 'me at myhost.com',
+ 
+ $copy = $me->dup;
+ 
+-is( $mg->mime_sign( $copy ), 0 );
++is( $mg->mime_sign( $copy ), 0, 'signing' ) or
++    diag(@{$mg->{last_message}});
+ 
+ my ($verify,$key,$who) = $mg->verify($copy);
+ is( $verify, 0 );
+-- 
+2.1.0
+
diff --git a/perl-Mail-GnuPG.spec b/perl-Mail-GnuPG.spec
index 9b25fe0..449d9e6 100644
--- a/perl-Mail-GnuPG.spec
+++ b/perl-Mail-GnuPG.spec
@@ -1,7 +1,7 @@
 Name:		perl-Mail-GnuPG
 Summary:	Process email with GPG
 Version:	0.21
-Release:	2%{?dist}
+Release:	3%{?dist}
 License:	GPLv2 or Artistic
 Group:		Development/Libraries
 URL:		http://search.cpan.org/dist/Mail-GnuPG/
@@ -9,6 +9,8 @@ BuildArch:	noarch
 
 Requires:	perl(:MODULE_COMPAT_%(eval "`%{__perl} -V:version`"; echo $version))
 Source0:	http://www.cpan.org/authors/id/D/DD/DDB/Mail-GnuPG-%{version}.tar.gz
+# Adapt to gpg-agent-2.1, bug #1189666, CPAN RT#102719
+Patch0: 	Mail-GnuPG-0.21-Adapt-to-gpg-agent-2.1.patch
 
 BuildRequires:	perl(GnuPG::Interface)
 BuildRequires:	perl(Mail::Address)
@@ -17,6 +19,7 @@ BuildRequires:	perl(MIME::Parser)
 BuildRequires:	perl(Module::Build)
 
 # Required by the tests
+BuildRequires:  perl(Cwd)
 BuildRequires:	perl(Test::More)
 BuildRequires:	perl(Test::Pod) >= 0.95
 BuildRequires:	/usr/bin/gpg
@@ -27,6 +30,7 @@ Use GnuPG::Interface to process or create PGP signed or encrypted email.
 
 %prep
 %setup -q -n Mail-GnuPG-%{version}
+%patch0 -p1
 iconv -f iso-8859-1 -t utf-8 README > README~
 mv README~ README
 
@@ -49,6 +53,9 @@ GPG_PRESET_PASSPHRASE=/usr/libexec/gpg-preset-passphrase ./Build test
 %{_mandir}/man3/*
 
 %changelog
+* Wed May 13 2015 Petr Pisar <ppisar at redhat.com> - 0.21-3
+- Adapt to gpg-agent-2.1 (bug #1189666)
+
 * Tue Sep 02 2014 Jitka Plesnikova <jplesnik at redhat.com> - 0.21-2
 - Perl 5.20 rebuild
 
-- 
cgit v0.10.2


	http://pkgs.fedoraproject.org/cgit/perl-Mail-GnuPG.git/commit/?h=master&id=b4be8159b22219276a677f0d28828bbd22541ec7


More information about the perl-devel mailing list