Skip Menu |

This queue is for tickets about the Mail-GnuPG CPAN distribution.

Report information
The Basics
Id: 60280
Status: resolved
Priority: 0/
Queue: Mail-GnuPG

People
Owner: Nobody in particular
Requestors: david [...] tethera.net
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 0.15_1



CC: David Bremner <bremner [...] unb.ca>
Subject: [PATCH] Add support for gpg agent.
Date: Thu, 12 Aug 2010 13:53:59 -0300
To: bug-Mail-GnuPG [...] rt.cpan.org
From: david [...] tethera.net
From: David Bremner <bremner@unb.ca> This is is controlled by a flag use_agent to the new() method. This has been mainly tested with the decrypt operation. --- It has been suggested that GPG::Interface ought to use gpg-agent by default anyway if it is enabled in ~/.gnupg/gpg.conf, but it doesn't for me, even though gpg on the command line does. See http://www.cs.unb.ca/~bremner/blog/posts/ffac/ for context. GnuPG.pm | 18 ++++++++++++------ 1 files changed, 12 insertions(+), 6 deletions(-) diff --git a/GnuPG.pm b/GnuPG.pm index 629880c..0192453 100644 --- a/GnuPG.pm +++ b/GnuPG.pm @@ -44,7 +44,7 @@ use Errno qw(EPIPE); key => gpg key id keydir => gpg configuration/key directory passphrase => primary key password - + use_agent => use gpg-agent if non-zero # FIXME: we need more things here, maybe primary key id. @@ -58,6 +58,7 @@ sub new { keydir => undef, passphrase => "", gpg_path => "gpg", + use_agent => 0, @_ }; $self->{last_message} = []; @@ -114,6 +115,11 @@ sub _set_options { =cut +sub _agent_args{ + my $self=shift; + return $self->{use_agent} ? ('command_args' => ['--use-agent']) : (); +} + sub decrypt { my ($self, $message) = @_; my $ciphertext = ""; @@ -161,7 +167,7 @@ sub decrypt { ); # this sets up the communication - my $pid = $gnupg->decrypt( handles => $handles ); + my $pid = $gnupg->decrypt( handles => $handles , $self->_agent_args ); die "NO PASSPHRASE" unless defined $passphrase_fh; my $read = _communicate([$output, $error, $status_fh], @@ -542,7 +548,7 @@ sub mime_sign { passphrase => $passphrase_fh, status => $status_fh, ); - my $pid = $gnupg->detach_sign( handles => $handles ); + my $pid = $gnupg->detach_sign( handles => $handles, $self->_agent_args ); die "NO PASSPHRASE" unless defined $passphrase_fh; # this passes in the plaintext @@ -641,7 +647,7 @@ sub clear_sign { stderr => $error, ); - my $pid = $gnupg->clearsign ( handles => $handles ); + my $pid = $gnupg->clearsign ( handles => $handles, $self->_agent_args ); my $plaintext = $body->as_string; @@ -744,7 +750,7 @@ sub _ascii_encrypt { my $pid = do { if ( $sign ) { - $gnupg->sign_and_encrypt ( handles => $handles ); + $gnupg->sign_and_encrypt ( handles => $handles, $self->_agent_args ); } else { $gnupg->encrypt ( handles => $handles ); } @@ -844,7 +850,7 @@ sub _mime_encrypt { my $pid = do { if ($sign) { - $gnupg->sign_and_encrypt( handles => $handles ); + $gnupg->sign_and_encrypt( handles => $handles, $self->_agent_args ); } else { $gnupg->encrypt( handles => $handles ); } -- 1.7.1
Subject: Re: [rt.cpan.org #60280] [PATCH] Add support for gpg agent.
Date: Thu, 12 Aug 2010 20:57:30 -0700
To: bug-Mail-GnuPG [...] rt.cpan.org
From: Robert Spier <rspier [...] pobox.com>
David, Thanks for the patch! Can you provide either an automated test to show it works, or since that might be a pain due to the need for gpg-agent, a simple set of instructions to confirm it? -R david via RT wrote: Show quoted text
> > Thu Aug 12 12:54:20 2010: Request 60280 was acted upon. > Transaction: Ticket created by david@tethera.net > Queue: Mail-GnuPG > Subject: [PATCH] Add support for gpg agent. > Broken in: (no value) > Severity: (no value) > Owner: Nobody > Requestors: david@tethera.net > Status: new > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=60280 > > > > From: David Bremner <bremner@unb.ca> > > This is is controlled by a flag use_agent to the new() method. > > This has been mainly tested with the decrypt operation. > --- > > It has been suggested that GPG::Interface ought to use gpg-agent by > default anyway if it is enabled in ~/.gnupg/gpg.conf, but it doesn't > for me, even though gpg on the command line does. See > http://www.cs.unb.ca/~bremner/blog/posts/ffac/ > for context. > > GnuPG.pm | 18 ++++++++++++------ > 1 files changed, 12 insertions(+), 6 deletions(-) > > diff --git a/GnuPG.pm b/GnuPG.pm > index 629880c..0192453 100644 > --- a/GnuPG.pm > +++ b/GnuPG.pm > @@ -44,7 +44,7 @@ use Errno qw(EPIPE); > key => gpg key id > keydir => gpg configuration/key directory > passphrase => primary key password > - > + use_agent => use gpg-agent if non-zero > # FIXME: we need more things here, maybe primary key id. > > > @@ -58,6 +58,7 @@ sub new { > keydir => undef, > passphrase => "", > gpg_path => "gpg", > + use_agent => 0, > @_ > }; > $self->{last_message} = []; > @@ -114,6 +115,11 @@ sub _set_options { > > =cut > > +sub _agent_args{ > + my $self=shift; > + return $self->{use_agent} ? ('command_args' => ['--use-agent']) : (); > +} > + > sub decrypt { > my ($self, $message) = @_; > my $ciphertext = ""; > @@ -161,7 +167,7 @@ sub decrypt { > ); > > # this sets up the communication > - my $pid = $gnupg->decrypt( handles => $handles ); > + my $pid = $gnupg->decrypt( handles => $handles , $self->_agent_args ); > > die "NO PASSPHRASE" unless defined $passphrase_fh; > my $read = _communicate([$output, $error, $status_fh], > @@ -542,7 +548,7 @@ sub mime_sign { > passphrase => $passphrase_fh, > status => $status_fh, > ); > - my $pid = $gnupg->detach_sign( handles => $handles ); > + my $pid = $gnupg->detach_sign( handles => $handles, $self->_agent_args ); > die "NO PASSPHRASE" unless defined $passphrase_fh; > > # this passes in the plaintext > @@ -641,7 +647,7 @@ sub clear_sign { > stderr => $error, > ); > > - my $pid = $gnupg->clearsign ( handles => $handles ); > + my $pid = $gnupg->clearsign ( handles => $handles, $self->_agent_args ); > > my $plaintext = $body->as_string; > > @@ -744,7 +750,7 @@ sub _ascii_encrypt { > > my $pid = do { > if ( $sign ) { > - $gnupg->sign_and_encrypt ( handles => $handles ); > + $gnupg->sign_and_encrypt ( handles => $handles, $self->_agent_args ); > } else { > $gnupg->encrypt ( handles => $handles ); > } > @@ -844,7 +850,7 @@ sub _mime_encrypt { > > my $pid = do { > if ($sign) { > - $gnupg->sign_and_encrypt( handles => $handles ); > + $gnupg->sign_and_encrypt( handles => $handles, $self->_agent_args ); > } else { > $gnupg->encrypt( handles => $handles ); > } > -- > 1.7.1 > >
Subject: Re: [rt.cpan.org #60280] [PATCH] Add support for gpg agent.
Date: Sat, 14 Aug 2010 12:26:13 -0300
To: bug-Mail-GnuPG [...] rt.cpan.org
From: David Bremner <david [...] tethera.net>
On Thu, 12 Aug 2010 23:57:45 -0400, "rspier@pobox.com via RT" <bug-Mail-GnuPG@rt.cpan.org> wrote: Show quoted text
> Can you provide either an automated test to show it works, or since > that might be a pain due to the need for gpg-agent, a simple set of > instructions to confirm it?
Here is my attempt at a test. See commit comments for discussion.

Message body is not shown because sender requested not to inline it.

From: rspier [...] cpan.org
Applied and pushed to the repository. I don't really use Mail::GnuPG anymore. Would you be interested in taking over maintenance?
Subject: Re: [rt.cpan.org #60280] [PATCH] Add support for gpg agent.
Date: Mon, 27 Sep 2010 14:16:01 -0300
To: bug-Mail-GnuPG [...] rt.cpan.org
From: David Bremner <david [...] tethera.net>
On Sun, 26 Sep 2010 21:07:33 -0400, "Robert Spier via RT" <bug-Mail-GnuPG@rt.cpan.org> wrote: Show quoted text
> > I don't really use Mail::GnuPG anymore. Would you be interested in > taking over maintenance? >
I can give it a try. Some hints would be appreciated; it's my first time maintaining a module on CPAN. David
Fixed in version 0.16