Yahoo Groups archive

Milter-greylist

Index last updated: 2026-04-28 23:32 UTC

Message

Re: milter-greylist patch for DRAC

2005-11-30 by Romain Kang

On Wed, Nov 30, 2005 at 10:00:57PM +0000, Emmanuel Dreyfus wrote:
> Could you grep sendmail source for DRAC usage? Just to be sure we are
> to open the file forever with a shared lock...

The reference to drac is made through the .cf file, rather than the
sendmail program itself.  The .mc says something like this:
    LOCAL_CONFIG
    # dynamic relay authorization control map
    Kdrac btree -o /usr/local/etc/dracd
    ...
    SLocal_check_relay
    # allow recent POP/IMAP mail clients to relay
    R$*				$: $&{client_addr}
    R$+				$: $(drac $1 $: ? $)
    R?				$@ ?
    R$+				$@ $#OK

Running lsof on an idle sendmail daemon shows none of the map files
are held open (e.g., dracd.db, aliases.db).  They are only opened
when reference is made to a particular map.  The sendmail map.c
code acquires and releases the lock with the sequence
    lockfile(..., LOCK_SH);
    ...
    lockfile(..., LOCK_UN);
In turn, lockfile() uses BSD style flock() when available, or fcntl()
style locks otherwise.

The check_drac() function that I posted last night no longer holds
the map file open.  Instead, the sequence goes like this:
    - open the DB file with the O_SHLOCK flag set
    - attempt to get() the item as an existence check
    - close the file (implicitly clearing the shared lock)
So if there are systems which don't support O_SHLOCK or only have
fcntl() locks, there could be a possible hole, but this risk seems
negligible.  Moreover, since the DB is merely used as an existence
check, the content is not that significant.

Romain

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.