I know this is a mite off topic for the list but I've not been able to get 
any help in other lists I've posted including the procmail one.  I thought 
that as a last resort I'd ask here since SA uses regex's for its rules. 
I'll take it off list if someone would just offer some suggestions as to 
what is wrong.

I have a a procmail recipe which uses formail to put the following at the 
end of message headers:

X-SenderIP: 65.54.169.39
X-ASN: ASN-8075
X-CIDR: 65.54.160.0/19

This works fine for my main isp, earthlink. However, I'd also like the same
to be added to mail from my domain, toadnet.com, and to mail I pull down
from my yahoo account using fetchyahoo.  I'm getting output as below in my 
procmail log:

ASN= From [EMAIL PROTECTED]  Tue Jan  3 17:17:07 2006
 Subject: {Virus?} Mail delivery failed: returning message to sender
  Folder: /home/chris/Maildir/.Spam/new/1136330227.12501_2.cpollock.lo     
6221
procmail: Skipped "Server"
procmail: Skipped "|by toadnet\.com \(8\.12\.11/8\.12\.11\)|by 
mta[0-9]*\.mail\..*\.yahoo\.com)"
ASN= 11456From [EMAIL PROTECTED]  Tue Jan  3 17:25:37 2006
 Subject: Valium as low as $3.41 
  Folder: /home/chris/Maildir/.Spam/new/1136330737.13087_2.cpollock.lo    
10118
procmail: Skipped "Server"
procmail: Skipped "|by toadnet\.com \(8\.12\.11/8\.12\.11\)|by 
mta[0-9]*\.mail\..*\.yahoo\.com)"

There is something wrong with the regex on the SMTP server line.  Here is
the whole recipe, I didn't write it and I'm not really good with regular 
expressions at all. Everything is on one line in
my .procmailrc.  Any assistance from you gurus out there would be greatly
appreciated.

# $Id: asn-header,v 1.2 2004/03/08 00:06:50 karsten Exp karsten $
#
# Add X-ASN header
# KMSelf Sun Jul 11 04:05:32 PDT 2004
#
# Add headers for ASN and originating IP.
# Original author:  Karsten M. Self
# 
# Requires FORMAIL variable be set (most procmail recipe sets do this).
#
# You must set your SMTP_SERVER identifier.
#
# Run this BEFORE any spamassassin processing.  The header tag itself
# should start being scored as a Bayesian attributed.

# FORMAIL = /usr/bin/formail

SMTP_SERVER = (EarthLink SMTP Server|by toadnet\.com 
\(8\.12\.11/8\.12\.11\)|by mta[0-9]*\.mail\..*\.yahoo\.com)

# ----------------------------------------------------------------------
# Parse out the sender's IP address.
SENDERIP = `formail -c -XReceived | grep "$SMTP_SERVER" | \
    tr '[][\t <>()]' '\n' | \
    grep '^[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}$' | \
     tail -1`

# Reverse IP for reverse DNS query
REVERSE_SENDERIP = `expr "$SENDERIP" | \
    sed "s/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)/\4.\3.\2.\1/"`

# Query asn.routeviews.org for the ASN.
# Note that this is pretty aggressive:  wait six seconds, retry ten
# times, may slow mail processing, but tends to improve data quality.
# Run a caching DNS server for improved performance.
# Raw is a mostly unmunged output (save quotes and prefix).  Contains
# ASN, IP, and CIDR prefix.
RAW_ASN = `host -W 6 -R 10 -t txt $REVERSE_SENDERIP.asn.routeviews.org | \
    sed -e 's/.* text //' -e 's/"//g'`
ASN = `echo $RAW_ASN | cut -d ' ' -f 1`
ASN_CIDR = `echo $RAW_ASN | cut -d ' ' -f 2`/`echo $RAW_ASN | cut -d ' ' -f
3`

# LOG = "SENDERIP= $SENDERIP"

# LOG = "REVERSE_SENDERIP= $REVERSE_SENDERIP"
LOG = "ASN= $ASN"

# ------------------------------------------------------------------------ 
# Add X-SenderIP header.
:0 fhw
* ! ^X-SenderIP:
| $FORMAIL -a "X-SenderIP: $SENDERIP"
# ------------------------------------------------------------------------ 

# ------------------------------------------------------------------------ 
# Add X-ASN header.
:0 fhw
* ! ^X-ASN:
| $FORMAIL -a "X-ASN: ASN-$ASN"
# ------------------------------------------------------------------------ 

# ------------------------------------------------------------------------ 
# Add X-CIDR header.
:0 fhw
* ! ^X-CIDR:
| $FORMAIL -a "X-CIDR: $ASN_CIDR"
# ------------------------------------------------------------------------  

Thanks in advance

-- 
Chris
Registered Linux User 283774 http://counter.li.org
20:32:33 up 11 days, 2:18, 2 users, load average: 2.08, 0.87, 0.40
Mandriva Linux 10.1 Official, kernel 2.6.8.1-12mdk

Attachment: pgpTpF9l4NEoy.pgp
Description: PGP signature

Reply via email to