[Mimedefang] Testing for port #/TLS in filter_relay

Philip Prindeville philipp_subx at redfish-solutions.com
Wed Feb 27 21:26:14 EST 2008


Philip Prindeville wrote:
> [snip]
> Well, I could just test for auth_type or tls_version, but my 
> understanding is that this isn't available as early on as 
> filter_relay() and filter_helo()...  that the commands file doesn't 
> get read until filter_sender(), right?
>
>       read_commands_file()
>              This function should only be called from filter_sender 
> and  fil-
>              ter_recipient. This will read the COMMANDS file (as 
> described in
>              mimedefang-protocol(7)), and will fill or update  the  
> following
>              global   variables:   $Sender,  @Recipients,  
> %RecipientMailers,
>              $RelayAddr, $RealRelayAddr, $RelayHostname,  
> $RealRelayHostname,
>              $QueueID, $Helo, %SendmailMacros.
>
>
> Or am I missing something?
>
> Will the milter API support passing the port # at filter_relay() time?
>
> -Philip


Hmmm.

Quick test confirms it.  I edited /etc/mail/sendmail.mc on my system,
adding:

define(`confMILTER_MACROS_CONNECT', ``j, _, {daemon_name}, 
{daemon_port}, {if_name}, {if_addr}'')dnl


(Which reminds me... anyone on this list cozy with the Sendmail folks?
This might be a useful change to make to the standard cf/m4/cfhead.m4
file...)

and remade the .cf file, then restarted Sendmail.  Then added
read_commands_file() into filter_relay(), and got:

Feb 27 18:35:21 mail mimedefang.pl[16628]: Cannot open COMMANDS file 
from mimedefang: No such file or directory
Feb 27 18:35:21 mail mimedefang[2683]: Error from multiplexor: error: 
Cannot open COMMANDS file from mimedefang: No such file or directory
Feb 27 18:35:21 mail sendmail[16635]: m1S1ZLZg016635: Milter: connect: 
host=notorious.mozilla.org, addr=63.245.208.166, temp failing commands


What am I missing?  Looking at the comment in mimedefang.pl, it says:

#***********************************************************************
# %PROCEDURE: read_commands_file
# %ARGUMENTS:
#  needf - if true, will return an error when no closing "F" was found.
#          (optional, default is false). needf should not be set when
#          called from within filter_relay, filter_sender, filter_recipient.
# %RETURNS:
#  true if parse went well,
#  false otherwise
# %DESCRIPTION:
#  Parses the COMMANDS file, and sets these global variables based
#  upon the contents of that file:
#    $Sender
#    @Recipients
#    %RecipientMailers
#    $SuspiciousCharsInHeaders
#    $SuspiciousCharsInBody
#    $RelayAddr
#    $RealRelayAddr
#    $WasResent
#    $RelayHostname
#    $RealRelayHostname
#    $QueueID
#    $Subject
#    $MessageID
#    $Helo
#    %SendmailMacros
#
#***********************************************************************


Which seems to negate the previous comment from the man page (usually
I'll trust source code over what the man pages say, since they aren't
always up to date).

Doh!  envfrom() in mimedefang.c needs to be modified...  Or else I need
to pass in extra macro names via -a (as a temporary measure).  Ok, even
after trying that (-a daemon_port), I'm still not seeing it...  Grrr.
In fact, %SendmailMacros doesn't seem to get populated until filter_begin().

David:  how about it?  Can we add 'daemon_port' to the list of default
macros in envfrom()?

-Philip





More information about the MIMEDefang mailing list