From f886a41805c010323d798d2b0737293b6bcde5ef Mon Sep 17 00:00:00 2001 From: rswindell <> Date: Mon, 12 Jan 2009 09:44:30 +0000 Subject: [PATCH] Added support for inserting Return-Path and Received headers before sending to spamd. Some SA features require these header fields. Received header support is currently disabled due to some issues, like: 1. Getting duplicates Received fields after processing the message 2. SpamAssassin *really* doesn't like dynamic IPs in Received header fields --- exec/load/salib.js | 23 ++++++++++++++++++++++- exec/spamc.js | 14 +++++++++----- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/exec/load/salib.js b/exec/load/salib.js index 6ea2a3c7fc..e1a594d9b5 100644 --- a/exec/load/salib.js +++ b/exec/load/salib.js @@ -31,17 +31,38 @@ function Message_DoCommand(command) var tmp; var sock=new Socket(SOCK_STREAM, "spamc"); var ret={message:'', isSpam:false, score:'unknown', threshold:'unknown', symbols:[]}; + var inserted_header_fields=""; if(!sock.connect(this.addr, this.port)) { ret.error='Failed to connect to spamd'; return(ret); } + var content_length = file_size(this.messagefile); + + if(this.reverse_path) + inserted_header_fields += "Return-Path: " + this.reverse_path + "\r\n"; + if(this.hello_name) { + inserted_header_fields += format( + "Received: from %s (%s [%s])\r\n" + + " by %s [%s] (%s)\r\n" + + " for %s; %s %s\r\n" + ,client.host_name,this.hello_name,client.ip_address + ,system.host_name,server.interface_ip_address + ,server.version + ,"unknown" + ,strftime("%a, %d %b %Y %H:%M:%S"),system.zonestr() + ); + } + log("SPAMD: inserted headers = " + inserted_header_fields); + content_length += inserted_header_fields.length; + sock.write(command.toUpperCase()+" SPAMC/1.2\r\n"); - sock.write("Content-length: "+file_size(this.messagefile)+"\r\n"); + sock.write("Content-length: "+content_length+"\r\n"); if(this.user) // Optional sock.write("User: " + this.user + "\r\n"); sock.write("\r\n"); + sock.write(inserted_header_fields); sock.sendfile(this.messagefile); sock.is_writeable=false; diff --git a/exec/spamc.js b/exec/spamc.js index 850481bda1..c961abf8a1 100644 --- a/exec/spamc.js +++ b/exec/spamc.js @@ -26,10 +26,11 @@ // Options: -// dest [ip_address] -// port [tcp_port] -// username [user] -// max-size [bytes] +// dest <ip_address> +// port <tcp_port> +// username <user> +// max-size <bytes> +// reject [threshold] // spamonly // debug @@ -86,7 +87,10 @@ function main() } log(LOG_INFO, "SPAMC: processing message with SPAMD at " + address + " port " + tcp_port); - msg.debug=debug; + msg.debug = debug; + msg.reverse_path = reverse_path; +// if(this.hello_name) +// msg.hello_name = this.hello_name; var ret=msg.process(); if(ret.warning != undefined) log(LOG_WARNING, "SPAMC: WARNING "+ret.warning); -- GitLab