}
sub new {
- my ($type, $all, $text, $ogroup) = @_;
+ my ($type, $all, $text, $ogroup, $quarantine) = @_;
my $class = ref($type) || $type;
$self->{all} = $all;
$self->{text} = $text;
+ $self->{quarantine} = $quarantine;
return $self;
}
my $obj;
- if ($value =~ m/^([01])(\:(.*))?$/s) {
+ if ($value =~ m/^([01])\,([01])(\:(.*))?$/s) {
+ $obj = $class->new($1, $4, $ogroup, $2);
+ } elsif ($value =~ m/^([01])(\:(.*))?$/s) {
$obj = $class->new($1, $3, $ogroup);
} else {
$obj = $class->new(0, undef, $ogroup);
defined($self->{ogroup}) || die "undefined ogroup: ERROR";
my $value = $self->{all} ? '1' : '0';
+ $value .= ','. ($self->{quarantine} ? '1' : '0');
if ($self->{text}) {
$value .= ":$self->{text}";
sub execute {
my ($self, $queue, $ruledb, $mod_group, $targets,
- $msginfo, $vars, $marks) = @_;
+ $msginfo, $vars, $marks, $ldap) = @_;
my $rulename = $vars->{RULE} // 'unknown';
my $html = PMG::Utils::subst_values($self->{text}, $vars);
- $html = "This attachment was removed: __FILENAME__\n" if !$html;
+ if (!$html) {
+ $html = "This attachment was removed: __FILENAME__\n";
+ $html .= "It was put into the Attachment Quarantine, please contact your Administrator\n" if $self->{quarantine};
+ }
my $rtype = "text/plain";
foreach my $ta (@$subgroups) {
my ($tg, $entity) = (@$ta[0], @$ta[1]);
+ # copy original entity to attachment quarantine if configured
+ if ($self->{quarantine}) {
+ my $original_entity = $entity->dup;
+ PMG::Utils::remove_marks($original_entity);
+ if (my $qid = $queue->quarantine_mail($ruledb, 'A', $original_entity, $tg, $msginfo, $vars, $ldap)) {
+ foreach (@$tg) {
+ syslog ('info', "$queue->{logid}: moved mail for <%s> to attachment quarantine - %s (rule: %s)", $_, $qid, $rulename);
+ }
+ }
+ }
+
# handle singlepart mails
my $ctype = $entity->head->mime_type;
if (!$entity->is_multipart && (!$self->{all} || $ctype !~ m|text/.*|i)) {
type => 'boolean',
optional => 1,
},
+ quarantine => {
+ description => "Copy original mail to attachment Quarantine.",
+ type => 'boolean',
+ default => 0,
+ optional => 1,
+ },
text => {
description => "The replacement text.",
type => 'string',
return {
text => $self->{text},
all => $self->{all},
+ quarantine => $self->{quarantine},
};
}
$self->{text} = $param->{text};
$self->{all} = $param->{all} ? 1 : 0;
+ $self->{quarantine} = $param->{quarantine} ? 1 : 0;
}
1;