procmail
[Top] [All Lists]

Re: Failure to write

2001-12-02 10:55:42
Thanks Dave

Ruben

On 2001.12.02 12:38:18 -0500 David W. Tamkin wrote:
Ruben from Brooklyn Linux Solutions wondered,

| I'm having a strange problem with procmail and my anti-spam perl
| script.  I get a certain behavior with certain nuisance posters who
seem
| to get around the procmail reciepe. I've wracked my brains on this and
| can't seem to find the trouble myself.
|
| The recipe being used looks like this:
| PATH=/bin:/usr/bin:/usr/bin
| MAILDIR=$HOME/mail
| LOGFILE=$MAILDIR/from
|
| :0 w
| * ^From.*hudes\.org
| |/home/ruben/reject.pl
|
| This normally works. But for this address I get the following error in
| the mail/from file:
|
|  371 SENT
|  372 procmail: Error while writing to "/home/ruben/reject.pl"

It's not a case of the address.  Procmail tried to run reject.pl, so you
know that the condition matched properly, but then it reported an error
in
feeding the message text to the perl script.

| The reject file looks like this:

At that point Ruben supplied the perl code, but I can't read perl, so I'm not going to analyze it or even quote it. But since procmail *sometimes*
has a write error, my first guess here will be the usual reason that a
recipe's action *sometimes* produces a write error.  It has to do with
the
length of the message, not with who sent it.

| Any clues?

If it's the usual cause, your perl script reads in either none of the
message or part of it (perhaps the head but not the body) but not the
whole
thing.  Either it doesn't need any of it or it needs only part and then
stops reading.  When the action is a pipe, procmail feeds one bufferful
at a
time to the command in there; if the command reads the whole message or
stops reading somewhere during the last bufferful of the message,
procmail
is happy; but if the command stops reading during a bufferful that
doesn't
go to the end of the message, then procmail tries to write the next
bufferful, and the command won't take it, and procmail reports a write
error.  (Note that if the entire message fits into one bufferful,
procmail
will not find a write error even if the command doesn't use any of the
text
at all.)

Solution: well, that's where we get into my ignorance of perl. There are
two possibilities, and if I knew perl, I could read what your script is
doing and see which of these is the case, but I don't, so here are both:

1. If the perl script is not supposed to read any of the message at all,
or
if it's supposed to quit in the middle of the head or the middle of the
body, add the `i' flag to the recipe to let procmail know that this time
apparent write errors are OK. (In fact, if perl will stop reading in the
middle of the head, use both `h' and `i'.)

:0 wi
* ^From.*hudes\.org
|/home/ruben/reject.pl

2. If the perl script is supposed to read the entire head of the message
and
ignore the body, add the `h' flag to the recipe so that procmail will
give
it only the head.  Don't use `i' because if there's a write error with
procmail's attempt to feed the head to perl, you'll want to know it.

:0 wh
* ^From.*hudes\.org
|/home/ruben/reject.pl




--
__________________________

Brooklyn Linux Solutions
__________________________
http://www.mrbrklyn.com - Consulting
http://www.brooklynonline.com - For the love of Brooklyn
http://www.nylxs.com - Leadership Development in Free Software
http://www.nyfairuse.org - The foundation of Democracy
http://www2.mrbrklyn.com/resources - Unpublished Archive or stories and articles from around the net
http://www2.mrbrklyn.com/mp3/annie.mp3 - Armed and Dangerous....
http://www2.mrbrklyn.com/downtown.html - See the New Downtown Brooklyn....

1-718-382-5752



_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>