Hi,

We, at Lerkins Group have used amavisd-new for our anti-spam & anti-virus 
cluster, and we
have found that that would be very usable to have the ability to resend the 
message
that came from host X to host Y, based on config specified in amavisd.conf.

As there was no such ability in amavisd-new we have developed a patch for 
amavisd, that
enables such feature very easily while giving the ability to keep old behaviour
untouched. 

Now the question is, would it be possible to incorporate this patch to amavisd
official release, so anybody could use it, and also it would be easier to 
maintain amavisd
after using that patch (right now if we want to upgrade, we have to apply this 
patch afer
prebuild stage of FreeBSD port on each machine)?

The patch is pasted below. Thanks a lot for any reply.


Kind regards
-- 
Bartłomiej Rutkowski <[EMAIL PROTECTED]>



--- amavisd.original    2006-08-17 13:18:43.000000000 +0200
+++ amavisd.patched     2006-08-22 12:25:56.000000000 +0200
@@ -2277,9 +2277,71 @@
   ($proc_fh, $pid);  # return pipe file handle to the subprocess and its PID
 }
 
+# This sub gets two params 1st one is new format of $forward_method
+#      smtp: { [smtphellohost1.mydomain]   ->      [10.10.3.13]:10025;         
                
+#               [smtphellohost2.mydomain]    ->     [10.10.3.12]:10025      }
+#      second one is smtphelo host for which we are looking forward_method
+# in result we get:
+#       string smtp:[10.10.3.13]:10025 for smtphellohost1.mydomain
+#       string smtp:[10.10.3.12]:10025 for smtphellohost2.mydomain
+#       empty string for anything else
+sub getmethod4smtphelo($$){
+    my($method,$smtphelo) = @_;
+    my($returnmethod)="";
+    my(%dynforw_host); #here we keep assoc. table host where e-mail has to be 
forwarded 
+    my(%dynforw_port); #as %dynforw_host but for ports
+    my($innermethod, @fortab, $temp, $hellosource, $forwardhost, $forwardport);
+            
+    $method =~ /(^[ ,\t]*smtp:[ ,\t]*{[ ,\t]*) (.+) ([ ,\t]*\})/xis;
+    $innermethod=$2; #we are getting rid of smtp:{ and } at the end;
+
+    if ($innermethod ne ''){
+       $innermethod =~ s/[\s]+//gis;
+    @fortab = split(/\;/gis, $innermethod); #table of forwads
+       foreach $temp (@fortab) {
+           #every row has the following statement 
+           #[smtphellohost.mydomain]->[10.10.3.13]:10025
+           $temp =~/\[(.*)\]\->\[(.*)\]:(\d*)/gis;
+           $hellosource = $1;
+           $forwardhost = $2;
+           $forwardport = $3;
+
+           #we have two association tables where we keep 
+           #host and ports where the messages should be fowarded
+           $dynforw_host{$hellosource}=$forwardhost;
+           $dynforw_port{$hellosource}=$forwardport;
+       }#foreach
+    }#if ($innermethod ne '')
+
+    if ($dynforw_host{$smtphelo} ne '' && $dynforw_port{$smtphelo} ne ''){
+          $returnmethod = sprintf("smtp:[%s]:%s",$dynforw_host{$smtphelo}, 
$dynforw_port{$smtphelo});
+    }else{
+          $returnmethod = '';
+    }
+    
+    $returnmethod = Amavis::Util::untaint($returnmethod);
+    $returnmethod;
+}
+
+
 sub dynamic_destination($$$) {
   my($method,$conn,$force_dynamic) = @_;
   my($client_ip) = !defined($conn) ? undef : $conn->client_ip;
+  my($smtp_helo) = !defined($conn) ? undef : $conn->smtp_helo;
+  my($new_formethod) = "";
+   
+  if ($method =~ /^smtp:\{/i) { #new format of forward method    
+    $method = sprintf("%s", getmethod4smtphelo($method, $smtp_helo));
+    $new_formethod = $method;
+    if ($new_formethod eq ""){
+        do_log(-1, "Something wrong with forward_method=$method. I can't find 
host to forward for smtp_helo=$smtp_helo");
+    }else{
+        do_log(1, "I changed forward_method basing on smtp_helo=$smtp_helo. 
New method is $new_formethod");
+        $method=$new_formethod;
+        
+    }
+  }  
+  
   if ($method =~ /^[A-Za-z0-9]*:/) {
     my(@list); $list[0] = ''; my($j) = 0;
     for ($method =~ /\G \[ (?: \\. | [^\]\\] )* \] | " (?: \\. | [^"\\] )* "
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
AMaViS-user mailing list
AMaViS-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/amavis-user
AMaViS-FAQ:http://www.amavis.org/amavis-faq.php3
AMaViS-HowTos:http://www.amavis.org/howto/

Reply via email to