Archive Mail feature patches

James A. Pattie james at PCXPERIENCE.COM
Wed Feb 20 18:16:15 GMT 2002


I've attached some patches to add an Archive Mail feature.

mailscanner.conf.patch - adds

Archive Mail = yes/no
Archive Mail Dir = directory to place emails in

archive.patch modifies config.pl and sendmail.pl.
Basically I added a check after the Spam Killer commented out code which
makes a copy of the df and qf files from sendmails incoming queue into
the ArchiveMailDir.  Nothing else is being done to the files yet.

Eventually we would like to see the ability to also archive a
disinfected email so that any programs that process the archive don't
unwittingly re-infect the network when it sends an infected attachment
to someone for closer inspection.

What would it take to make the archive create a single mbox style mail
file or is there a better format to store multiple emails in?  We want
to be able to have a program scan the archived emails for content, etc.
but also allow an administrator to quickly search the archive.  Any
suggestions, comments, etc. are welcome.

--
James A. Pattie
james at pcxperience.com

Linux  --  SysAdmin / Programmer
PC & Web Xperience, Inc.
http://www.pcxperience.com/
-------------- next part --------------
diff -r -u bin/config.pl bin.new/config.pl
--- bin/config.pl       Wed Feb 20 08:33:15 2002
+++ bin.new/config.pl   Wed Feb 20 08:18:17 2002
@@ -118,6 +118,8 @@
 $Config::ScanDomainsFilename        = "$prefix/etc/domains.to.scan.conf";
 $Config::SignUnscannedMessages      = 1;
 $Config::UnscannedHeader            = 'not scanned';
+$Config::ArchiveMail                = 0;
+$Config::ArchiveMailDir             = "/var/spool/mailArchive";

 sub ReadConfig {
   my($Config) = @_;
@@ -145,6 +147,8 @@

     $key = lc($key);
     $key =~ s/[^a-z]//g; # Delete everything except letters
+    $Config::ArchiveMail           = $value if $key =~ /^archivemail$/;
+    $Config::ArchiveMailDir        = $value if $key =~ /^archivemaildir/;
     $Config::Sendmail              = $value if $key =~ /^sendmail(?!2)/;
     $Config::Sendmail2             = $value if $key =~ /^sendmail2/;
     $Config::QuarantineDir         = $value if $key =~ /^quarantine/;
@@ -264,6 +268,7 @@
   $Config::QuarantineAction = 'delete'
     if $Config::QuarantineAction =~ /dele|wipe/i;

+  $Config::ArchiveMail          = ZeroOrOne($Config::ArchiveMail);
   $Config::TellLocalPostie      = ZeroOrOne($Config::TellLocalPostie);
   $Config::TellSenders          = ZeroOrOne($Config::TellSenders);
   $Config::CheckSpam            = ZeroOrOne($Config::CheckSpam);
@@ -292,6 +297,7 @@
   $Config::QuarantineDir =~ s/\/$//;
   $Config::SrcDir        =~ s/\/$//;
   $Config::LockDir       =~ s/\/$//;
+  $Config::ArchiveMailDir =~ s/\/$//;

   # Check to ensure all the directories and files we need actually exist
   DirExists($Config::QuarantineDir);
@@ -299,6 +305,7 @@
   DirExists($Config::InQueueDir);
   DirExists($Config::OutQueueDir);
   DirExists($Config::LockDir);
+  DirExists($Config::ArchiveMailDir) if ($Config::ArchiveMail);
   FileReadable($Config::FilenameRules);
   FileReadable($Config::DisinfectedReportText);
   FileReadable($Config::WhiteListFilename);
diff -r -u bin/sendmail.pl bin.new/sendmail.pl
--- bin/sendmail.pl     Wed Feb 20 08:33:19 2002
+++ bin.new/sendmail.pl Wed Feb 20 08:34:50 2002
@@ -110,6 +110,11 @@
     # Skip it if either fails.
     Lock::openlock($QfFile, "$InQueueDir/$file", "r") or next;

+    # See if we need to Archive the Email
+    if ($Config::ArchiveMail)
+    {
+      system("/bin/cp $InQueueDir/" . MTA::HFileName($id) . " $InQueueDir/" . MTA::DFileName($id) . " $Config::ArchiveMailDir");
+    }
     # Temporary mod for Spam Killer development process.
     #system("/bin/cp $InQueueDir/qf$id $InQueueDir/df$id /export/2/var/spam/queue")
     #  if (-s "$InQueueDir/df$id") <= 1000000 && $Config::Hostname =~ /magpie/i;
-------------- next part --------------
--- mailscanner.conf    Tue Feb 12 08:31:29 2002
+++ mailscanner.conf.rpmsave    Wed Feb 20 08:31:28 2002
@@ -283,6 +283,11 @@
 # MAPS lists.
 Spam White List = /usr/local/MailScanner/etc/spam.whitelist.conf

+# Do you want all email coming into the system archived?
+Archive Mail = 1
+# Specify where the archived email should be placed.
+Archive Mail Dir = /var/spool/mailArchive
+
 #
 # Advanced Features
 # =================


More information about the MailScanner mailing list