From: Dobrica Pavlinusic Date: Sat, 29 Jan 2011 13:46:45 +0000 (+0100) Subject: read protect tar dumps after md5sum calculation X-Git-Url: http://git.rot13.org/?p=BackupPC.git;a=commitdiff_plain;h=0a4689159b1f9dc6d99086cedc54990ab61721b8;ds=sidebyside read protect tar dumps after md5sum calculation This allows operator errors in re-running dumps which have archives allready created, and it seems that pigz produce some amount of fuzzing in archive creation, so md5sums of re-created archives don't match any more (which is bad since we stored them in database for export to CD/DVD image) --- diff --git a/bin/BackupPC_ASA_PostArchive_Update b/bin/BackupPC_ASA_PostArchive_Update index d58f245..475a477 100755 --- a/bin/BackupPC_ASA_PostArchive_Update +++ b/bin/BackupPC_ASA_PostArchive_Update @@ -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: