diff -r f361d688365c -r cb50d6c57439 bin/imager.restore --- a/bin/imager.restore Fri Jul 29 16:06:55 2011 +0200 +++ b/bin/imager.restore Sun Jul 31 15:03:06 2011 +0200 @@ -16,12 +16,17 @@ use autodie qw(:all); use Pod::Usage; use Getopt::Long; +use Hash::Util qw(lock_keys); use IO::Uncompress::Gunzip qw(gunzip $GunzipError); use constant KiB => 1024; use constant MiB => 1024 * KiB; use constant GiB => 1024 * MiB; use constant ME => basename $0; +use constant CIPHER => "aes-128-cbc"; + +my %o = (pass => "stdin"); +lock_keys(%o); sub find_data_dir; @@ -29,8 +34,9 @@ Getopt::Long::Configure(qw(Bundling)); GetOptions( - "h|help" => sub { pod2usage(-verbose => 1, -exit => 0) }, - "m|man" => sub { + "p|pass=s" => \$o{pass}, + "h|help" => sub { pod2usage(-verbose => 1, -exit => 0) }, + "m|man" => sub { pod2usage( -verbose => 2, -exit => 0, @@ -66,7 +72,7 @@ if (-f "$data/$path") { open($in => "$data/$path"); binmode($in); - local $/ = \$blocksize; + local $/ = undef; $buffer = <$in>; } elsif (-f "$data/$path.gz") { @@ -75,6 +81,26 @@ gunzip($in => \$buffer) or die $GunzipError; } + elsif (-f "$data/$path.x") { + open($in, "openssl @{[CIPHER]} -d -pass $o{pass} -in '$data/$path.x'|"); + binmode($in); + local $/ = undef; + $buffer = <$in>; + } + elsif (-f "$data/$path.x.gz") { + warn "$data/$path.x.gz: depreciated!\n"; + open($in, + "gzip -d -c $data/$path.x.gz | openssl bf -d -pass $o{pass}|"); + binmode($in); + local $/ = undef; + $buffer = <$in>; + } + elsif (-f "$data/$path.gz.x") { + open($in, "openssl bf -d -pass $o{pass} -in $data/$path.gz.x|"); + binmode($in); + gunzip($in => \$buffer) + or die $GunzipError; + } else { die ME . ": Can't open $data/$path: $!\n"; } @@ -100,7 +126,7 @@ =head1 SYNOPSIS - imager.restore {idx} {destination} + imager.restore [options] {idx} {destination} =head1 DESCRIPTION @@ -108,5 +134,22 @@ cats them as one data stream. The destination can be any block device, a file name or even B<-> (STDOUT). +=head1 OPTIONS + +=over + +=item B<-p> I | B<--pass=>I + +In case you expect encrypted data, this option takes the argument for +B's C<-pass> option. See L for mor information. +(default: stdin) + +=item B<-h>|B<--help> + +=item B<-m>|B<--man> + +The standard help options. + +=back =cut