[Mimedefang] restricting senders who can post to a specific recipient

Tony Nugent tony at linuxworks.com.au
Sun Aug 25 06:56:01 EDT 2002


On Sat Aug 24 2002 at 12:07, Tony Nugent wrote:

> I have a situation where I need to protect an email alias from
> "unauthorised" use.  This alias expands to several thousand (!!)
> organisational members, all kept in an external :include: file which
> is regularly updated from an sql database.

[ ... ]


> I'm sure it will
> all become obvious once I get a handle on the mechanics of how all
> these functions work.

Indeed.  In the end the solution was rather trivial :)  As the
mimedefang-filter man page states:

  ... a "recipient" is determined before alias expansion...  If you
  have Sendmail 8.12, then locally-submitted messages are sent via
  SMTP, and MIMEDefang will be called for each resent message.

Some quite-time late-night testing showed this to be exactly the
case.  As it turns out, the behaviour of filter_recipient() allows
me to do exactly what I wanted in a very elegant way.

Problem solved.  Wonderful!  :)

And thanks Ray, for your example code in another reply.  It does the
check within filter_begin() itself, and would be good for checking a
large and/or varying number of possible permitted senders based on
information in external files.  It does this by foreach-looping
through all the @Recipients.  filter_recipient() appears to set this
up automatically, called for each recipient with local delivery.

> I'm a bit confused with how/when to use the filter_recipient() and
> filter_sender() functions... at what stage of the m'defang filtering
> process are they called?  Before filter_begin() ?

After my testing (also upgraded to 2.19), it appears that
filter_recipient() (and family) are called before any filtering
actually begins... filter_begin() has not been called at this point.

I wanted to know if global variables that I (re)set in
filter_begin() from virus checks and so on, were available (and
correct) when filter_recipient() was called.  This does not appear
to be the case, so that's an important restriction I learned to be
aware of.

What about calling other functions called from filter_recipients()?
For example, is it safe or even useful to rewite headers, add/delete
recipients, quarantine_entire_message() and so on at this point?

My impression is that more complex filtering should be left for
later stages of processing :)

Also, the smtp conversation appears to indicate that the decision to
accept or reject the message is taken after the entire message has
been received.  Is the message itself available to
filter_recipients() (eg, for a resend) and if so, how?

Thanks.

Cheers
Tony



More information about the MIMEDefang mailing list