From: Dobrica Pavlinusic Date: Sat, 29 Jan 2011 14:54:49 +0000 (+0100) Subject: make md5sums read-only X-Git-Url: http://git.rot13.org/?p=BackupPC.git;a=commitdiff_plain;h=796b15687f42564a63e80496b2c0daa641e7567d make md5sums read-only --- diff --git a/bin/BackupPC_ASA_PostArchive_Update b/bin/BackupPC_ASA_PostArchive_Update index 475a477..93478c9 100755 --- a/bin/BackupPC_ASA_PostArchive_Update +++ b/bin/BackupPC_ASA_PostArchive_Update @@ -120,6 +120,13 @@ my $sth_inc_size = $dbh->prepare(qq{ where id = ? }); +sub read_only { + my $full = shift; + my $perm = (stat $full)[2] & 0444; + warn sprintf("chmod %03o %s\n",$perm,$full); + chmod $perm, $full || die $!; +} + sub check_archive { my ($host,$num) = @_; warn "# check_archive $host $num"; @@ -144,6 +151,7 @@ sub check_archive { if ( ! -e $md5_path ) { system_ok "cd $Conf{ArchiveDest} && /usr/bin/md5sum $host.$num.* > $md5_path"; + read_only $md5_path; $read_protect = 1; } else { system_ok "cd $Conf{ArchiveDest} && /usr/bin/md5sum -c $md5_path" if $opt->check; @@ -153,12 +161,7 @@ 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; - } + read_only "$Conf{ArchiveDest}/$path" if $read_protect; } # depending on expected returned value this is used like: