[Mimedefang] Where is best to use $SendmailMacros{"auth_authe n"} ?

Damrose, Mark mdamrose at elgin.edu
Thu Jul 1 11:41:01 EDT 2004


> -----Original Message-----
> From: Minica, Nelson (EDS) [mailto:Nelson.Minica at RailAmerica.com]
> Sent: Thursday, July 01, 2004 10:30 AM
> 
> #Must set MX_RELAY_CHECK=yes in /etc/init.d/mimedefang
>         sub filter_relay {
>          my($ip, $name, $helo) = @_;
>          if ($helo =~ /mydomain\./i) {
>            if (!is_trusted()){
>              return(REJECT,"Spam block HELO $helo.");
>              }
>            }
>          if (is_trusted()){
>            return(ACCEPT_AND_NO_MORE_FILTERING,"ok1");
>            }
> 
>          return (CONTINUE,"ok2");
>          }


Nit:  you're calling is_trusted twice to check the same things - including a
file read.
Option 1, store the value and use it for the tests.

         sub filter_relay {
          my($ip, $name, $helo) = @_;
          my $trusted = is_trusted();
          if ($helo =~ /mydomain\./i) {
            if (!$trusted){
              return(REJECT,"Spam block HELO $helo.");
              }
            }
          if ($trusted){
            return(ACCEPT_AND_NO_MORE_FILTERING,"ok1");
            }
 
          return (CONTINUE,"ok2");
          }

Option 2, use an if then else

         sub filter_relay {
          my($ip, $name, $helo) = @_;
          if (is_trusted()){
            return(ACCEPT_AND_NO_MORE_FILTERING,"ok1");
            } else {
            if ($helo =~ /mydomain\./i) {
              return(REJECT,"Spam block HELO $helo.");
              }
            }
 
          return (CONTINUE,"ok2");
          }



More information about the MIMEDefang mailing list