Bug 23811

Summary: Patch to Sendmail Mail Filter (Milter) API
Product: Base System Reporter: Scot W. Hetzel <hetzels>
Component: binAssignee: Gregory Neil Shapiro <gshapiro>
Status: Closed FIXED    
Severity: Affects Only Me CC: gshapiro
Priority: Normal    
Version: 4.2-STABLE   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff none

Description Scot W. Hetzel 2000-12-24 01:40:00 UTC
The sendmail Mail Filter API (Milter) is designed to allow third-party
programs access to mail messages as they are being processed in order to
filter meta-information and content. (from libmilter/README)

While there is a way to enable the Milter API within sendmail, the
libmilter, libsmutil and header files needed to build a Milter daemon are
not installed.

A Milter daemon can be used for:

    - Filtering messages for viruses
    - changing extentions on attachements to prevent them from
      being accidenlty executed by the user.
    - Achiving messages sent/received thru the server
    - Append company disclaimer to all outgoing messages.

I was able to compile libmilter as a shared library.  But when I compiled
libsmutil as a shared library and tried to compile the sample.c from
libmilter/README, it gave me the following error:

cc -I/usr/include/sendmail -o sample sample.c -lmilter -lsmutil -pthread
/usr/lib/libsmutil.so: undefined reference to `message'
/usr/lib/libsmutil.so: undefined reference to `syserr'

both of these are defined in /usr/include/sendmail/sendmail.h.

Due to the above error with a shared libsmutil, the attached patch doesn't
build a shared libsmutil.

I had no problem building sample.c with:

cc -I/usr/include/sendmail -o sample sample.c -lmilter /usr/lib/libsmutil.a -pthread

I tested the sample milter dameon (w/shared libmilter) and sendmail.  The
sample milter dameon wrote the incoming message to a file in /tmp and
delivered it to the recipent mailbox (as described in libmilter/README).

NOTE: to use a milter daemon with sendmail, the *.mc file needs to define
_FFR_MILTER, as well as specifying the milter daemon (see libmilter/README).

    define(_FFR_MILTER)dnl
    INPUT_MAIL_FILTER(`sample', `S=local:/var/run/f1.sock')dnl

Fix: The attached patch makes it so that the Milter API is compiled in to
Sendmail, and that the proper libraries and header files are installed.

Milter daemons need to start before sendmail is started.  A new startup
directory rc.milter is created in $PREFIX/etc/.  This directory should
contain milter startup scripts (similar to the scripts in rc.d).
rc/rc.shutdown have been modified to start/stop the milter daemon before/after
sendmail is started/stopped.


    Changed Files:                    New Files:
        Makefile                          lib/libmilter/Makefile
        etc/defaults/make.conf            lib/libmilter/sample.c
        etc/defaults/rc.conf              lib/libmilter/sample.sh
	etc/mtree/BSD.include.dist
	etc/mtree/BSD.local.dist
        etc/rc
        etc/rc.shutdown
        lib/Makefile
        lib/libsmutil/Makefile
        src/usr.sbin/sendmail/Makefile

NOTE: This patch was created on 4.2-STABLE, but does apply to a
    5.0-CURRENT source tree (with a little fuzziness on some files).
Comment 1 Gregory Neil Shapiro freebsd_committer freebsd_triage 2001-02-05 01:14:15 UTC
Responsible Changed
From-To: freebsd-bugs->gshapiro

Given to sendmail maintainer
Comment 2 Gregory Neil Shapiro freebsd_committer freebsd_triage 2001-04-16 19:06:44 UTC
State Changed
From-To: open->analyzed

Thank you for the patch.  However, given that Milter in 8.11 is an 
unsupported feature, I am going to wait until 8.12 is imported into FreeBSD. 
8.12, currently in beta, enables Milter by default.
Comment 3 Gregory Neil Shapiro freebsd_committer freebsd_triage 2001-05-12 04:14:16 UTC
State Changed
From-To: analyzed->closed

Milter will be imported with sendmail 8.12.