summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
9f7b563)
With complicated rulesets knowing which rule is responsible for the action
applied to a mail can become complex. Since relevant actions [0] do log a line
when being executed adding the rule's name to this logline should simplify
understanding and debugging complex rules.
Additionally the mix of string interpolation and formatstrings in Quarantine.pm
got unified to formatstrings.
[0] Attach is covered via Notify, Disclaimer and ModField could result in too
verbose logging (i.e. users adding many headers to a mail) without any gain
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
my $subgroups = $mod_group->subgroups($targets, 1);
my $subgroups = $mod_group->subgroups($targets, 1);
+ my $rulename = $vars->{RULE};
+
foreach my $ta (@$subgroups) {
my ($tg, $entity) = (@$ta[0], @$ta[1]);
foreach my $ta (@$subgroups) {
my ($tg, $entity) = (@$ta[0], @$ta[1]);
$msginfo->{xforward}, $msginfo->{fqdn});
if ($qid) {
foreach (@$tg) {
$msginfo->{xforward}, $msginfo->{fqdn});
if ($qid) {
foreach (@$tg) {
- syslog('info', "%s: accept mail to <%s> (%s)", $queue->{logid}, encode('UTF-8', $_), $qid);
+ syslog('info', "%s: accept mail to <%s> (rule: %s, %s)", $queue->{logid}, encode('UTF-8', $_), $rulename, $qid);
}
$queue->set_status ($tg, 'delivered', $qid);
} else {
foreach (@$tg) {
}
$queue->set_status ($tg, 'delivered', $qid);
} else {
foreach (@$tg) {
- syslog('err', "%s: reinject mail to <%s> failed", $queue->{logid}, encode('UTF-8', $_));
+ syslog('err', "%s: reinject mail to <%s> (rule: %s) failed", $queue->{logid}, encode('UTF-8', $_), $rulename);
}
if ($code) {
my $resp = substr($code, 0, 1);
}
if ($code) {
my $resp = substr($code, 0, 1);
my $subgroups = $mod_group->subgroups($targets, 1);
my $subgroups = $mod_group->subgroups($targets, 1);
+ my $rulename = $vars->{RULE};
+
my $bcc_to = PMG::Utils::subst_values($self->{target}, $vars);
if ($bcc_to =~ m/^\s*$/) {
# this happens if a notification is triggered by bounce mails
# which notifies the sender <> - we just log and then ignore it
my $bcc_to = PMG::Utils::subst_values($self->{target}, $vars);
if ($bcc_to =~ m/^\s*$/) {
# this happens if a notification is triggered by bounce mails
# which notifies the sender <> - we just log and then ignore it
- syslog('info', "%s: bcc to <> (ignored)", $queue->{logid});
+ syslog('info', "%s: bcc to <> (rule: %s, ignored)", $queue->{logid}, $rulename);
$msginfo->{xforward}, $msginfo->{fqdn}, 1);
foreach (@bcc_targets) {
if ($qid) {
$msginfo->{xforward}, $msginfo->{fqdn}, 1);
foreach (@bcc_targets) {
if ($qid) {
- syslog('info', "%s: bcc to <%s> (%s)", $queue->{logid}, $_, $qid);
+ syslog('info', "%s: bcc to <%s> (rule: %s, %s)", $queue->{logid}, $_, $rulename, $qid);
- syslog('err', "%s: bcc to <%s> failed", $queue->{logid}, $_);
+ syslog('err', "%s: bcc to <%s> (rule: %s) failed", $queue->{logid}, $_, $rulename);
my ($self, $queue, $ruledb, $mod_group, $targets,
$msginfo, $vars, $marks) = @_;
my ($self, $queue, $ruledb, $mod_group, $targets,
$msginfo, $vars, $marks) = @_;
+ my $rulename = $vars->{RULE};
+
if ($msginfo->{testmode}) {
my $fh = $msginfo->{test_fh};
print $fh "block from: $msginfo->{sender}\n";
if ($msginfo->{testmode}) {
my $fh = $msginfo->{test_fh};
print $fh "block from: $msginfo->{sender}\n";
}
foreach my $to (@$targets) {
}
foreach my $to (@$targets) {
- syslog('info', "%s: block mail to <%s>", $queue->{logid}, encode('UTF-8', $to));
+ syslog('info', "%s: block mail to <%s> (rule: %s)", $queue->{logid}, encode('UTF-8', $to), $rulename);
}
$queue->set_status($targets, 'blocked');
}
$queue->set_status($targets, 'blocked');
+ my $rulename = $vars->{RULE};
+
my $body = PMG::Utils::subst_values($self->{body}, $vars);
my $subject = PMG::Utils::subst_values($self->{subject}, $vars);
my $to = PMG::Utils::subst_values($self->{to}, $vars);
my $body = PMG::Utils::subst_values($self->{body}, $vars);
my $subject = PMG::Utils::subst_values($self->{subject}, $vars);
my $to = PMG::Utils::subst_values($self->{to}, $vars);
if ($to =~ m/^\s*$/) {
# this happens if a notification is triggered by bounce mails
# which notifies the sender <> - we just log and then ignore it
if ($to =~ m/^\s*$/) {
# this happens if a notification is triggered by bounce mails
# which notifies the sender <> - we just log and then ignore it
- syslog('info', "%s: notify <> (ignored)", $queue->{logid});
+ syslog('info', "%s: notify <> (rule: %s, ignored)", $queue->{logid}, $rulename);
$top, $from, \@targets, undef, $msginfo->{fqdn});
foreach (@targets) {
if ($qid) {
$top, $from, \@targets, undef, $msginfo->{fqdn});
foreach (@targets) {
if ($qid) {
- syslog('info', "%s: notify <%s> (%s)", $queue->{logid}, $_, $qid);
+ syslog('info', "%s: notify <%s> (rule: %s, %s)", $queue->{logid}, $_, $rulename, $qid);
- syslog ('err', "%s: notify <%s> failed", $queue->{logid}, $_);
+ syslog ('err', "%s: notify <%s> (rule: %s) failed", $queue->{logid}, $_, $rulename);
my $subgroups = $mod_group->subgroups($targets, 1);
my $subgroups = $mod_group->subgroups($targets, 1);
+ my $rulename = $vars->{RULE};
+
foreach my $ta (@$subgroups) {
my ($tg, $entity) = (@$ta[0], @$ta[1]);
foreach my $ta (@$subgroups) {
my ($tg, $entity) = (@$ta[0], @$ta[1]);
if (my $qid = $queue->quarantine_mail($ruledb, 'V', $entity, $tg, $msginfo, $vars, $ldap)) {
foreach (@$tg) {
if (my $qid = $queue->quarantine_mail($ruledb, 'V', $entity, $tg, $msginfo, $vars, $ldap)) {
foreach (@$tg) {
- syslog ('info', "$queue->{logid}: moved mail for <%s> to virus quarantine - $qid", $_);
+ syslog ('info', "$queue->{logid}: moved mail for <%s> to virus quarantine (rule: %s, %s)", $_, $rulename, $qid);
}
$queue->set_status ($tg, 'delivered');
}
$queue->set_status ($tg, 'delivered');
if (my $qid = $queue->quarantine_mail($ruledb, 'S', $entity, $tg, $msginfo, $vars, $ldap)) {
foreach (@$tg) {
if (my $qid = $queue->quarantine_mail($ruledb, 'S', $entity, $tg, $msginfo, $vars, $ldap)) {
foreach (@$tg) {
- syslog ('info', "$queue->{logid}: moved mail for <%s> to spam quarantine - $qid", $_);
+ syslog ('info', "$queue->{logid}: moved mail for <%s> to spam quarantine (rule: %s, %s)", $_, $rulename, $qid);
}
$queue->set_status($tg, 'delivered');
}
$queue->set_status($tg, 'delivered');
}
sub delete_marked_parts {
}
sub delete_marked_parts {
- my ($self, $queue, $entity, $html, $rtype, $marks) = @_;
+ my ($self, $queue, $entity, $html, $rtype, $marks, $rulename) = @_;
- syslog ('info', "%s: removed attachment $id ('%s')",
- $queue->{logid}, $on);
+ syslog ('info', "%s: removed attachment $id ('%s', rule: %s)",
+ $queue->{logid}, $on, $rulename);
} else {
$self->delete_marked_parts($queue, $part, $html, $rtype, $marks);
} else {
$self->delete_marked_parts($queue, $part, $html, $rtype, $marks);
my ($self, $queue, $ruledb, $mod_group, $targets,
$msginfo, $vars, $marks) = @_;
my ($self, $queue, $ruledb, $mod_group, $targets,
$msginfo, $vars, $marks) = @_;
+ my $rulename = $vars->{RULE};
+
if (!$self->{all} && ($#$marks == -1)) {
# no marks
return;
if (!$self->{all} && ($#$marks == -1)) {
# no marks
return;
$entity->head->delete('x-proxmox-tmp-aid');
}
$entity->head->delete('x-proxmox-tmp-aid');
}
- $self->delete_marked_parts($queue, $entity, $html, $rtype, $marks);
+ $self->delete_marked_parts($queue, $entity, $html, $rtype, $marks, $rulename);
if ($msginfo->{testmode}) {
$entity->head->mime_attr('Content-type.boundary' => '------=_TEST123456') if $entity->is_multipart;
if ($msginfo->{testmode}) {
$entity->head->mime_attr('Content-type.boundary' => '------=_TEST123456') if $entity->is_multipart;
my ($self, $queue, $ruledb, $mod_group, $targets,
$msginfo, $vars, $marks) = @_;
my ($self, $queue, $ruledb, $mod_group, $targets,
$msginfo, $vars, $marks) = @_;
+ my $rulename = $vars->{RULE};
+
my $subgroups = $mod_group->subgroups($targets);
foreach my $ta (@$subgroups) {
my $subgroups = $mod_group->subgroups($targets);
foreach my $ta (@$subgroups) {
+ syslog('info', "%s: report mail as spam (rule: %s)", $queue->{logid}, $rulename);
$queue->set_status ($tg, 'delivered');
}
}
$queue->set_status ($tg, 'delivered');
}
}