X-Git-Url: http://git.rot13.org/?p=BackupPC.git;a=blobdiff_plain;f=bin%2FBackupPC_ASA_PostArchive_Update;h=93478c985afbe71e8a82da6b982f75c75567e35b;hp=475a4778e529e9842c66325e0b16f9d1566d4e4c;hb=796b15687f42564a63e80496b2c0daa641e7567d;hpb=0a4689159b1f9dc6d99086cedc54990ab61721b8 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: