Re: hashcash addition for qmail scanner

"JHolder" <[email protected]>
Newsgroups gmane.mail.qmail.scanner
Message-ID <[email protected]>
JHolder said:
<SNIP>
> I have been running qmail scanner for a while, and I had the idea of using
> it to add hashcash headers to outgoing emails.  I got most of the way
> through creating the code to do this when I realized spamassassin (with
> some configuration) might already have a means of doing this.  Is this
> indeed possible?  If it is not, is anyone interested in this
> functionality?
<SNIP>

I got back to look at this again this afternoon, and decided to edit the
qmail_reque function instead.  I have a couple of questions if anyone is
willing to entertain me with answers.

First, is the method I used to split up addresses safe?
Second, is the place where I print out the hashcash headers ok?

Please find attached patch which applies cleanly to qmail-scanner-2.01:

-------------------------------------------------------------------------
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/

_______________________________________________
Qmail-scanner-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qmail-scanner-general
add-hashcash-qmailscanner.patch (application/octet-stream, 1.7 KB)
--- qmail-scanner-2.01/qmail-scanner-queue.template	2006-04-04 02:00:17.000000000 +0000
+++ hashcash-patch/qmail-scanner-queue.template	2007-05-30 22:21:12.000000000 +0000
@@ -1417,6 +1417,29 @@
   my($sender,$env_recips,$msg)=@_;
   my ($temp,$findate);
 
+  # This is the first version of hashcash that is still in testing
+  my $dohashcash = "1";
+  my $addhashcashheader = "1";  
+  my $hashcashcmd = "/usr/bin/hashcash -m -X ";
+  my $hashheaders = "";
+
+  if ($dohashcash) {
+     &debug("Starting HASHCASH creation function");
+
+     #compute hashcash for all addresses that are not bound for this server
+     my ($hashaddr,$addr,$dom) = "";     
+     # is this a safe way to split?  It works so far for my testcases...
+     my @addrlist = split(/,/, $recips);  
+     foreach $addr (@addrlist) {
+        foreach $dom (@local_domains_array) {         
+         if (!($addr =~ /$dom$/i)) {          
+           $hashheaders .= `$hashcashcmd $addr`;
+         }
+       }
+     }
+     &debug("HASHCASH headers: $hashheaders");
+  }
+
   &debug("q_r: fork off child into $qmailqueue...");
   
   #($recips=$env_recips) =~ s/^T//;
@@ -1454,6 +1477,7 @@
     $elapsed_time = tv_interval ($start_time, [gettimeofday]);
     $findate = POSIX::strftime( "%d %b ",$sec,$min,$hour,$mday,$mon,$year);
     $findate .= sprintf "%02d %02d:%02d:%02d -0000", $year+1900, $hour, $min, $sec;
+    print QMQ "$hashheaders\n";
     print QMQ "Received: from $remote_smtp_ip$remote_smtp_auth by $hostname (envelope-from <$returnpath>, uid $real_uid) with qmail-scanner-$VERSION \n";
     print QMQ " ($SCANINFO \n Clear:$tag_score. \n";
     print QMQ " Processed in $elapsed_time secs); $findate\n";
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.