Hi,
I'm a technician and I work in an IT society. We offer web hosting and
e-mail hosting.
Our mail server is Qmail which controls the virtual domains through
vpopmail. While using Spamassassin to eliminate spam messages, we
noticed some errors.
These bugs have already been reported as:
bug 2536 <http://issues.apache.org/SpamAssassin/show_bug.cgi?id=2536>,
bug 4568 <http://issues.apache.org/SpamAssassin/show_bug.cgi?id=4568>,
bug 4714 <http://issues.apache.org/SpamAssassin/show_bug.cgi?id=4714>,
bug 3120 <http://issues.apache.org/SpamAssassin/show_bug.cgi?id=3120>
and bug 2866.
<http://issues.apache.org/SpamAssassin/show_bug.cgi?id=2866> .
The errors regarding the alias have become critical with the
Spamassassin 3.2.1 and PERL 5.8.8. In the case of multiple aliases the
e-mail wouldn't be tested by Spamassassin.
For this reason I wrote a patch for Spamassassin 3.2.1. which should
solve the problems with the aliases. The patch searches for the first
real recipient it finds in the .qmail files. It looks through every
alias until it finds the first local recipient and sets the home
directory in this user in order to create the user_prefer.
There's a command in the patch to avoid indefinite iterations (eg.
alias1->alias2->alias1...). If it doesn't find real users (for example
if it only finds forwards to other programs or remote em-mails and not
local domains), from home directory it gets set to undefined.
This patch should solve the bug
4568<http://issues.apache.org/SpamAssassin/show_bug.cgi?id=4568> and the
bug 4714 <http://issues.apache.org/SpamAssassin/show_bug.cgi?id=4714>.
We tested the patch for about 1 year on the Spamasassin 3.2.1 and now we
testing on the Spamassassin 3.2.5. On the production server seems work
fine.
Since I'm a new PERL user I apologize in advance if I haven't followed
the style rules elected from the Spamassassin dev team. So I beg you to
let me know eventual style errors in order to able to correct them.
I also kindly ask you to include the patch in the following versions of
Spamassassin.

Thanks

--
Sossi Andrej
-------------------------
DotCom Information technology

Via Biancospino, 9
34151 - Opicina (TS)
Italy

tel: +39 040 2158191
fax: +39 040 0641954
E-mail: [email protected]
----------------------------

Ai sensi del D.lgs n. 196 del 30.06.03 (Codice Privacy) si precisa che le informazioni contenute in questo messaggio sono riservate e ad uso esclusivo del destinatario. Qualora il messaggio in parola Le fosse pervenuto per errore, La preghiamo di eliminarlo senza copiarlo e di non inoltrarlo a terzi, dandocene gentilmente comunicazione. Grazie

This message, for the D.lgs n. 196 / 30.06.03 (Privacy Code), may contain confidential and/or privileged information. If you are not the addressee or authorized to receive this for the addressee, you must not use, copy, disclose or take any action based on this message or any information herein. If you have received this message in error, please advise the sender immediately by reply e-mail and delete this message. Thank you for your cooperation.
--- spamd.orig  2009-01-22 13:29:03.000000000 +0100
+++ spamd       2009-01-23 13:43:03.000000000 +0100
@@ -2099,20 +2099,79 @@
   # If vpopmail config enabled then set $dir to virtual homedir
   #
   if ( $opt{'vpopmail'} ) {
+    #
+    # Patched by Hrast
+    #
     my $vpopdir = $dir;
-    $dir = `$vpopdir/bin/vuserinfo -d \Q$username\E`;
-    if ($? != 0) {
-      #
-      # If vuserinfo failed $username could be an alias
-      #
-      $dir = `$vpopdir/bin/valias \Q$username\E`;
-      if ($? == 0 && $dir !~ /.+ -> &/) {
-        $dir =~ s,.+ -> (/.+)/Maildir/,$1,;
+    my ($vpopemail, @vpopemail, $vpopalias, @vpopalias, @todo, $work);
+    @vpopemail=(); @todo=();
+    while () {
+      push(@vpopemail, $username);
+      $dir = `$vpopdir/bin/vuserinfo -d \Q$username\E`;
+      if ($? == 0) {
+        #
+        # Valid username found
+       #
+        chomp($dir);
+        last;
       } else {
+        #
+        # If vuserinfo failed $username could be an alias
+        #
         undef($dir);
+        $vpopalias = `$vpopdir/bin/valias \Q$username\E`;
+        if ($? == 0) {
+          @vpopalias = split(/\n/, $vpopalias);
+          @todo=(@vpopalias, @todo);
+        }
+        while (defined ($work=shift(@todo))) {
+          if ($work =~ /^.+ -> \/.+\/Maildir\/$/) {
+            #
+            # This is the path to real mail box
+            #
+            $work =~ s,^.+ -> (/.+)/Maildir/$,$1,;
+            $dir = $work;
+            last;
+          } elsif ($work =~ /^.+ -> 
[a-z0-9_-]+(\.[a-z0-9_-]+)*...@[a-z0-9_-]{2,}(\.[a-z0-9_-]+)*\.[a-z]{2,4}$/) {
+            #
+            # This is the forward to the new e-mail address
+            # Need to test if is local address (real or another alias)
+            #
+            my $processed;
+            $processed='';
+            $work =~ m/^.+ -> 
([a-z0-9_-]+(\.[a-z0-9_-]+)*...@[a-z0-9_-]{2,}(\.[a-z0-9_-]+)*\.[a-z]{2,4})$/;
+            $work = $1;
+            foreach(@vpopemail) {
+            #
+            # Test if mail address is already processed
+            #
+              if ($_ eq $work) {
+                # address already processed
+                # possible loop forward or multiple forward
+                $processed = $_;
+                last;
+              }
+            }
+            if ($processed eq '') {
+              $username = $work;
+              last;
+            }
+          }
+        }
+      last if (defined $dir);
+      }
+      if ($#todo == -1 && $work !~ 
/[a-z0-9_-]+(\.[a-z0-9_-]+)*...@[a-z0-9_-]{2,}(\.[a-z0-9_-]+)*\.[a-z]{2,4}/) {
+        #
+        # If todo list is empty mean real user does't exist.
+        # Possible forward to remote user and/or to program.
+        #
+       undef($dir);
+       last;
       }
     }
-    chomp($dir);
+    #
+    # end patch Hrast
+    #
   }
 
   # don't do this if we weren't passed a directory

Reply via email to