Skip Menu |

This queue is for tickets about the GnuPG CPAN distribution.

Report information
The Basics
Id: 58213
Status: new
Priority: 0/
Queue: GnuPG

People
Owner: Nobody in particular
Requestors: IKEGAMI [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.17
Fixed in: (no value)



Subject: GnuPG assumes STDIN is attached to fd0 and STDOUT is attached to fd1
GnuPG assumes STDIN is attached to fd0 and STDOUT is attached to fd1, but that's not always the case. For example, Catalyst overwrites the STDIN and STDOUT handles. Workaround: open(local *STDIN, '<&=0') or Carp::croak("Cannot reopen stdin: $!"); open(local *STDOUT, '>&=1') or Carp::croak("Cannot reopen stdout: $!");
Same idea for STDERR too.
This is an interesting problem, and I might try to implement this or another fix into the codebase in a future release, however, for now my answer is that GnuPG only uses STDIN and STDOUT as a fallback method, so I recommend that if you're in this scenario with Catalyst or some other application having redirected these, then simply pass your file descriptors or filenames directly to GnuPG. The most correct fix here is probably for me to refactor GnuPG to use sysread() and syswrite().
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.