[Mimedefang] Disable filter on smtp-auth

Jan-Pieter Cornet johnpc at xs4all.nl
Mon Jan 28 04:26:07 EST 2013


On 2013-1-27 22:21 , Michiel Brandenburg wrote:
> Hi Wesley,
>> Is there a way to disable this filter only for SMTP Auth ?
> Sure there is, I use the following function
> 
> # Checks authentication
> sub check_authenticated {
> 
>         load_sendmail_macros();

err.. that is not a mimedefang-function. Maybe you meant 'read_commands_file()'? That's only necessary if called from filter_sender or filter_recipient.

>         if ( defined( $SendmailMacros ) &&
>              defined( $SendmailMacros{auth_authen})) {

This is written in a very confusing way (actually, just plain wrong). You are testing two unrelated variables: First, you are testing the scalar $SendmailMacros (which does not normally exist, so it will always be undefined - or throw a compiler error), and an element of the %SendmailMacros hash. Yes, perl is confusing this way... variables can have the same name but still be different if they're of a different type ($foo vs %foo). To make the compiler catch such an error, make sure you "use strict;" in your filter.

>              return $SendmailMacros{auth_authen};
>         }
>         # check COMMANDS file for info, we use auth_authen
>         # =auth_authen apex
>         # =auth_ssf 0
>         # =auth_type LOGIN
>         # =auth_authen apex
>         open( COMM, "<./COMMANDS" ) or return 0;

... and here you're implementing read_commands_file yourself... but written in such a way that you don't extract the authenticated username.

> Make sure that sendmail passes along the macro auth_authen, think this is default not sure though.

Yes, that's default.

Much easier is to just use:

  if ( $SendmailMacros{auth_authen} ) {
     # connection has authenticated
     ...
  }

Unless you are doing this check in filter_sender() or filter_recipient() (which is really unlikely if you're doing content filtering), then you will have to call read_commands_file() before doing the test.

-- 
Jan-Pieter Cornet
"Most seasonal greetings are sent by spammers and phishers."

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 332 bytes
Desc: OpenPGP digital signature
URL: <http://lists.roaringpenguin.com/pipermail/mimedefang/attachments/20130128/819bb6f1/attachment.pgp>


More information about the MIMEDefang mailing list