now decryption in fuse module works
authorHeiko Schlittermann (JUMPER) <hs@schlittermann.de>
Sun, 31 Jul 2011 22:58:30 +0200
changeset 42 b5db10953648
parent 41 6bf98af421f3
child 43 27f0c30c5240
now decryption in fuse module works
bin/imager.fuse
bin/imager.restore
bin/imager.save
--- a/bin/imager.fuse	Sun Jul 31 16:23:14 2011 +0200
+++ b/bin/imager.fuse	Sun Jul 31 22:58:30 2011 +0200
@@ -18,11 +18,13 @@
     debug  => undef,
     detach => 1,
     tmp    => undef,
+    pass   => undef,
 );
 lock_keys %o;
 
 use constant ME => basename $0;
 use constant BS => 4 * 1024;
+use constant CIPHER => "aes-128-cbc";
 
 my ($DATA, $IDX);
 
@@ -47,6 +49,7 @@
         "detach!"  => \$o{detach},
         "tmp:s" => sub { $o{tmp} = length $_[1] ? $_[1] : $ENV{TMP} // "/tmp" },
         "h|help" => sub { pod2usage(-verbose => 1, -exit => 0) },
+	"p|pass=s" => \$o{pass},
         "m|man"  => sub {
             pod2usage(
                 -verbose   => 2,
@@ -227,6 +230,28 @@
                 gunzip($fh => \$cache{data})
                   or die $GunzipError;
             }
+	    elsif (-e "$fn.x") {
+		open(my $fh => "openssl @{[CIPHER]} -d -pass '$o{pass}' -in '$fn.x'|");
+		binmode($fh);
+		local $/ = undef;
+		$cache{data} = <$fh>;
+		close($fh);
+	    }
+	    elsif (-e "$fn.gz.x") {
+		open(my $fh => "openssl @{[CIPHER]} -d -pass '$o{pass}' -in '$fn.gz.x'|");
+		binmode($fh);
+		gunzip($fh => \$cache{data})
+		    or die $GunzipError;
+		close($fh);
+	    }
+	    elsif (-e "$fn.x.gz") {
+		warn "$fn.x.gz is depreciated!\n";
+		open(my $fh => "zcat $fn.x.gz | openssl @{[CIPHER]} -d -pass '$o{pass}'|");
+		binmode($fh);
+		local $/ = undef;
+		$cache{data} = <$fh>;
+		close($fh);
+	    }
             $cache{fn} = $fn;
         }
 
@@ -309,6 +334,20 @@
 
 =over 4
 
+=item B<-d> | B<--debug>
+
+Enables debugging output from B<Fuse>. When using this option,
+B<Fuse> does not detach from the terminal. (default: off)
+
+=item B<-->I<[no]>B<detach> 
+
+Detach or don't detach from the terminal. (default: detach)
+
+=item B<-p> I<pass> | B<--pass>=I<pass>
+
+Password to be used for decryption. For the format please refer
+L<openssl(1)>. (default: not set)
+
 =item B<--tmp> [I<dir/>]
 
 Write dirty blocks into a buffer file in the specified tmp directory.
@@ -317,15 +356,6 @@
 
 B<Beware>: The temporary file may get B<HUUGE>.
 
-=item B<-d>|B<--debug>
-
-Enables debugging output from B<Fuse>. When using this option,
-B<Fuse> does not detach from the terminal. (default: off)
-
-=item B<-->I<[no]>B<detach> 
-
-Detach or don't detach from the terminal. (default: detach)
-
 =item B<-h>|B<--help>
 
 =item B<-m>|B<--man>
--- a/bin/imager.restore	Sun Jul 31 16:23:14 2011 +0200
+++ b/bin/imager.restore	Sun Jul 31 22:58:30 2011 +0200
@@ -142,7 +142,7 @@
 =item B<-p> I<pass> | B<--pass=>I<pass>
 
 In case you expect encrypted data, this option takes the argument for
-B<openssl>'s C<-pass> option. See L<openssl(3)> for mor information.
+B<openssl>'s C<-pass> option. See L<openssl(1)> for mor information.
 (default: stdin)
 
 =item B<-h>|B<--help>
--- a/bin/imager.save	Sun Jul 31 16:23:14 2011 +0200
+++ b/bin/imager.save	Sun Jul 31 22:58:30 2011 +0200
@@ -255,7 +255,7 @@
 =item B<-p> I<pass> | B<--pass>=I<pass>
 
 Use symmetric encryption for writing the data blocks. This option
-is passed to L<openssl(3)>.
+is passed to L<openssl(1)>.
 
 =item B<-z> [I<level>]|B<--compress>[=I<level>]