procmail
[Top] [All Lists]

Re: Conflict between c flag and filter

2002-08-27 17:53:03
On 27 Aug, Udi Mottelo wrote:
| On Tue, 27 Aug 2002, Don Hammond wrote:
| 
| >
| > On 27 Aug, Udi Mottelo wrote:
| > |
| > | [...]
| > | :0 H
| > | * with ESMTP id \/[^    ]+
| > | {
| > | FILE=/var/tmp/Udi/Vdir/$MATCH
| > | HEADER=/var/tmp/Udi/Vdir/$LOGNAME.$MATCH
| > | ANTIVIRUS="/usr/local/sbin/f-prot -dumb -archive -silent"
| > | NOTHING=
| > |
| > |   :0 c
| > |   $FILE
| > |
| > |   :0 Bw
| > |   * 1^0 $ ! ? $ANTIVIRUS $FILE
| > |   * 0^0 $ NOTHING ?? ? /bin/rm $FILE
| > |   {
| > |           :0 fhwc
| > |           |cat | tee $HEADER
| > |   }
| > | }
| > |
| > | :0
| > | /var/tmp/Udi/bigfolder
| > |
| > |
| > |   Any ideas?
| > |
| >
| > I don't understand what you mean by procmail continuing "with the body
| > only".  I'm also not sure what is/isn't happening that you do/don't
| > want or expect. But I'm sure as can be (famous last words) that you
| > don't want the "f" filter flag on either of the two examples you give
| > above. The "f" flag renders them non-delivering, and procmail  continues
| > to process the message (2 of them with the "c" flag). You also don't
| > need the cat (UUOC), and I have no clue what you're trying to do with
| > tee.
| 
|         Yes, I see that you did not understand me _BUT_ you have already
|         helped me, isn't a magic?  (:-)
| 
|         What I wanted is:
| 
|       1)  Save all the messages in one folder which named "bigfolder".
|       2)  If the message is infected - save the header in a file which
|           named  Username.TheMessageID  that's it, not collection in
|           one folder.
| 
|       Because of the "f" flag (that I dropped thanks to you) the filter
|       changed the message header to be null (the output of the filter
|       is nothing while cat(1)'s output is redirected to a file)  then
|       procmail went to the next recipe and saved the message i.e. only
|       the body, into the folder bigfolder.
| 
|       The tee(1) duplicates the stdout so that output of cat(1) goto a
|       file _AND_ stdout, the header is saved the message is not corrupted.

It was probably dumb luck, not magic. I didn't even consider that the 2 
"| cat ..." filters would return nothing to procmail in the way of
headers, otherwise I'd have understood the comment about continuing
with the body only. I just knew that there was no reason for an f flag
on either of those recipes.

As for the use of tee, I still can't see the purpose. The output to
stdout just disappears, doesn't it?  Where do you think it's going?

Maybe I'm misunderstanding something else, but I'm guessing f-prot
can't take it's input on stdin, which is why you're saving a copy
to $FILE. If so, then there's no need for the "B" flag on the recipe
that runs f-prot as a condition. And the ? condition requires an exit
code to test, so "w" should be unnecessary too. All of this is guess
work, however.

Lastly, I've used David Tamkin's suggestion about not using 0^0, since
it does the same thing but protects you if you change procmail
versions, forget this discussion, and can't figure out why it doesn't
work any longer.

:0 H   # H flag not neceesary, but I guess it doesn't hurt
* with ESMTP id \/[^    ]+
{
  FILE=/var/tmp/Udi/Vdir/$MATCH
  HEADER=/var/tmp/Udi/Vdir/$LOGNAME.$MATCH
  ANTIVIRUS="/usr/local/sbin/f-prot -dumb -archive -silent"
  NOTHING=

  :0 c:
  $FILE

  # The next c(opy) will only be created if the conditons
  # match, otherwise nothing will be saved to $HEADER.
  # You shouldn't need the path to rm; and maybe you want rm -f,
  # unless you want to see errors in the procmail log file.
  :0 c:
  *  2^0 $ ! ? $ANTIVIRUS $FILE
  * -1^0 $ NOTHING ?? ? /bin/rm $FILE
  $HEADER
}

:0:
/var/tmp/Udi/bigfolder


 
| P.S.  What is UUOC?

http://www.ling.helsinki.fi/~reriksso/unix/award.html
http://groups.google.com/groups?hl=en&lr=&ie=ISO-8859-1&q=%22Useless+Use+of+Cat%22&btnG=Google+Search&meta=group%3Dcomp.unix.shell

-- 
Reply to list please, or append "8" to "procmail" in address if you must.
Spammers' unrelenting address harvesting forces me to this...reluctantly.


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