[PATCH 4/7] Reimplement encryption

Michael Hanselmann public at hansmi.ch
Wed Aug 13 21:15:59 UTC 2008


From: Michael Hanselmann <hansmi at hansmi-mac-zrh.local>

Currently, it's only synchronous. Hopefully, further changes will allow
me to make it sort-of asynchronous again.
---
 lib/Brackup/Backup.pm |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/lib/Brackup/Backup.pm b/lib/Brackup/Backup.pm
index b1ab7bc..5ec0945 100644
--- a/lib/Brackup/Backup.pm
+++ b/lib/Brackup/Backup.pm
@@ -134,7 +134,9 @@ sub _emit_file {
 
 sub _emit_chunk {
     my ($self, $rec) = @_;
-    my $merge_under = $self->{parent}->{root}->merge_files_under;
+    my $root = $self->{parent}->{root};
+    my $merge_under = $root->merge_files_under;
+    my $gpg_rcpt = $root->gpg_rcpt;
 
     if ($rec->isa("Brackup::File")) {
         $self->start_file($rec);
@@ -175,6 +177,10 @@ sub _emit_chunk {
     unless ($self->{dryrun}) {
         $schunk = Brackup::StoredChunk->new($pchunk);
 
+        if ($gpg_rcpt) {
+            $schunk->set_encrypted_chunkref($root->encrypt($pchunk->raw_chunkref));
+        }
+
         # see if we should pack it into a bigger blob
         my $chunk_size = $schunk->backup_length;
 
@@ -235,6 +241,8 @@ sub end_file {
     $self->{modecounts}{$file->type}{$file->mode}++;
 
     $self->{cur_file} = undef;
+
+    $self->_write_meta();
 }
 
 sub _write_meta {
@@ -339,6 +347,10 @@ sub backup_header {
         $ret .= "DefaultDirMode: " . $self->default_directory_mode . "\n";
     }
 
+    if (my $rcpt = $root->gpg_rcpt) {
+        $ret .= "GPG-Recipient: $rcpt\n";
+    }
+
     return "$ret\n";
 }
 
-- 
1.5.5.3



More information about the brackup mailing list