procmail
[Top] [All Lists]

Re: Sending warning of virus via procmail

2003-10-01 22:47:25
David, 
 
You were -almost- spot on, thank you...or maybe you were and I 
mis-interperted your suggestion.  I ended up replacing the w with the 'c' 
and then putting the 'i' on the :0 | action that actually opened the 
shell/sendmail pipe and creating the error.  If I put 'i' on both or even 
just the old 'w' line I recieved a "Extraneous ignore-write-error flag 
ignored", which was almost as annoying! 
 
Comments below show the two changes I made. 
 
On Wed, 01 Oct 2003 23:55:38 -0500, David W. Tamkin wrote 
I wasn't paying much attention to this thread, but Rob has this code, 
 
 :0w 
Changed above to :0c, :0ci here created the "Extraneous...." message.  I 
wonder if I could change this to :0hc since I'm only working with the 
headers anyways. 
 { 
   # Grab the entire header for the body of the message 
   # Grab the Virus name for the Subject line. 
   HEADER = `formail -X "" ` 
   VIRUS  = `formail -xX-ClamAV` 

   :0 
Changed above to :0i, Since this is the action that causes the error, this 
seems like the right place anyways.  Maybe this is where I should have put 
'ci', but I'm not sure if it matters if I clone the entire set of actions or 
just here.  I'm a bit worried that anything I do in the parent block might 
munge the original if I don't 'c' it all now. 
   | ( echo "From: Postmaster(_at_)dympna(_dot_)com"; \ 
       echo "To: $LOGNAME(_at_)dympna(_dot_)com"; \ 
       echo "Subject: ** Virus eMail with $VIRUS"; \ 
       echo "No auto-reply was sent to the originator of this virus";\ 
       echo "infected email.  You may with to contact the person in";\ 
       echo "the >From: line below."; \ 
       echo " ";\ 
       echo "Following are the headers that were extracted from the 
email:";\ 
       echo " ";\ 
       echo "$HEADER" ) | $SENDMAIL -oi -t 
 } 
 
and he gets, 
 
procmail: Error while writing to " ( echo "From: 
postmaster(_at_)dympna(_dot_)com"; 
\ 
 
Well, of course.  The action of that recipe echoes a bunch of canned  
lines to a pipe to sendmail; it doesn't read the message text at  
all. So when it doesn't read it, procmail can't write it, and  
there's a write error.  If you intentionally are writing an action  
line that won't read the message in, use the `i' flag to tell  
procmail that write errors are OK for a change. 
 
Scott thought, 
 
I think the error is coming from sendmail. 
 
No, it's a procmail error.  It should be listed in the procmailrc(5)  
man page [or maybe procmail(1); I can't check right now]. 
 
Also (a nit) I don't see a filter anywhere, so the 'w' flag at the top 
probably isn't necessary. You'll usually see it in conjunction with 
'f' (procmailrc). 
 
`w' does not make sense on a recipe whose action is to open a  
nesting block unless it also has a `c' to fork a clone.  So if  
Scott's point is that `w' is unnecessary, it is, but not because  
there's no `f'. 
 
Scott also advised Rob, 
 
You might consider using formail (see the formail manpage) for 
generating your headers; it will be less work and probably more RFC 
correct. 
 
Rob's header generating method is fine as it is.  I wouldn't  
recommend it for a reply, but for an additional message to the  
recipient it's probably preferable to starting with the incoming  
headers and running them through formail, given all the alteration  
formail would need to do.   A shell is being invoked anyway to  
handle the semicolons and the pipe, and presumablye Rob's shell has  
echo built in, so there's less load with just a shell and $SENDMAIL  
than with formail, a shell, and $SENDMAIL. 
 
What *is* missing is a `c' on the recipe that sends the warning  
note. The only reason procmail isn't exiting there but manages to  
save the original message to $VIRUS_FOLDER is that it senses the  
very write error that is annoying Rob! 
 
So leave your code as is, except to add `ci' to the flag line of the  
recipe that sends the warning note.  Alternatively, put the save to  
$VIRUS_FOLDER first (with a `c') and then drop in the warning note  
(but use the `i' flag).  You could also set $TRAP to take care of it. 
 
_______________________________________________ 
procmail mailing list 
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE 
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail 

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