[pmg-devel] [PATCH pmg-api 04/10] MailQueue: prepare for attachment quarantine

Dominik Csapak d.csapak at proxmox.com
Thu Sep 26 12:28:08 CEST 2019


create the spooldir for the attachment quarantine, as well as
allow quarantining into it

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 src/PMG/MailQueue.pm | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/src/PMG/MailQueue.pm b/src/PMG/MailQueue.pm
index 61cb166..e0f56b9 100644
--- a/src/PMG/MailQueue.pm
+++ b/src/PMG/MailQueue.pm
@@ -25,15 +25,24 @@ sub create_spooldirs {
 
     # if requested, remove any stale date
     File::Path::remove_tree(
-	"$spooldir/cluster", "$spooldir/active",
-	"$spooldir/virus", "$spooldir/spam") if $cleanup;
+	"$spooldir/cluster",
+	"$spooldir/active",
+	"$spooldir/virus",
+	"$spooldir/spam",
+	"$spooldir/attachment",
+    ) if $cleanup;
 
     File::Path::make_path(
-	"$spooldir/active", "$spooldir/spam", "$spooldir/virus");
+	"$spooldir/active",
+	"$spooldir/spam",
+	"$spooldir/virus",
+	"$spooldir/attachment",
+    );
 
     if ($lcid) {
 	mkpath "$spooldir/cluster/$lcid/virus";
 	mkpath "$spooldir/cluster/$lcid/spam";
+	mkpath "$spooldir/cluster/$lcid/attachment";
     }
 }
 
@@ -254,6 +263,12 @@ sub fsync_file_and_dir {
 
 }
 
+my $subpath_map = {
+    'V' => 'virus',
+    'S' => 'spam',
+    'A' => 'attachment',
+};
+
 sub quarantine_mail {
     my ($self, $ruledb, $qtype, $entity, $tg, $msginfo, $vars, $ldap) = @_;
 
@@ -261,7 +276,7 @@ sub quarantine_mail {
 
     my $header = extract_header_text ($entity);
 
-    my $subpath = $qtype eq 'V' ? 'virus' : 'spam';
+    my $subpath = $subpath_map->{$qtype} // 'spam';
 
     my $lcid = $msginfo->{lcid};
 
-- 
2.20.1




More information about the pmg-devel mailing list