Skip to content

GnuPG::Interface::_version does not work under mod_perl #8

@jirkanov

Description

@jirkanov

When trying to sign a mail message from mod_perl using Mail::GnuPG I get these errors:

Can't open(IO::Handle=GLOB(0x563c07e781e0), <&-1): Invalid argument at (eval 276) line 55.

and

Use of uninitialized value $line in pattern match (m//) at /usr/lib64/perl5/vendor_perl/5.32/GnuPG/Interface.pm line 830.
Argument "xnovosa1" isn't numeric in numeric comparison (<=>) at /usr/lib64/perl5/vendor_perl/5.32/GnuPG/Interface.pm line 849.
Argument "xnovosa1" isn't numeric in numeric comparison (<=>) at /usr/lib64/perl5/vendor_perl/5.32/GnuPG/Interface.pm line 849.
GnuPG Version 1.4 or 2.2+ required at (eval 276) line 55.

Under mod_perl, fileno(STDIN) == -1 and the code in GnuPG::Interface::fork_attach_exec doesn't cope with this possibility. This patch seems to be a simple way of avoiding the problem:

diff --git a/lib/GnuPG/Interface.pm b/lib/GnuPG/Interface.pm
index 905ae30..a8d5aba 100644
--- a/lib/GnuPG/Interface.pm
+++ b/lib/GnuPG/Interface.pm
@@ -821,7 +821,10 @@ sub _version {
     my ( $self ) = @_;

     my $out = IO::Handle->new;
-    my $handles = GnuPG::Handles->new( stdout => $out );
+    my $handles = GnuPG::Handles->new(
+        stdout => $out,
+        stdin  => IO::Handle->new,
+    );
     my $pid = $self->wrap_call( commands => [ '--no-options', '--version' ], handles => $handles );
     my $line = $out->getline;
     $line =~ /(\d+\.\d+\.\d+)/;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions