Wondering if anyone could take a look at this. I had decryption working fine, but couldn't get encryption to work. I upgraded to the newest version of GnuPG::Interface. I finally managed to get encryption working not long after, however, the next time I checked, decryption is now broken. Now they're both broken... ARG

When I decrypt, it says "Broken pipe" and when I try to encrypt, it creates a file but never writes to it, with no errors displayed

The script:

#!/usr/bin/perl -wT # {{{ info # # putmpw.pl # # Created: 2003-05-29 by Andy Harrison <ajharrison@gwi.net> # # putmpw.pl will reside on each server in the system for the purpose o +f # syncing the master.passwd file # # Usage: putmpw.pl --source # use when running on the source server # putmpw.pl --target # use when running on the target server # # $Id: putmpw.pl,v 1.6 2003/06/02 17:54:47 ajharrison Exp $ # # }}} # {{{ args $|++; use Data::Dumper; use vars qw( $opt_source $opt_target $opt_v ); use Getopt::Long; GetOptions ( 'source' => \$opt_source, 'target' => \$opt_target, 'v!' => \$opt_v ); unless ( $opt_source || $opt_target ) { die "Arguments:\n\n Required:\n --source # use when running on the source server\n --target # use when running on the target server\n Optional:\n -v verbose\n "; } else { # }}} # {{{ modules/vars/handles use IO::Handle; use GnuPG::Interface; use IO::File; my $mpw = "master.passwd"; my $gpgmpw = "/root/master.passwd.asc"; # }}} # {{{ main if ( $opt_target ) { # {{{ decrypt my $gnupg = GnuPG::Interface->new(); $gnupg->options->hash_init( armor => 1, homedir => '/root/.g +nupg' ); # Note you can set the recipients even if you aren't encryptin +g! $gnupg->options->push_recipients( 'root@diesel.gwi' ); $gnupg->options->meta_interactive( 0 ); # This time we'll catch the standard error for our perusing # as well as passing in the passphrase manually # as well as the status information given by GnuPG my ( $input, $output, $error, $passphrase_fh, $status_fh ) = ( IO::Handle->new(), IO::Handle->new(), IO::Handle->new(), IO::Handle->new(), IO::Handle->new(), ); my $handles = GnuPG::Handles->new( stdin => $input, stdout => $output, stderr => $error, passphrase => $passphrase_fh, status => $status_fh, ); my $cipher_file = IO::File->new( "$gpgmpw" ) || die "\n\nUnable to open encrypted master.passwd file. $!\ +n"; # this sets up the communication my $pid = $gnupg->decrypt( handles => $handles ); # This passes in the passphrase, which is blank to use an empt +y # passphrase. Not the best idea, but you still can't extract +the file # without access to the secret key in /root/.gnupg/ print $passphrase_fh ""; close $passphrase_fh; # this passes in the plaintext print "----step1\n\n\n"; print $input $_ while <$cipher_file>; print "----step2\n\n\n"; # this closes the communication channel, indicating we are don +e close $input; close $cipher_file; my @plaintext = <$output>; # reading the output my @error_output = <$error>; # reading the error my @status_info = <$status_fh>; # read the status info if ( $opt_v ) { # display the decrypted contents on screen print "--------- begin decrypted file ----------\n\n", @plaintext, "----------- end decrypted file ---------\n\n"; print @error_output; print @status_info; } print "writing decrypted master.passwd file... "; print $dec_mpw @plaintext || die "Unsuccessful\n\n"; print "Successful\n\n"; # clean up... close $output; close $error; close $status_fh; close $dec_mpw; waitpid $pid, 0; # clean up the finished GnuPG process # }}} } elsif ( $opt_source ) { # {{{ encrypt my $encrypted_file = IO::File->new( ">$gpgmpw" ) || die "\n\nUnable to open encrypted master.

Any suggestions?

~~
naChoZ


In reply to GnuPG::Interface by naChoZ

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.