GnuPG module producing empty files

GnuPG module producing empty files

am 15.10.2009 16:12:54 von Laurent MARTIN

--Apple-Mail-155-283383576
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=us-ascii;
format=flowed;
delsp=yes

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
--Apple-Mail-155-283383576
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html;
charset=us-ascii

-webkit-nbsp-mode: space; -webkit-line-break: after-white-space; =
">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:
face=3D"Monaco" size=3D"3"> style=3D"font-size: 12px;">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 =
:)


style=3D"word-wrap: break-word; -webkit-nbsp-mode: space; =
-webkit-line-break: after-white-space; "> style=3D"border-collapse: separate; color: rgb(0, 0, 0); font-family: =
'Lucida Grande'; font-size: 12px; font-style: normal; font-variant: =
normal; font-weight: normal; letter-spacing: normal; line-height: =
normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: =
normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: =
0px; -webkit-border-vertical-spacing: 0px; =
-webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: =
auto; -webkit-text-stroke-width: 0px; ">
break-word; -webkit-nbsp-mode: space; -webkit-line-break: =
after-white-space; "> style=3D"border-collapse: separate; color: rgb(0, 0, 0); font-family: =
'Lucida Grande'; font-size: 12px; font-style: normal; font-variant: =
normal; font-weight: normal; letter-spacing: normal; line-height: =
normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: =
normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: =
0px; -webkit-border-vertical-spacing: 0px; =
-webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: =
auto; -webkit-text-stroke-width: 0px; ">
break-word; -webkit-nbsp-mode: space; -webkit-line-break: =
after-white-space; "> style=3D"border-collapse: separate; color: rgb(0, 0, 0); font-family: =
'Lucida Grande'; font-size: 12px; font-style: normal; font-variant: =
normal; font-weight: normal; letter-spacing: normal; line-height: =
normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: =
normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: =
0px; -webkit-border-vertical-spacing: 0px; =
-webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: =
auto; -webkit-text-stroke-width: 0px; ">
break-word; -webkit-nbsp-mode: space; -webkit-line-break: =
after-white-space; "> style=3D"border-collapse: separate; color: rgb(0, 0, 0); font-family: =
'Lucida Grande'; font-size: 12px; font-style: normal; font-variant: =
normal; font-weight: normal; letter-spacing: normal; line-height: =
normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: =
normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: =
0px; -webkit-border-vertical-spacing: 0px; =
-webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: =
auto; -webkit-text-stroke-width: 0px; ">
break-word; -webkit-nbsp-mode: space; -webkit-line-break: =
after-white-space; "> style=3D"border-collapse: separate; color: rgb(0, 0, 0); font-family: =
'Lucida Grande'; font-size: 12px; font-style: normal; font-variant: =
normal; font-weight: normal; letter-spacing: normal; line-height: =
normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: =
normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: =
0px; -webkit-border-vertical-spacing: 0px; =
-webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: =
auto; -webkit-text-stroke-width: 0px; ">
break-word; -webkit-nbsp-mode: space; -webkit-line-break: =
after-white-space; ">
-- 
Laurent =
MARTIN
=
=

--Apple-Mail-155-283383576--

Re: GnuPG module producing empty files

am 19.10.2009 08:26:10 von Cees Hek

--0016e64606ca5c241d047643d298
Content-Type: text/plain; charset=ISO-8859-1

On Fri, Oct 16, 2009 at 1:12 AM, Laurent MARTIN 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

--0016e64606ca5c241d047643d298
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable


This might be because the GnuPG module execute=
s the 'gpg' binary directly to run it's commands and it plays w=
ith 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 w=
ork):


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

  =A0 # mod_perl ties STDIN and STDOUT which confli=
cts with GnuPG::Interface

  =A0 my ( $stdin, $stdout );
  =A0 if ( MP and not MP2 ) {
=
      =A0 $stdin=A0 =3D tied *STDIN;
      =A0 $=
stdout =3D tied *STDOUT;
      =A0 untie *STDIN;
  =
    =A0 untie *STDOUT;
  =A0 }
  =A0 my $mg =3D Mail:=
:GPG->new( gnupg_hash_init =3D> \%GNUPG_OPTIONS );

  =A0 my $key_id =3D eval { $mg->query_keyring( search =3D> $name=
); };
  =A0 if ( MP and not MP2 ) {
      =A0 tie *S=
TDIN,=A0 ref $stdin,=A0 $stdin;
      =A0 tie *STDOUT, ref $=
stdout, $stdout;
  =A0 }
  =A0 die "query_keyring failed=
:=A0 $@" if $@;



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

Cheer=
s,


Cees


--0016e64606ca5c241d047643d298--

Re: GnuPG module producing empty files

am 19.10.2009 15:03:22 von Laurent MARTIN

--Apple-Mail-41-624812011
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=us-ascii;
format=flowed;
delsp=yes

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
> 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



--Apple-Mail-41-624812011
Content-Transfer-Encoding: 7bit
Content-Type: text/html;
charset=us-ascii

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 <> 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





--Apple-Mail-41-624812011--

Re: GnuPG module producing empty files

am 20.10.2009 21:05:39 von Michael Schout

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

Re: GnuPG module producing empty file

am 23.10.2009 17:11:21 von Laurent MARTIN

>> 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.
Thank you! I'll try that.
Laurent.