read protect tar dumps after md5sum calculation
[BackupPC.git] / bin / BackupPC_ASA_PostArchive_Update
index 50d9cc9..475a477 100755 (executable)
@@ -140,8 +140,11 @@ sub check_archive {
        my $md5_path = "$Conf{ArchiveDest}/$host.$num.md5";
        unlink $md5_path if -s $md5_path == 0; # fix empty
 
+       my $read_protect = 0;
+
        if ( ! -e $md5_path ) {
                system_ok "cd $Conf{ArchiveDest} && /usr/bin/md5sum $host.$num.* > $md5_path";
+               $read_protect = 1;
        } else {
                system_ok "cd $Conf{ArchiveDest} && /usr/bin/md5sum -c $md5_path" if $opt->check;
        }
@@ -150,6 +153,12 @@ sub check_archive {
        foreach ( split(/\n/, read_file "$Conf{ArchiveDest}/$host.$num.md5" ) ) {
                my ( $md5, $path ) = split(/\s+/,$_);
                $md5sum->{$path} = $md5;
+               if ( $read_protect ) {
+                       my $full = "$Conf{ArchiveDest}/$path";
+                       my $perm = (stat $full)[2] & 0444;
+                       warn sprintf("chmod %03o %s\n",$perm,$full);
+                       chmod $perm, $full;
+               }
        }
 
        # depending on expected returned value this is used like:
@@ -264,8 +273,8 @@ sub check_archive {
                        $items++;
                        $tar_size_inarc += $entry->size;
 
-                       if ($tar_size_inarc > $Conf{ArchiveChunkSize}) {
-                               print ", part $filename is too big $tar_size_inarc > $Conf{ArchiveChunkSize}\n";
+                       if ($tar_size_inarc > $Conf{ArchiveMediaSize}) {
+                               print ", part $filename is too big $tar_size_inarc > $Conf{ArchiveMediaSize}\n";
                                return 0;
                        }