diff options
-rwxr-xr-x | cli/icevault | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/cli/icevault b/cli/icevault index e0c2757..ef186d0 100755 --- a/cli/icevault +++ b/cli/icevault @@ -379,7 +379,7 @@ sub saveIdentityFile($$) { # don't encrypt directly into the destination file so we don't # end up with a messed up file if something goes wrong - my $outfh = File::Temp->new(SUFFIX => '.gpg', UNLINK => 0, TMPDIR => 1); + my $outfh = File::Temp->new(SUFFIX => '.gpg', UNLINK => 0, TMPDIR => 1) or die; my $pid = IPC::Open2::open2( ">&".$outfh->fileno , (ref $form ? my $infh : "<&".fileno($NULL)) , $CONFIG{gpg}, qw/-o - --no-encrypt-to --recipient/, $CONFIG{keyid} @@ -398,10 +398,10 @@ sub saveIdentityFile($$) { my $parent_dir = $filename =~ s/\/[^\/]+$//r; File::Path::make_path($parent_dir) unless -d $parent_dir; # create parent directories recursively - unless (File::Copy::move($outfh->filename, $filename)){ + unless (File::Copy::move($outfh->filename, $filename)) { my $r = $!; - unlink $outfh->filename; - error "Can't move C<%s>: %s", $outfh->filename, $r; + unlink $outfh->filename or error "Can't unlink C<%s>: %s", $outfh->filename, $!; + error "Can't move C<%s> to C<%s>: %s", $outfh->filename, $filename, $r; } # TODO: git add $filename; git commit @@ -838,14 +838,13 @@ elsif ($command eq 'edit') { my $id = shift; my $filename = getIdentityFile $id; error "No such identity C<%s>", $id unless -f $filename; - require 'File/Copy.pm'; require 'File/Temp.pm'; error "C<%s> is not set", '$EDITOR' unless defined $ENV{EDITOR}; $ENV{EDITOR} =~ /\A(\p{Print}+)\z/ or error "Insecure C<%s>", "\$EDITOR"; my $EDITOR = $1; # untaint $EDITOR - my $fh = File::Temp->new(SUFFIX => '.yaml', UNLINK => 0, TMPDIR => 1); + my $fh = File::Temp->new(SUFFIX => '.yaml', UNLINK => 0, TMPDIR => 1) or die; END { unlink $fh->filename if defined $fh; } # never leave cleartext lying around loadIdentityFile $filename, $fh; |