Sorry, I didn't realize the fix would be unclear.
On Fri Jun 18 15:11:25 2010, MFROST wrote:
Show quoted text> I recommend that if you're in this scenario [...],
> then simply pass your file descriptors or filenames
> directly to GnuPG.
Passing the file handles or file descriptors doesn't help. They'll just
end up associated with fd 3 (or whatever) instead of fd 0 as required.
The fix is to change
if ( ref $self->{input} && defined fileno $self->{input} ) {
open ( STDIN, "<&" . fileno $self->{input} )
or die "error setting up data input: $!\n";
} elsif ( $self->{input} && -t STDIN) {
open ( STDIN, $self->{input} )
or die "error setting up data input: $!\n";
} elsif ( $self->{input} ) {
push(@{$cmdline}, $self->{input});
}# Defaults to stdin
to
my $input_fd = fileno(STDIN);
if ( ref $self->{input} && defined fileno $self->{input} ) {
$input_fd = fileno $self->{input};
} elsif ( $self->{input} && -t STDIN) {
open ( STDIN, $self->{input} )
or die "error setting up data input: $!\n";
} elsif ( $self->{input} ) {
push(@{$cmdline}, $self->{input});
}
if ($input_fd != 0) {
open ( my $fh, "<&=0" )
or die "error getting fd 0: $!\n";
open ( $fh, "<&".$input_fd )
or die "error setting up data input: $!\n";
}
or the simpler
use POSIX qw( dup2 );
my $input_fd = fileno(STDIN);
if ( ref $self->{input} && defined fileno $self->{input} ) {
$input_fd = fileno $self->{input};
} elsif ( $self->{input} && -t STDIN) {
open ( STDIN, $self->{input} )
or die "error setting up data input: $!\n";
} elsif ( $self->{input} ) {
push(@{$cmdline}, $self->{input});
}
if ($input_fd != 0) {
dup2($input_fd, 0)
or die "error setting up data input: $!\n";
}
Similarly for STDOUT and STDERR.