I'm sorry, I was not able to install any of the existing GPG modules properly. I am using plain open3 instead.
Note: If you are under mod_perl and go with open3, remember to untie STDIN, STDOUT, STDERR or you will get strange results.
This is the code I use for open3 (with some debugging commented out):
use IPC::Open3 (); # don't import open3 sub my_open3 { # cmd write read error my %opt = ( write => [], read => [], error => [], cmd => "ls", @_); my $stdin = tied *STDIN; my $stdout = tied *STDOUT; my $stderr = tied *STDERR; # temporarily turn off warnings # "untie attempted while 1 inner references still exist" { local $^W = 0; untie *STDIN if $stdin; untie *STDOUT if $stdout; untie *STDERR if $stderr; } my $pid = IPC::Open3::open3(*WTRFH, *RDRFH, *ERR, $opt{cmd}); unless ($pid) { print "can't fork: $!" if $DEBUG; return 0; } # local $SIG{PIPE} = sub { 1 }; # $pipe_error = 1 }; print WTRFH @{$opt{write}}; # || return 0; # die "can't write: $!"; close (WTRFH); # || return 0; #die "bad pipe: $! $?"; @{$opt{read}} = <RDRFH>; @{$opt{error}} = <ERR>; close (RDRFH); # || return 0; #die "bad pipe: $! $?"; close (WTRFH); # || return 0; #die "bad pipe: $! $?"; waitpid $pid, 0; tie *STDIN, ref $stdin, $stdin if $stdin; tie *STDOUT, ref $stdout, $stdout if $stdout; tie *STDERR, ref $stderr, $stderr if $stderr; return 1; # ok }
This is an example on how to use it:
my $gpg = "gpg ...options..."; my ($id, $pass, @data) = ('fglock','xxx',"data\n","data\n"); my (@result, @err); unshift @data, $pass . "\n"; $cmd = "$gpg --no-tty --local-user $id --passphrase-fd 0 --decrypt +"; my_open3( cmd => $cmd, write => \@data, read => \@result, error => \@err );
In reply to Re: GnuPG::Interface and fingerprint
by fglock
in thread GnuPG::Interface and fingerprint
by pawal
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |