|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
Filter question
From: Account for mailinglists (lists
soderlund.org)
Date: Tue Apr 29 2003 - 06:59:42 CDT
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hiya folks, lovely with another filterquestion right :-)
Anyway, im messing around with the readme's and in perticular the
FILTER_README. In the long run, i'd like to make a script that simply
checks who the mail is for, and based on another file with addresses,
determines if its in there, and in that case sends back a vacation-notice.
I.e a crude autoresponder.
Now, Ive started by adding this i my master.cf (im running amavis and
spamassassin as advanced filters, hence the location of the definition of
vfilter:
[snip]----------------------------------
127.0.0.1:10025 inet n - n - - smtpd
-o content_filter=vfilter:
-o local_recipient_maps=
-o smtpd_helo_restrictions=
-o smtpd_client_restrictions=
-o smtpd_sender_restrictions=
-o smtpd_recipient_restrictions=permit_mynetworks,reject
-o mynetworks=127.0.0.0/8
vfilter unix - n n - - pipe
flags=R user=filter argv=/usr/local/sbin/vfilter2 -f ${sender} --
${recipient}
[snip]----------------------------------
Ive added a user with no login or shell called "filter".
The script "/usr/local/sbin/vfilter2" looks like this (taken from the
FILTER_README):
[snip]----------------------------------
#!/bin/sh
# Localize these.
INSPECT_DIR=/var/spool/filter
SENDMAIL="/usr/sbin/sendmail -i"
# Exit codes from <sysexits.h>
EX_TEMPFAIL=75
EX_UNAVAILABLE=69
# Clean up when done or when aborting.
trap "rm -f in.$$" 0 1 2 3 15
# Start processing.
cd $INSPECT_DIR || { echo $INSPECT_DIR does not exist; exit $EX_TEMPFAIL; }
cat >in.$$ || { echo Cannot save mail to file; exit $EX_TEMPFAIL; }
echo $2 $4 >> /var/spool/filter/testfile || { echo Message content
rejected; exit $EX_UNAVAILABLE; }
$SENDMAIL "$@" <in.$$
exit $?
[snip]----------------------------------
Notice the "echo"-line which is where I actually DO something with the
mail. Well..kind of, Im taking the variables the filter and script is
initiated with, and echo it into a file. Just to see that something is
happening.
Well, now the problem. With this setup and I send a mail to a known user
(in a virtual domain) I get an infinite loop, but the correct info shows up
(sender and recipient) in the testfile. The loop seems to be that when
sendmail is invoked with -i to reinstate the mail back to postfix, it comes
in as a new unfiltered mail and goes thru the same procedure again, and
again etc etc. Until the maximum hops stops it.
Im sure Ive left something out that is crucial, thats usually something
that happens when you try to explain a problem you have with something
you've not yet mastered fully.
Any thoughts?
Regards,
N
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]