CustomFunction: ArchiveSAtimeout

paddy paddy at PANICI.NET
Thu Nov 25 13:36:41 GMT 2004


Hi,

# ArchiveSAtimeout
#
# This is a custom function to archive any message which happens
# to be subject to an SA timeout.  It is probably not very useful.
#
#       IF YOU HAVE PROBLEMS WITH SA TIMEOUTS,
#   THIS IS PROBABLY **NOT** THE CODE YOU ARE LOOKING FOR ...
#
# Instead see previous discussions on the mailing list which
# will direct you towards _fruitful_ investigations: bayes,
# network timeouts, how to use Debug Spamassassin, big rules, etc.
#
# This code is derived from MailScanner, Copyright Julian Field.
# Licensed under the GNU General Public License v.2 or later.
#
# I, Paddy, can confidently lay claim to all the _faults_ herein.
# In particularly, note that this CF has not been extensively tested.
# There is no waranty: you get to keep the pieces.
# But feel free to email me.  Feedback & improvements especially welcome.
#
# paddy at panici.net 2004

package MailScanner::CustomConfig;

my $ASATsatimedout;

sub InitArchiveSAtimeout {
  $ASATsatimedout = MailScanner::Config::LanguageValue($message, 'satimedout');
  MailScanner::Log::InfoLog("InitArchiveSAtimeout: looking for '%s'",$ASATsatimedout);
}

sub EndArchiveSAtimeout {
  MailScanner::Log::InfoLog("EndArchiveSAtimeout");
}

sub ArchiveSAtimeout {
my($message)= @_;

  my $spamreport = $message->{spamreport};
  $spamreport =~ s/\n/ /g;
  $spamreport =~ s/\t//g;

  #MailScanner::Log::InfoLog("ArchiveSAtimeout: %s",$spamreport);

  if ($spamreport =~ /$ASATsatimedout/){
    StoreSAtimeout($message);
    my $id = $message->{id};
    MailScanner::Log::InfoLog("ArchiveSAtimeout: %s archived",$id);
  #}else{
  #  #do nothing
  #  my $id = $message->{id};
  #   MailScanner::Log::InfoLog("ArchiveSAtimeout: %s no action",$id);
  }
  return 0;
}

sub StoreSAtimeout {
my($message)= @_;

  my($dir, $dir2, $spamdir, $uid, $gid, $changeowner);
  $uid = $global::MS->{quar}->{uid};
  $gid = $global::MS->{quar}->{gid};
  $changeowner = $global::MS->{quar}->{changeowner};
  $dir = MailScanner::Config::Value('quarantinedir', $message);
  $dir2 = $dir . '/' .  MailScanner::Quarantine::TodayDir();
  $spamdir = $dir2 . '/' . 'satimeouts';
  umask $global::MS->{quar}->{dirumask};
  unless (-d $dir) {
    mkdir $dir, 0777;
    chown $uid, $gid, $dir if $changeowner;
  }
  unless (-d $dir2) {
    mkdir $dir2, 0777;
    chown $uid, $gid, $dir2 if $changeowner;
  }
  unless (-d $spamdir) {
  mkdir $spamdir, 0777;
    chown $uid, $gid, $spamdir if $changeowner;
  }
  #print STDERR "Storing spam to $spamdir/" . $message->{id} . "\n";
  #print STDERR "uid=$uid gid=$gid changeowner=$changeowner\n";
  umask $global::MS->{quar}->{fileumask};
  $message->{store}->CopyEntireMessage($message, $spamdir, $message->{id},
                                    $uid, $gid, $changeowner);
  chown $uid, $gid, "$spamdir/" . $message->{id}; # Harmless if this fails
}

1;

------------------------ MailScanner list ------------------------
To unsubscribe, email jiscmail at jiscmail.ac.uk with the words:
'leave mailscanner' in the body of the email.
Before posting, read the MAQ (http://www.mailscanner.biz/maq/) and
the archives (http://www.jiscmail.ac.uk/lists/mailscanner.html).

Support MailScanner development - buy the book off the website!




More information about the MailScanner mailing list