Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: ModPerl: ModPerl

GnuPG module producing empty files

 

 

ModPerl modperl RSS feed   Index | Next | Previous | View Threaded


laurent at gide

Oct 15, 2009, 7:12 AM

Post #1 of 4 (184 views)
Permalink
GnuPG module producing empty files

Hi!

I've recently upgraded one of my old website to mod_perl
(ModPerl::PerlRun) and I'm not able to make GnuPG (0.10) work
properly :/ As soon as I try to encrypt a plaintext file, I get an
empty encrypted file. See below what I get in error log with the
'trace' option set to true:
protocol error: expected SHM_GET_XXX got \n at /usr/lib/perl5/
site_perl/5.8.5/GnuPG.pm line 154

Any clue? Thanks in advance :)

--
Laurent MARTIN


ceeshek at gmail

Oct 18, 2009, 11:26 PM

Post #2 of 4 (154 views)
Permalink
Re: GnuPG module producing empty files [In reply to]

On Fri, Oct 16, 2009 at 1:12 AM, Laurent MARTIN <laurent[at]gide.net> wrote:

> Hi!
> I've recently upgraded one of my old website to mod_perl (ModPerl::PerlRun)
> and I'm not able to make GnuPG (0.10) work properly :/ As soon as I try to
> encrypt a plaintext file, I get an empty encrypted file. See below what I
> get in error log with the 'trace' option set to true:
> protocol error: expected SHM_GET_XXX got \n at
> /usr/lib/perl5/site_perl/5.8.5/GnuPG.pm line 154
>
> Any clue? Thanks in advance :)
>

This might be because the GnuPG module executes the 'gpg' binary directly to
run it's commands and it plays with STDIN, STDOUT and STDERR to do that.

I had a similar issue using GnuPG::Interface under mod_perl, but was able to
solve it by untieing and saving STDIN and STDOUT when making calls to
GnuPG::Interface (the example below calls Mail::GPG which in turn uses
GnuPG::Interface to do the grunt work):

use constant MP => ( exists $ENV{MOD_PERL} );
use constant MP2 => ( exists $ENV{MOD_PERL_API_VERSION} and
$ENV{MOD_PERL_API_VERSION} >= 2 );

# mod_perl ties STDIN and STDOUT which conflicts with GnuPG::Interface
my ( $stdin, $stdout );
if ( MP and not MP2 ) {
$stdin = tied *STDIN;
$stdout = tied *STDOUT;
untie *STDIN;
untie *STDOUT;
}
my $mg = Mail::GPG->new( gnupg_hash_init => \%GNUPG_OPTIONS );
my $key_id = eval { $mg->query_keyring( search => $name ); };
if ( MP and not MP2 ) {
tie *STDIN, ref $stdin, $stdin;
tie *STDOUT, ref $stdout, $stdout;
}
die "query_keyring failed: $@" if $@;


Note though that I only noticed the issues with mod_perl1 and not with
mod_perl2 so it may be something different that you are seeing. Here's
hoping it gives you some hints on where to look next...

Cheers,

Cees


laurent at gide

Oct 19, 2009, 6:03 AM

Post #3 of 4 (152 views)
Permalink
Re: GnuPG module producing empty files [In reply to]

Hi Cees,
Thank you for your help on this. Unfortunately, this doesn't fix my
problem.
Has anyone on the list some experience with mod_perl and an
alternative to GnuPG module (which is "simply" a wrapper around pgp
binary). Crypt::GPG? Crypt::OpenPGP?
TIA.
Laurent.

On 19 oct. 2009, at 08:26, Cees Hek wrote:

> On Fri, Oct 16, 2009 at 1:12 AM, Laurent MARTIN <laurent[at]gide.net>
> wrote:
> Hi!
>
> I've recently upgraded one of my old website to mod_perl
> (ModPerl::PerlRun) and I'm not able to make GnuPG (0.10) work
> properly :/ As soon as I try to encrypt a plaintext file, I get an
> empty encrypted file. See below what I get in error log with the
> 'trace' option set to true:
> protocol error: expected SHM_GET_XXX got \n at /usr/lib/perl5/
> site_perl/5.8.5/GnuPG.pm line 154
>
> Any clue? Thanks in advance :)
>
> This might be because the GnuPG module executes the 'gpg' binary
> directly to run it's commands and it plays with STDIN, STDOUT and
> STDERR to do that.
>
> I had a similar issue using GnuPG::Interface under mod_perl, but was
> able to solve it by untieing and saving STDIN and STDOUT when making
> calls to GnuPG::Interface (the example below calls Mail::GPG which
> in turn uses GnuPG::Interface to do the grunt work):
>
> use constant MP => ( exists $ENV{MOD_PERL} );
> use constant MP2 => ( exists $ENV{MOD_PERL_API_VERSION} and $ENV
> {MOD_PERL_API_VERSION} >= 2 );
>
> # mod_perl ties STDIN and STDOUT which conflicts with
> GnuPG::Interface
> my ( $stdin, $stdout );
> if ( MP and not MP2 ) {
> $stdin = tied *STDIN;
> $stdout = tied *STDOUT;
> untie *STDIN;
> untie *STDOUT;
> }
> my $mg = Mail::GPG->new( gnupg_hash_init => \%GNUPG_OPTIONS );
> my $key_id = eval { $mg->query_keyring( search => $name ); };
> if ( MP and not MP2 ) {
> tie *STDIN, ref $stdin, $stdin;
> tie *STDOUT, ref $stdout, $stdout;
> }
> die "query_keyring failed: $@" if $@;
>
>
> Note though that I only noticed the issues with mod_perl1 and not
> with mod_perl2 so it may be something different that you are
> seeing. Here's hoping it gives you some hints on where to look
> next...
>
> Cheers,
>
> Cees


mschout at gkg

Oct 20, 2009, 12:05 PM

Post #4 of 4 (142 views)
Permalink
Re: GnuPG module producing empty files [In reply to]

Laurent MARTIN wrote:

> Has anyone on the list some experience with mod_perl and an alternative
> to GnuPG module (which is "simply" a wrapper around pgp binary).

I use GnuPG::Interface, and it works fine.

Regards,
Michael Schout

ModPerl modperl RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.