[Mimedefang] Notifying virus recipients

alan premselaar alien at 12inch.com
Thu May 15 06:22:01 EDT 2003


On 5/15/03 3:50 PM, "Adrian Chadd" <adrian at creative.net.au> wrote:

> 
> hi,
> 
> I've been playing with mimedefang and I have it nearly doing all the
> per-user options that I want.
> 
> The only thing I haven't managed to make it do yet is notify a recipient
> that they might have been sent a virus.
> 
> Ie, if foo at domain.com is sent a virus I've currently got it configured
> to send back to the virus sender a bounce message. I'd also like
> to email foo at domain.com that sender bar at domain2.com sent them a potential
> virus.
> 
> Any clues, example snippets?

check the mimedefang-filter man pages for action_replace_with_warning()
routines.  you'll have to pass it a message string to send to the recipient,
but that should do it.  if you look at the contrib/linuxorg/filter in the
rejected() subroutine, there's a good example of code to do this (even
though this particular code is for sending notifications that an executable
file was sent, not a virus)

> 
> Whilst I'm at embarrasing myself, take a look at:
> 
> (MAINTAINING STATE from mimedefang-filter manpage)
> 
> In general, for a given mail message, these groups of functions may be
> called in completely different Perl processes.   Thus,  there
> is no way to maintain state inside Perl between groups of functions.
> That is, you cannot set a variable in filter_relay and expect
> it to be available in filter_sender, because the filter_sender invocation
> might take place in a completely different process.
> 
> Now, in the example mimedefang-filter script the $FoundVirus variable
> is set in filter_begin() and tested in filter(). Thats keeping state, right?
> I'm doing some state-keeping magic in my filter for per-recipient
> filters and it _seems_ to Do the right thing. What gives?
> 
If i'm not mistaken, there were some changes made from previous versions of
MD (I forget specifically which, but I think it was from 2.29 to 2.30+) in
which *some* variables were able to maintain state.  Although David is a
better person to answer this.

Also, the way I interpret that statement is that, if a variable is set in
filter_sender or filter_relay, *THAT* particular variable will probably not
maintain state as those particular functions may not be called in any
specific order, and/or one or both of them may not be called at all
(depending on your configuration, and your filter). However, filter() and
filter_begin() should be called in the same order always.

If i'm not mistaken, the flow of the filter is:

via MILTER filter() gets called
then filter_begin() is called
then filter_relay(), filter_sender(), filter_recipient() and/or any other
necessary subroutines will be called depending on the requirements of the
mail being processed and the configuration.
lastly, filter_end() is called and returned via MILTER

(anyone, please feel to correct me if i'm wrong here)

hopefully this is helpful information (and hopefully accurate)

alan




More information about the MIMEDefang mailing list