]>
git.proxmox.com Git - pmg-api.git/blob - src/PMG/SACustom.pm
9 my $shadow_path = "/var/cache/pmg-scores.cf";
10 my $conf_path = "/etc/mail/spamassassin/pmg-scores.cf";
17 rename($shadow_path, $conf_path) if -f
$shadow_path;
25 foreach my $rule (sort keys %$data) {
26 my $score = $data->{$rule}->{score
};
27 my $comment = $data->{$rule}->{comment
} // "";
28 $raw .= "$rule$score$comment";
31 my $digest = Digest
::SHA
::sha1_hex
($raw);
35 PVE
::INotify
::register_file
('pmg-scores.cf', $conf_path,
39 always_call_parser
=> 1,
40 shadow
=> $shadow_path,
44 my ($filename, $fh) = @_;
50 while (defined(my $line = <$fh>)) {
52 next if $line =~ m/^\s*$/;
53 if ($line =~ m/^# ?(.*)\s*$/) {
57 if ($line =~ m/^score\s+(\S+)\s+(\S+)\s*$/) {
67 warn "parse error in '$filename': $line\n";
77 my ($filename, $fh, $scores) = @_;
80 foreach my $rule (sort keys %$scores) {
81 my $comment = $scores->{$rule}->{comment
};
82 my $score = sprintf("%.3f", $scores->{$rule}->{score
});
83 $content .= "# $comment\n" if defined($comment) && $comment !~ m/^\s*$/;
84 $content .= "score $rule $score\n";
86 PVE
::Tools
::safe_print
($filename, $fh, $content);