--- /usr/share/perl5/Razor2/Client/Core.pm.orig	2009-04-21 09:09:31.000000000 +0200
+++ /usr/share/perl5/Razor2/Client/Core.pm	2009-04-21 09:10:38.000000000 +0200
@@ -902,6 +902,22 @@
 sub check { 
     my ($self, $objects) = @_;
 
+    # HOSTALIA 
+    #
+    # Alvaro Marin <alvaro@hostalia.com> - April 17th, 2009
+    #
+    # Support for ehash/sha1 whitelisting - we mantain the whitelist format:
+    # http://www.netfrag.org/cgi-bin/dwww/usr/share/man/man5/razor-whitelist.5.gz?type=man
+    #
+    # Vipul's message:
+    # http://www.mail-archive.com/razor-users@lists.sourceforge.net/msg02612.html
+    #
+    # --
+    # We get the whitelisted hashes
+    my %hash_w=%{$self->{whitelist}};
+    my $is_whitelisted=0;
+    # /HOSTALIA
+
     my $valid = 0;
     foreach my $obj (@$objects) {
         next if $obj->{skipme}; 
@@ -953,6 +969,18 @@
                     }
                 } else { 
                     $self->log(8,"mail $objp->{id} e$engine_save sig: $sig");
+                    # HOSTALIA we see if the hash is whitelisted
+                    for (keys %hash_w){
+			if ($_ eq "sha1"){
+				for (@{$hash_w{$_}}){
+					if ($sig eq $_){
+                                        	$self->log (5,"Hash whitelisted: $sig = $_");
+                                        	$is_whitelisted=1;
+                                	}
+                        	}
+                    	}
+                    }
+                    # /HOSTALIA
                 }
 
                 my $query = $self->make_query( {
@@ -994,6 +1022,10 @@
         #
         $self->check_logic($obj);
 
+        # HOSTALIA
+        if ($is_whitelisted) {$obj->{spam} = 0;}
+        # /HOSTALIA
+
         $self->log (3,"mail $obj->{id} is ". ($obj->{spam} ? '' : 'not ') ."known spam.");
     }
     return 1;


