�&ǐk�@'bJ�h�ۊL'}T� :��'2�Z#$��n�a��� �>a��`��_3d�Qpt�/�P -��#5�,�M��� �pA:©�q�����NW��ډ�A���� �9nʺج���� �TSM��{J6?7��r�@�\����D��� �׶���s�f�TJj?"��D��`?��̒� b�#�%�C*v�$�{�$����5Ծ�F�s��y�e/8��h-�f�̰&(����Gj�L:U� 2�� ����v�_k����Y��gp,�k�WF�R������_C�R��N@���R�@�ߔ?A�w9���F("iNa-S���Q�o�3tDMLh*�#4k�T/iQ��Y*�G��m����)��8�hBm/�I�,g�ﯖ���Z��}�Cz�q@´��d.����L�ŕ�,��1�Z�܌�: ̪���F+J-'��c�tvJ8��]Q-��b��y �6;*J`r_�d ��'�G ~p��)'�C,�%F��E(��2�k�����lР�z�!�=t ��_�0��f7��� ;�p�|�U �%[2] >= $uid_min } @$pwcache_ref ) { ( $user, $uid, $gid, $homedir ) = ( (@$pwref)[ 0, 2, 3, 7 ] ); if ( $homedir ne '/' && -e $homedir . '/.spamassassin' ) { my ( $ok_files, $broken_files ) = _test_sa_dbm_files( $user, $uid, $gid, $homedir ); $user_count++; $ok_count += scalar @$ok_files if $ok_files; $broken_count += scalar @$broken_files if $broken_files; if ( $broken_files && @$broken_files ) { if ( my $pid = fork() ) { waitpid( $pid, 0 ); } else { Cpanel::AccessIds::SetUids::setuids( $uid, $gid ) || die "Failed to setuid to $user"; foreach my $file_data_ref (@$broken_files) { print "\n\t$user: $file_data_ref->{'file'} has problem: $file_data_ref->{'error'}. Moving to $file_data_ref->{'file'}.broken.$now"; rename( $file_data_ref->{'file'}, "$file_data_ref->{'file'}.broken.$now" ); } exit(0); } } } } print "\n" if $broken_count; print "Done\n"; print "Checked " . ( $ok_count + $broken_count ) . " files for $user_count user(s), $ok_count ok, $broken_count broken\n"; sub _test_sa_dbm_files { my ( $user, $uid, $gid, $homedir ) = @_; my $test_files = _get_matching_files( "$homedir/.spamassassin", '(?:bayes_|auto-)[^\.]+$' ); my ( $test_canary, $file, $data, $error ); my ( @ok_files, @broken_files ); @$test_files = grep( !/_journal/, @$test_files ); #special journal file return if !@$test_files; my $loop_count = 0; while ( @$test_files && ++$loop_count <= 5 ) { my $readpid = open( my $child_rdr, '-|' ); if ($readpid) { while (<$child_rdr>) { chomp($_); next if !$_; ( $test_canary, $file, $data, $error ) = split( /:/, $_, 4 ); if ( $test_canary eq $canary ) { if ($file) { @$test_files = grep { $_ ne $file } @$test_files; if ( $data eq 'ok' ) { push @ok_files, { 'file' => $file, 'status' => 1 }; } else { push @broken_files, { 'file' => $file, 'status' => 0, 'error' => "$data:$error" }; } } } else { print STDERR "Error from child process for $user: $_\n"; } #print "DEBUG: $_\n";; } close($child_rdr); } else { alarm(60); Cpanel::Rlimit::set_rlimit($MAX_MEMORY_ALLOWED); Cpanel::AccessIds::SetUids::setuids( $uid, $gid ) || die "Failed to setuid to $user"; while ( my $test_file = pop(@$test_files) ) { print "\n"; my %test_hash; print "${canary}:$test_file:"; if ( ( stat($test_file) )[7] > $MAX_DB_SIZE ) { print "toobig:database too large:\n"; } elsif ( my $result = tie %test_hash, 'DB_File', $test_file, &DB_File::O_RDONLY ) { print "ok\n"; untie %test_hash; } else { print "failed:$!:$result\n"; } print "\n"; } exit(0); } } return ( \@ok_files, \@broken_files ); } # From pkgacct sub _get_matching_files { my $dir = shift; my $regex = shift; my $compiled_regex; eval { $compiled_regex = qr/$regex/; }; if ( !$compiled_regex ) { print "Failed to compile regex $regex\n"; return; } my $dot_files_regex = qr/^\.\.?$/; opendir( my $dir_h, $dir ); my @files = map { "$dir/$_" } grep { $_ !~ $dot_files_regex && $_ =~ $compiled_regex } readdir($dir_h); closedir($dir_h); return \@files; }