Merge from vendor branch SENDMAIL:
[dragonfly.git] / contrib / sendmail-8.13.7 / libmilter / docs / design.html
1 <html>
2 <head>
3 <title>Architecture</title>
4 </head>
5 <body>
6 <!--
7 $Id: design.html,v 1.11 2003/03/05 19:57:54 ca Exp $
8 -->
9
10 <h1>Architecture</h1>
11
12 <h2>Contents</h2>
13
14 <ul>
15     <li>Design Goals
16     <li>Implementing Filtering Policies
17     <li>MTA - Filter Communication
18 </ul>
19
20 <h2>Goals</h2>
21
22 The Sendmail Content Management API (Milter) provides an interface for
23 third-party software to validate and modify messages as they pass
24 through the mail transport system.  Filters can process messages'
25 connection (IP) information, envelope protocol elements, message
26 headers, and/or message body contents, and modify a message's
27 recipients, headers, and body.  The MTA configuration file specifies
28 which filters are to be applied, and in what order, allowing an
29 administrator to combine multiple independently-developed filters.
30
31 <p>
32 We expect to see both vendor-supplied, configurable mail filtering
33 applications and a multiplicity of script-like filters designed by and
34 for MTA administrators.  A certain degree of coding sophistication and
35 domain knowledge on the part of the filter provider is assumed.  This
36 allows filters to exercise fine-grained control at the SMTP level.
37 However, as will be seen in the example, many filtering applications
38 can be written with relatively little protocol knowledge.
39
40 <p>
41 Given these expectations, the API is designed to achieve the following
42 goals:
43
44 <OL>
45   <LI>Safety/security.
46         Filter processes should not need to run as root
47         (of course, they can if required, but that is a local issue);
48         this will simplify coding
49         and limit the impact of security flaws in the filter program.
50 <p>
51   <LI>Reliability.
52         Coding failures in a Milter process that cause that process
53         to hang or core-dump
54         should not stop mail delivery.
55         Faced with such a failure,
56         sendmail should use a default mechanism,
57         either behaving as if the filter were not present
58         or as if a required resource were unavailable.
59         The latter failure mode will generally have sendmail return
60         a 4xx SMTP code (although in later phases of the SMTP protocol
61         it may cause the mail to be queued for later processing).
62 <p>
63   <LI>Simplicity.
64         The API should make implementation of a new filter
65         no more difficult than absolutely necessary.
66         Subgoals include:
67         <UL>
68           <LI>Encourage good thread practice
69               by defining thread-clean interfaces including local data hooks.
70           <LI>Provide all interfaces required
71               while avoiding unnecessary pedanticism.
72         </UL>
73 <p>
74   <LI>Performance.
75         Simple filters should not seriously impact overall MTA performance.
76 </OL>
77
78 <h2>Implementing Filtering Policies</h2>
79
80 Milter is designed to allow a server administrator to combine
81 third-party filters to implement a desired mail filtering policy.  For
82 example, if a site wished to scan incoming mail for viruses on several
83 platforms, eliminate unsolicited commercial email, and append a mandated
84 footer to selected incoming messages, the administrator could configure
85 the MTA to filter messages first through a server based anti-virus
86 engine, then via a large-scale spam-catching service, and finally
87 append the desired footer if the message still met requisite criteria.
88 Any of these filters could be added or changed independently.
89
90 <p>
91 Thus the site administrator, not the filter writer, controls the
92 overall mail filtering environment.  In particular, he/she must decide
93 which filters are run, in what order they are run, and how they
94 communicate with the MTA.  These parameters, as well as the
95 actions to be taken if a filter becomes unavailable, are selectable
96 during MTA configuration.  <a href="installation.html">Further
97 details</a> are available later in this document.
98
99 <h2>MTA - Filter communication</h2>
100
101 Filters run as separate processes, outside of the sendmail address
102 space.  The benefits of this are threefold:
103
104 <OL>
105   <LI>The filter need not run with "root" permissions, thereby
106         avoiding a large family of potential security problems.</LI>
107
108   <LI>Failures in a particular filter will not affect the MTA or
109         other filters.</LI>
110
111   <LI>The filter can potentially have higher performance because of
112         the parallelism inherent in multiple processes.</LI>
113 </OL>
114
115 <p>
116 Each filter may communicate with multiple MTAs at the same time over
117 local or remote connections, using multiple threads of execution.  <a
118 href="#figure-1">Figure 1</a> illustrates a possible network of
119 communication channels between a site's filters, its MTAs, and other
120 MTAs on the network:
121 </p>
122 <div align="center">
123 <a name="figure-1"><img src="figure1.jpg" ALT=""></A><br>
124 <b>Figure 1: A set of MTA's interacting with a set of filters.</b>
125 </div>
126 <p>
127 The Milter library (libmilter) implements the communication protocol.
128 It accepts connections from various MTAs, passes the relevant data to
129 the filter through callbacks, then makes appropriate responses based
130 on return codes.  A filter may also send data to the MTA as a result
131 of library calls.  <a href="#figure-2">Figure 2</a> shows a single
132 filter process processing messages from two MTAs:
133 </p>
134 <div align="center">
135 <img src="figure2.jpg" ALT=""><br>
136 <b>Figure 2: A filter handling simultaneous requests from two MTA's.</b>
137 </div>
138 <hr size="1">
139 <font size="-1">
140 Copyright (c) 2000, 2003 Sendmail, Inc. and its suppliers.
141 All rights reserved.
142 <br>
143 By using this file, you agree to the terms and conditions set
144 forth in the LICENSE.
145 </font>
146 </body>
147 </html>