mailscanner exim patch

Matthew Byng-Maddick mbm+mailscanner at colondot.net
Mon Feb 2 09:50:39 GMT 2004


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

The attached patch changes the behaviour of mailscanner to deal with exim4
(>4.23) queue files, where ACL variables get stored. Unfortunately, this
part of the queue files doesn't appear to be documented in the Exim
Specification (I'll be posting this to the exim-users list too). Previously,
such queue files would be rejected as invalid, due to the difference in the
way that ACL variables are handled (as a part of the "dashvars" section).
This patch seems to be happy with reading, and re-outputting such queue
files, with ACL data intact.

db93dae7eb0c34468f8324e7a9fd9c71  mailscanner-exim.patch

Although the patch is against MailScanner-4.25-14, I believe it should
also apply cleanly against 4.26.7 (with an offset of 6 lines).

Cheers

Matthew

- -- 
<Ben> hmmm - what's the term that comes between "tweak" and "frob"?
<ti> "small, controlled change"?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (FreeBSD)

iD8DBQFAHh1ciGjP99nB6xERAvtNAJ40AckCXoNcI5Lkwbx/nVerYomU2QCeI6+z
X0+33XN4JeK94hyMnj5VpI8=
=zb6Y
-----END PGP SIGNATURE-----
-------------- next part --------------
diff -uNr lib/MailScanner/Exim.pm.orig lib/MailScanner/Exim.pm
--- lib/MailScanner/Exim.pm.orig	2003-11-26 16:35:29.000000000 +0000
+++ lib/MailScanner/Exim.pm	2004-02-02 09:20:54.000000000 +0000
@@ -244,7 +244,7 @@
   my($RQf) = $message->{store}{inhhandle};
 
   my %metadata;
-  my($InHeader, $InSubject, $InDel, @headers, $msginfo, $from, @to, $subject);
+  my($InHeader, $InSubject, $InDel, @headers, $msginfo, $from, @to, $subject, @acl);
   my($ip, $sender);
   my($line);
 
@@ -276,12 +276,34 @@
   # and tracking them in %{$metadata{dashvars}}
   while (chomp($line = <$RQf>)) {
     $line =~ s/^-(\w+) ?// or last;
-    $metadata{dashvars}{$1} = 0;
-    $line eq "" and $metadata{"dv_$1"} = 1, next;
-    $metadata{"dv_$1"} = $line;
-    $metadata{dashvars}{$1} = 1;
+    if($1 eq "acl") {
+      # we need to handle acl vars differently
+      if($line =~ /^(\d+) (\d+)$/) {
+	my $buf;
+	my $pos=$1;
+	my $len=$2;
+	$acl[$pos]=[];
+	(read($RQf, $buf, $len + 1)==$len+1) or last;
+	if($buf=~/\n$/) {
+	  chomp $buf;
+	} else {
+	  # invalid format
+	  last;
+	}
+	$acl[$pos]->[0]=$buf;
+      } else {
+	# this is a weird format, and we're not sure how to handle it
+	last;
+      }
+    } else {
+      $metadata{dashvars}{$1} = 0;
+      $line eq "" and $metadata{"dv_$1"} = 1, next;
+      $metadata{"dv_$1"} = $line;
+      $metadata{dashvars}{$1} = 1;
+    }
     next;
   }
+  $metadata{aclvars}=\@acl;
 
   # If it was an invalid queue file, log a warning and tell caller
   unless (defined $line) {
@@ -959,6 +981,7 @@
 
 sub CreateQf {
   my($message) = @_;
+  my $i;
 
   my $Qfile = "";
   my $metadata = $message->{metadata};
@@ -986,6 +1009,15 @@
     $Qfile .= "\n";
   }
 
+  # Add the separate ACL Vars
+  my @acl=@{$metadata->{aclvars}};
+  for($i=0; $i<=$#acl; $i++) {
+    if($acl[$i]) {
+      $Qfile .= "-acl " . $i . " " . length($acl[$i]->[0]) . "\n";
+      $Qfile .= $acl[$i]->[0] . "\n";
+    }
+  }
+
   # Add non-recipients
   $Qfile .= BTreeString($metadata->{nonrcpts});
 


More information about the MailScanner mailing list