docs/diploma

changeset 185:1611abd5443b

restructuring and new content (a large commit)
author meillo@marmaro.de
date Mon, 29 Dec 2008 14:06:50 +0100
parents b0adae481138
children 84d27c22517c
files thesis/tex/4-MasqmailsFuture.tex
diffstat 1 files changed, 271 insertions(+), 122 deletions(-) [+]
line diff
     1.1 --- a/thesis/tex/4-MasqmailsFuture.tex	Mon Dec 29 14:05:24 2008 +0100
     1.2 +++ b/thesis/tex/4-MasqmailsFuture.tex	Mon Dec 29 14:06:50 2008 +0100
     1.3 @@ -1,9 +1,28 @@
     1.4  \chapter{\masqmail's present and future}
     1.5  
     1.6 +This chapter \dots %fixme write text here
     1.7 +
     1.8 +
     1.9 +
    1.10 +
    1.11  \section{Existing code base}
    1.12 +
    1.13  Here regarded is version 0.2.21 of \masqmail. This is the last version released by Oliver \person{Kurth}, and the basis for my thesis.
    1.14  
    1.15  
    1.16 +\subsubsection*{The source code}
    1.17 +
    1.18 +\masqmail\ is written in the C programming language. The program, as of version 0.2.21, consists of 34 source code and eight header files, containing about 9,000 lines of code\footnote{Measured with \name{sloccount} by David A.\ Wheeler.}. Additionally, it includes a \name{base64} implementation (about 300 lines) and \name{md5} code (about 150 lines). For systems that do not provide \name{libident}, this library is distributed as well (circa 600 lines); an available shared library however has higher precedence in linking.
    1.19 +
    1.20 +The only mandatory dependency is \name{glib}---a cross-platform software utility library, originated in the \NAME{GTK+} project. It provides safer replacements for many standard library functions. It also offers handy data containers, easy-to-use implementations of data structures, and much more.
    1.21 +
    1.22 +With \masqmail\ comes the small tool \path{mservdetect}; it helps setting up a configuration that uses the \name{mserver} system to detect the online state. Two other binaries get compiled for testing purposes: \path{readtest} and \path{smtpsend}. All three programms use \masqmail\ source code; they only add a file with a \verb+main()+ function each.
    1.23 +
    1.24 +\masqmail\ does not provide an interface to plug in modules with additional functionality. There exists no add-on or module system. The code is only separated by function to the various source files. Some functional parts can be included or excluded by defining symbols. Adding maildir support at compile time, means giving the option \verb+--enable-maildir+ to the \path{configure} call. This preserves the concerning code to get removed by the preprocessor. Unfortunately the \verb+#ifdef+s are scattered through all the source, leading to source code that is hard to read.
    1.25 +%fixme: refer to ifdef-considered-harmful ?
    1.26 +
    1.27 +
    1.28 +
    1.29  \subsubsection*{Features}
    1.30  
    1.31  \masqmail\ accepts mail on the command line and via \SMTP. Mail queueing and alias expansion is supported. \masqmail\ is able to deliver mail to local mailboxes (in \name{mbox} or \name{maildir} format) or pass it to a \name{mail delivery agent} (like \name{procmail}). Mail destinated to remote locations is sent using \SMTP\ or can be piped to commands, being gatesways to \NAME{UUCP} or \NAME{FAX} for example.
    1.32 @@ -20,29 +39,22 @@
    1.33  Additional to the \mta\ job, \masqmail\ also offers mail retrieval services with being a \NAME{POP3} client. It can fetch mail from different remote locations, dependent on the active online route.
    1.34  
    1.35  
    1.36 -\subsubsection*{The code}
    1.37 -
    1.38 -\masqmail\ is written in the C programming language. The program, as of version 0.2.21, consists of 34 source code and eight header files, containing about 9,000 lines of code\footnote{Measured with \name{sloccount} by David A.\ Wheeler.}. Additionally, it includes a \name{base64} implementation (about 300 lines) and \name{md5} code (about 150 lines). For systems that do not provide \name{libident}, this library is distributed as well (circa 600 lines); an available shared library however has higher precedence in linking.
    1.39 -
    1.40 -The only mandatory dependency is \name{glib}---a cross-platform software utility library, originated in the \NAME{GTK+} project. It provides safer replacements for many standard library functions. It also offers handy data containers, easy-to-use implementations of data structures, and much more.
    1.41 -
    1.42 -
    1.43 -With \masqmail\ comes the small tool \path{mservdetect}; it helps setting up a configuration that uses the \name{mserver} system to detect the online state. Two other binaries get compiled for testing purposes: \path{readtest} and \path{smtpsend}. All three programms use \masqmail\ source code; they only add a file with a \verb+main()+ function each.
    1.44 -
    1.45 -
    1.46 -\masqmail\ does not provide an interface to plug in modules with additional functionality. There exists no add-on or module system. The code is only separated by function to the various source files. Some functional parts can be included or excluded by defining symbols. Adding maildir support at compile time, means giving the option \verb+--enable-maildir+ to the \path{configure} call. This preserves the concerning code to get removed by the preprocessor. Unfortunately the \verb+#ifdef+s are scattered through all the source, leading to a FIXME(holperig) code base.
    1.47 -
    1.48  
    1.49  
    1.50  
    1.51  
    1.52  \section{Requirements}
    1.53  
    1.54 -This section identifies the requirements for future version of \masqmail. Most of them will apply to modern \MTA{}s in general.
    1.55 +This section identifies the requirements for a modern \masqmail. Most of them will apply to modern \MTA{}s in general.
    1.56 +
    1.57 +
    1.58  
    1.59  \subsection{General requirements}
    1.60  
    1.61 -Following is a list of current and future requirements to make \masqmail\ ready for the future.
    1.62 +The following list of general requirements applies not only to \masqmail, but to all kinds of programs in similar environment doing similar jobs with the same intention. These requirements can be covered by the term ``quality''.
    1.63 +%fixme: add cites
    1.64 +%fixme: refer to ch01 and ch02
    1.65 +General requirements specify the non-functional properties of the software, thus they are also called \name{non-functional requirements}.
    1.66  
    1.67  
    1.68  \subsubsection*{Security}
    1.69 @@ -72,7 +84,138 @@
    1.70  
    1.71  
    1.72  
    1.73 -\subsection{Discussion on architecture}
    1.74 +
    1.75 +\subsection{Functional requirements}
    1.76 +
    1.77 +This section identifies the needed functionality for a modern \MTA. The basic job of a \mta\ is to tranport mail from a sender to a recipient. This is the definition of such kind of software and this is how \MTA{}s are generally seen \cite[page 19]{dent04} \cite[pages 3-5]{hafiz05}.
    1.78 +
    1.79 +An \MTA\ therefore needs at least a mail receiving facility and a mail sending facility.
    1.80 +
    1.81 +
    1.82 +
    1.83 +\subsubsection*{Incoming channels}
    1.84 +
    1.85 +\sendmail-compatible \mta{}s must support at least two incoming channels: mail submitted using the \sendmail\ command, and mail received via the \SMTP\ daemon. Thus it is common to split the incoming channel into local and remote. This is done by \qmail\ and \postfix. The same way is \person{Hafiz}'s view. \SMTP\ is the primary mail transport protocol today, but with the increasing need for new protocols\ref{FIXME} in mind, support for more than just \SMTP\ is good to have. This leads to more than one remote channel.
    1.86 +
    1.87 +
    1.88 +\subsubsection*{Outgoing channels}
    1.89 +
    1.90 +Outgoing mail is commonly either sent using \SMTP, piped into local commands (for example \texttt{uucp}), or delivered locally by appending to a mailbox.
    1.91 +
    1.92 +Outgoing channels are similar for \qmail, \postfix, and \name{sendmail X}: All of them have a module to send mail using \SMTP, and one for writing into a local mailbox. Local mail delivery is a job that requires root priveledge to be able to switch to any user in order to write to his mailbox.
    1.93 +
    1.94 +As mail delivery to local users, is \emph{not} included in the basic job of an \MTA{}, why should it care about it? In order to keep the system simple and to have programs that do one job well, the local delivery job should be handed over to a specialist: the \name{mail delivery agent}. \NAME{MDA}s know about the various mailbox formats and are aware of the problems of concurrent write access and thelike. Hence handling the message and the responsiblity over to a \NAME{MDA}, like \name{procmail} or \name{maildrop}, seems to be the right way to go.
    1.95 +
    1.96 +This means an outgoing connection that pipes mail into local commands is required. Other outgoing channels, one for each supportet protocol, may be designed like it was done in other \MTA{}s.
    1.97 +
    1.98 +
    1.99 +
   1.100 +\subsubsection*{Mail queue}
   1.101 +
   1.102 +Additionally to the mail receiving and sending facilities, mail queues are a basic feature. A mail queue removes the need to deliver intantly as a message is received. They provide fail-safe storage of mails until they are delivered. Mail queues are probably used in all \mta{}s, excluding the simple forwarders. A mail queue is a essential requirement for \masqmail, as it is to be used for non-permanent online connections. This means, mail must be queued until a online connection is available to send the message.
   1.103 +
   1.104 +The mail queue and the module to manage it are the central part of the whole system. This demands especially for robustness and reliability, as a failure here can lead to loosing mail. An \MTA\ takes over responsibility for mail in accepting it, hence loosing mail messages is absolutely to avoid. This covers any kind of crash situation too. The worst thing acceptable to happen is a mail to be sent twice.
   1.105 +
   1.106 +\sendmail, \exim, \qmail, \name{sendmail X}, and \masqmail\ feature one single mail queue. \postfix\ has three of them: \name{incoming}, \name{active}, and \name{deferred}. (The \name{maildrop} queue is excluded, as it is only used for the \texttt{sendmail} command.)
   1.107 +
   1.108 +\MTA\ setups that do external content scanning tend to require two separate queues. To use \sendmail\ in such setups requires two independent instances, with two separate queues, running. \exim\ can handle it with special \name{router} and \name{transport} rules, but the data flow gets complicated. Having two independent queues seems to be preferable.
   1.109 +
   1.110 +
   1.111 +
   1.112 +
   1.113 +\subsubsection*{Header sanitizing}
   1.114 +
   1.115 +Mail coming into the system often lacks important header lines. At least the required ones must be added from the \MTA. One example is the \texttt{Date:} header, another is the, not required but recommended \texttt{Message-ID:} header. Apart from adding missing headers, rewriting headers is important too, to change the locally known domain part of email addresses to globally known ones for example. \masqmail\ needs also the ability to rewrite the domain part dependent on the route used to send the message.
   1.116 +
   1.117 +Generating the envelope is a related job. The envelope specifies the actual recipient of the mail, no matter what the \texttt{To:}, \texttt{Cc:}, and \texttt{Bcc:} headers tell. Multiple reciptients lead to multiple different envelopes, containing all the same mail message.
   1.118 +
   1.119 +
   1.120 +
   1.121 +
   1.122 +\subsubsection*{Aliasing}
   1.123 +
   1.124 +Email addresses can have aliases and need to be expanded. Aliases can be of different kind: different local user, remote user, list of local and/or remote users, or a command. Most important are the aliases in the \path{aliases} file, usually located at \path{/etc/aliases}. Addresses expanding to lists of users lead to more envelopes. Aliases changing the reciptients domain part may require a different route to use.
   1.125 +
   1.126 +
   1.127 +
   1.128 +
   1.129 +\subsubsection*{Choose route to use}
   1.130 +
   1.131 +One key feature of \masqmail\ is its ability to send mail out in different ways. The decision is based on the current online state and whether a route may be used for a message or not. The online state can be retrieved in tree ways, explained in \ref{sec:fixme}. A route to send is found by checking every available route for being able to transfer the current message, until one matches.
   1.132 +
   1.133 +
   1.134 +
   1.135 +
   1.136 +\subsubsection*{Authentication}
   1.137 +
   1.138 +One thing to avoid is being an \name{open relay}. Open relays allow to relay mail from everywhere to everywhere. This is a major source of spam. The solution is restricting relay\footnote{Relaying is passing mail, that is not from and not for the own system, through it.} access.
   1.139 +
   1.140 +Several ways to restrict access are available. The most simple one is restrictiction relaying by the \NAME{IP} address. No extra complexity is added this way, but static \NAME{IP} addresses are needed.
   1.141 +
   1.142 +If static access restriction is not possible, for example mail from locations with changing \NAME{IP} addresses, some kind of authentication mechanism is required. Three common kinds exist:
   1.143 +\begin{itemize}
   1.144 +	\item \SMTP-after-\NAME{POP}: Uses authenication on the \NAME{POP} protocol to permit incoming \SMTP\ connections for a limited time afterwards.
   1.145 +	\item \SMTP authentication: An extension to \SMTP. Authentication can be requested before mail is accepted.
   1.146 +	\item Certificates: They confirm the identity of someone.
   1.147 +\end{itemize}
   1.148 +
   1.149 +
   1.150 +
   1.151 +\subsubsection*{Encryption}
   1.152 +
   1.153 +Electronic mail is very weak to sniffing attacks, because all data transfer is unencrypted. This concerns the message's content, as well as the email addresses in header and envelope, but also authentication dialogs that may transfer plain text passwords (\NAME{PLAIN} and \NAME{LOGIN} are examples). Thus encryption is wanted.
   1.154 +
   1.155 +The common way to encrypt \SMTP\ dialogs is using \name{Transport Layer Security} (short: \TLS, successor of \NAME{SSL}). \TLS\ encrypts the datagrams of the \name{transport layer}. This means it works below the application protocols and can be used by any of them\citeweb{wikipedia:tls}.
   1.156 +
   1.157 +Outgoing \SMTP\ connections can get encrypted using a secure tunnel, created by an external application. Incoming connections, can not use this technique because the remote \NAME{IP} address is hidden then; \NAME{STARTTLS}---defined in \RFC2487---is what \mta{}s implement.
   1.158 +
   1.159 +
   1.160 +
   1.161 +\subsubsection*{Spam prevention}
   1.162 +
   1.163 +Spam is a major threat nowadays, but it is a war in which the good guys tend to lose. Putting much effort in fighting spam results in few gain. Real success will only be possible with new---better---protocols and abandonning the weak legacy technologies. The goal is to provide state-of-the-art spam protection, but not more (see section \ref{sec:swot-analysis}). As spam is not just a nuisance for end users, but also for the infrastructure---the \mta{}s---by increasing the amount of mail messages, \MTA{}s need to protect themself.
   1.164 +
   1.165 +Filtering spam can be done in two ways: Refusing spam during the \SMTP\ dialog or checking for spam after the mail was accepted and queued. Both have advantages and disadvantages, so modern \MTA{}s use them in combination. Spam is identified by the results of a set of checks. Static rules, querying databases (\NAME{DNS} blacklists), requesting special client behavior (\name{greylisting}, \name{hashcash}), or statistical analysis (\name{bogofilter}) are checks that may be used. Running more checks leads to better results, but takes more system resources and time.
   1.166 +
   1.167 +Doing some basic checks during the \SMTP\ dialog seems to be a must.
   1.168 +
   1.169 +
   1.170 +
   1.171 +\subsubsection*{Virus checking}
   1.172 +
   1.173 +Related to spam is malicous content (short: \name{malware}) like viruses, worms, trojan horses. They, in contrast to spam, do not affect the \MTA\ itself, as they are in the mail body. \MTA{}s searching for malware is equal to real world's post offices opening letters to check if they contain something that could harm the recipient. This is not a mail transport job. But the last \MTA---the one responsible for the recipient---seems to be at a good position to do this work.
   1.174 +
   1.175 +In any way should malware checking be done by external programs that may be invoked by the \mta. But using mail deliver and processing agents, like \name{procmail}, a better suited locations to invoke content scanners.
   1.176 +
   1.177 +A popular email filter framework is \name{amavis} which integrates various spam and virus scanners. The common setup includes a receiving \MTA\ which sends it to \name{amavis} using \SMTP, \name{amavis} processes the mail and sends it then to a second \MTA\ that does the outgoing transfer. Having interfaces to such scanners is, for sure, good to have.
   1.178 +
   1.179 +
   1.180 +
   1.181 +\subsubsection*{Archiving}
   1.182 +
   1.183 +Mail archiving and auditability become more important as electronic mail becomes more important. The ability to archive verbatim copies of every mail coming into and every mail going out of the system, with relation between them, appears to be a goal to achieve.
   1.184 +
   1.185 +\postfix\ for example has a \texttt{always\_bcc} feature, to send a copy of every mail to a definable reciptient. At least this funtionality should be given, although a more complete approach is preferable.
   1.186 +
   1.187 +
   1.188 +
   1.189 +
   1.190 +
   1.191 +
   1.192 +
   1.193 +
   1.194 +\section{Work to do}
   1.195 +
   1.196 +What exists, what is missing, what needs to be done?
   1.197 +
   1.198 +auth, enc, archiving
   1.199 +
   1.200 +\masqmail\ is already able to encrypt outgoing connections, but encryption of incoming connections, using \NAME{STARTTLS} should be implemented. This only affects the \SMTP\ server module.
   1.201 +
   1.202 +
   1.203 +
   1.204 +
   1.205 +\subsubsection*{Discussion on architecture}
   1.206  
   1.207  A program's architecture is probably the most influencing design decision, and has the greatest impact on the program's future capabilities. %fixme: search quote ... check if good
   1.208  
   1.209 @@ -116,33 +259,34 @@
   1.210  
   1.211  
   1.212  
   1.213 +\subsubsection*{A design from scratch?}
   1.214  
   1.215 +<< what would be needed (effort) >>
   1.216  
   1.217 +The next section is a design
   1.218  
   1.219 -http://fanf.livejournal.com/50917.html %how not to design an mta - the sendmail command
   1.220 -http://fanf.livejournal.com/51349.html %how not to design an mta - partitioning for security
   1.221 -http://fanf.livejournal.com/61132.html %how not to design an mta - local delivery
   1.222 -http://fanf.livejournal.com/64941.html %how not to design an mta - spool file format
   1.223 -http://fanf.livejournal.com/65203.html %how not to design an mta - spool file logistics
   1.224 -http://fanf.livejournal.com/65911.html %how not to design an mta -   more about log-structured MTA queues
   1.225 -http://fanf.livejournal.com/67297.html %how not to design an mta -   more log-structured MTA queues
   1.226 -http://fanf.livejournal.com/70432.html %how not to design an mta - address verification
   1.227 -http://fanf.livejournal.com/72258.html %how not to design an mta - content scanning
   1.228  
   1.229  
   1.230  
   1.231  
   1.232  
   1.233  
   1.234 +\section{A design from scratch}
   1.235  
   1.236 -\subsection{Jobs of an MTA}
   1.237 +The last sections identified the jobs that need to be done by a modern \MTA; problems and prefered choices were mentioned too. Now the various jobs are assigned to modules, of which an architecture is created. It is inpired by existing ones and driven by the identified jobs and requirements.
   1.238  
   1.239 -This section tries to identify the needed modules for a modern \MTA. They are later the pieces of which the new architecture is built of.
   1.240  
   1.241 -The basic job of a \mta\ is to tranport mail from a sender to a recipient. This is the definition of such a program and this is how \person{Dent}\cite[page 19]{dent04} and \person{Hafiz} \cite[pages 3-5]{hafiz05} generally see its design.
   1.242  
   1.243 -An \MTA\ therefor needs at least a mail receiving facility and a mail sending facility. Additionally probably all \MTA\ developers (excluded the only forwarders), see the need for a mail queue. A mail queue removes the need to deliver at once a message is received. They also provide fail-safe storage of mails until they are delivered.
   1.244  
   1.245 +\subsection{Design decisions}
   1.246 +
   1.247 +One major design idea of the design were:
   1.248 +\begin{itemize}
   1.249 +	\item free the internal system from in and out channels
   1.250 +	\item arbitrary protocol handlers have to be addable afterwards
   1.251 +	\item a single facility for scanning (all mail goes through it)
   1.252 +	\item concentrate on mail transfer
   1.253 +\end{itemize}
   1.254  
   1.255  
   1.256  \subsubsection*{Incoming channels}
   1.257 @@ -194,17 +338,6 @@
   1.258  
   1.259  
   1.260  
   1.261 -\subsubsection*{Choose route to use}
   1.262 -
   1.263 -One key feature of \masqmail\ is its ability to send mail out in different ways. The decision is based on the current online state and whether a route may be used for a message or not. The online state can be retrieved in tree ways, explained in \ref{sec:fixme}. A route to send is found by checking every available route for being able to transfer the current message, until one matches.
   1.264 -
   1.265 -This functionality should be implemented in the module that is responsible to invoke one of the outgoing channel modules (for example the one for \SMTP\ or the pipe module).
   1.266 -
   1.267 -\masqmail\ can rewrite the envelope's from address and the \texttt{From:} header, dependent on the outgoing route to use. This rewrite must be done \emph{after} it is clear which route a mail will take, of course, so this may be not the module where other header editing is done.
   1.268 -%fixme: see hafiz05 page 57: maybe put the rewriting into the sending module (like smx, exim, courier) (problem with archiving of all outgoing mail?)
   1.269 -
   1.270 -
   1.271 -
   1.272  \subsubsection*{Aliasing}
   1.273  
   1.274  Where should aliases get expanded? They appear in different kind. Important are the ones available in the \path{aliases} file. Aliases can be:
   1.275 @@ -220,6 +353,17 @@
   1.276  
   1.277  
   1.278  
   1.279 +\subsubsection*{Choose route to use}
   1.280 +
   1.281 +One key feature of \masqmail\ is its ability to send mail out in different ways. The decision is based on the current online state and whether a route may be used for a message or not. The online state can be retrieved in tree ways, explained in \ref{sec:fixme}. A route to send is found by checking every available route for being able to transfer the current message, until one matches.
   1.282 +
   1.283 +This functionality should be implemented in the module that is responsible to invoke one of the outgoing channel modules (for example the one for \SMTP\ or the pipe module).
   1.284 +
   1.285 +\masqmail\ can rewrite the envelope's from address and the \texttt{From:} header, dependent on the outgoing route to use. This rewrite must be done \emph{after} it is clear which route a mail will take, of course, so this may be not the module where other header editing is done.
   1.286 +%fixme: see hafiz05 page 57: maybe put the rewriting into the sending module (like smx, exim, courier) (problem with archiving of all outgoing mail?)
   1.287 +
   1.288 +
   1.289 +
   1.290  \subsubsection*{Authentication}
   1.291  
   1.292  One thing to avoid is being an \name{open relay}. Open relays allow to relay mail from everywhere to everywhere. This is a major source of spam. The solution is restricting relay\footnote{Relaying is passing mail, that is not from and not for the own system, through it.} access.
   1.293 @@ -228,30 +372,10 @@
   1.294  
   1.295  If static access restriction is not possible, for example if mail from locations with changing \NAME{IP} addresses wants to be accepted, some kind of authentication mechanism is required. Three common kinds exist:
   1.296  \begin{enumerate}
   1.297 -\item \SMTP-after-\NAME{POP}: uses authenication on the \NAME{POP} protocol to permit incoming \SMTP\ connections for a limited time afterwards.
   1.298 -\item \SMTP authentication: is an extension to \SMTP. Authentication can be requested before mail is accepted.
   1.299 -\item Certificates: confirm the identity of someone.
   1.300 +	\item \SMTP-after-\NAME{POP}: uses authenication on the \NAME{POP} protocol to permit incoming \SMTP\ connections for a limited time afterwards.
   1.301 +	\item \SMTP authentication: is an extension to \SMTP. Authentication can be requested before mail is accepted.
   1.302 +	\item Certificates: confirm the identity of someone.
   1.303  \end{enumerate}
   1.304 -The first mechanism requires a \NAME{POP} (or \NAME{IMAP}) server running on the same host (or a trusted one), to enable the \SMTP\ server to use the login dates on the \NAME{POP} server. This is a common practice used by mail service providers, but is not adequate for the environments \masqmail\ is designed for.
   1.305 -
   1.306 -Certificate based authentication, like provided by \NAME{TLS}, suffers from the overhead of certificate management. But \NAME{TLS} provides encryption too, so is useful anyway.
   1.307 -
   1.308 -\SMTP\ authentication (also refered to as \NAME{SMTP-AUTH}) suppoert is easiest received by using a \name{Simple Authentication and Security Layer} implementation. \person{Dent} sees in \NAME{SASL} the best solution for authenticating dynamic users:
   1.309 -\begin{quote}
   1.310 -%None of these add-ons is an ideal solution. They require additional code compiled into your existing daemons that may then require special write accesss to system files. They also require additional work for busy system administrators. If you cannot use any of the nonauthenticating alternatives mentioned earlier, or your business requirements demand that all of your users' mail pass through your system no matter where they are on the Internet, SASL is probably the solution that offers the most reliable and scalable method to authenticate users.
   1.311 -None of these [authentication methods] is an ideal solution. They require additional code compiled into your existing daemons that may then require special write accesss to system files. They also require additional work for busy system administrators. If you cannot use any of the nonauthenticating alternatives mentioned earlier, or your business requirements demand that all of your users' mail pass through your system no matter where they are on the Internet, \NAME{SASL} is probably the solution that offers the most reliable and scalable method to authenticate users.
   1.312 -\cite[page 44]{dent04}
   1.313 -\end{quote}
   1.314 -
   1.315 -%either by
   1.316 -%- network/ip address
   1.317 -%	easiest: restricting by static IP addresses (Access control via hosts.allow/hosts.deny)
   1.318 -%or
   1.319 -%- some kind of auth (for dynamic remote hosts)
   1.320 -%	adds complexity
   1.321 -%	- SASL
   1.322 -%	- POP/IMAP: pop-before-smtp, DRAC, WHOSON
   1.323 -%	- TLS (certificates)
   1.324  
   1.325  
   1.326  
   1.327 @@ -265,42 +389,10 @@
   1.328  
   1.329  The \NAME{POP} protocol, for example, is good suited for such tunneling, but \SMTP\ is is not generally. Outgoing \SMTP\ client connections can be tunneled without problem---\masqmail\ already provides a configure option called \texttt{wrapper} to do so. Tunneling incomming connections to a server leads to problems with \SMTP. As data comes encrypted through the tunnel to the receiving host and gets then decrypted and forwarded on local to the port the application listens on. From the \MTA's view, this makes all connections appear to come from localhost, unfortunately. Figure \ref{fig:stunnel} depicts the data flow.
   1.330  
   1.331 -\begin{figure}
   1.332 -	\begin{center}
   1.333 -		\input{input/stunnel.tex}
   1.334 -	\end{center}
   1.335 -	\caption{Data flow using \name{stunnel}}
   1.336 -	\label{fig:stunnel}
   1.337 -\end{figure}
   1.338 -
   1.339  For incoming connections, \NAME{STARTTLS}---defined in \RFC2487---is what \mta{}s implement.
   1.340  
   1.341  \masqmail\ is already able to encrypt outgoing connections, but encryption of incoming connections, using \NAME{STARTTLS} should be implemented. This only affects the \SMTP\ server module.
   1.342  
   1.343 -%TLS/SSL prevents attackers to listen on the cable
   1.344 -%but it does not prevent man-in-the-middle attacks
   1.345 -%signed certificates help here
   1.346 -%   or PGP encryption
   1.347 -
   1.348 -
   1.349 -%do not use stunnel wit SMTP:
   1.350 -%because all incoming mail would be from 127.0.0.1 !!
   1.351 -%use STARTTLS instead
   1.352 -
   1.353 -%postfix: main.cf
   1.354 -%\begin{verbatim}
   1.355 -%	smtpd_use_tls = yes
   1.356 -%	smtpd_tls_received_header = no (does not log in received headers)
   1.357 -%
   1.358 -%	smtpd_tls_key_file = /etc/postfix/key.pem
   1.359 -%	smtpd_tls_cert_file = /etc/postfix/cert.pem
   1.360 -%	smtpd_tls_CA_file = /etc/postfix/CAcert.pem
   1.361 -%
   1.362 -%	smtp_use_tls = yes  (use TLS for sending)
   1.363 -%	smtp_tls_key_file = /etc/postfix/key.pem
   1.364 -%	smtp_tls_cert_file = /etc/postfix/cert.pem
   1.365 -%	smtp_tls_CA_file = /etc/postfix/CAcert.pem
   1.366 -%\end{verbatim}
   1.367  
   1.368  
   1.369  
   1.370 @@ -382,17 +474,9 @@
   1.371  
   1.372  
   1.373  
   1.374 -\section{Merging the parts}
   1.375  
   1.376 -The last sections identified the jobs that need to be done by a modern \MTA; problems and prefered choices were mentioned too. Now the various jobs are assigned to modules, of which an architecture is created. It is inpired by existing ones and driven by the identified jobs and requirements.
   1.377  
   1.378 -One major design idea of the design were:
   1.379 -\begin{itemize}
   1.380 -	\item free the internal system from in and out channels
   1.381 -	\item arbitrary protocol handlers have to be addable afterwards
   1.382 -	\item a single facility for scanning (all mail goes through it)
   1.383 -	\item concentrate on mail transfer
   1.384 -\end{itemize}
   1.385 +\subsection{The resulting architecture}
   1.386  
   1.387  The result is a symetric design, featuring the following parts: Any number of handlers for incoming connections to receive mail and pass it to the module that stores it into the incoming queue. A central scanning module take mail from the incoming queue, processes it in various ways and puts it afterwards into the outgoing queue. Another module takes it out there and passes it to a matching transport module that transfers it to the destination. In other words, three main modules (queue-in, scanning, queue-out) are connected by the two queues (incoming, outgoing); on each end are more modules to receive and send mail---for each protocol one. Figure \ref{fig:masqmail-arch-new} depicts the new designed architecture.
   1.388  
   1.389 @@ -410,7 +494,7 @@
   1.390  %fixme: do i need all this ``quesses''??
   1.391  
   1.392  
   1.393 -\subsection{Modules and queues}
   1.394 +\subsubsection*{Modules and queues}
   1.395  
   1.396  The new architecture consists of several modules and two queues. They are defined in more detail now, and the jobs, identified above, are assigned to them. First the three main modules, then the queues, and afterwards the modules for incoming and outgoing transfer.
   1.397  
   1.398 @@ -437,7 +521,7 @@
   1.399  
   1.400  
   1.401  
   1.402 -\subsection{Inter-module communication}
   1.403 +\subsubsection*{Inter-module communication}
   1.404  
   1.405  Communication between modules is required to exchange data and status information. It is also called ``Inter-process communication'' (short: \NAME{IPC}), as modules are programs being part of a larger system, and processes are generally seen as programs in execution.
   1.406  
   1.407 @@ -472,7 +556,7 @@
   1.408  
   1.409  
   1.410  
   1.411 -\subsection{Spool file format}
   1.412 +\subsubsection*{Spool file format}
   1.413  
   1.414  The spool file format is basically the same as the one in current \masqmail: one file for the message body, the other for envelope and header information. The data file is stored in a separate data pool. It is written by \name{queue-in}, \name{scanning} can read it if necessary, \name{queue-out} reads it to generate the outgoing message, and deletes it after successful transfer. The header file (including the envelope) is written into the \name{incoming} queue. The \name{scanning} modules reads it, processes it, and writes a modified copy into the \name{outgoing} queue; the file in \name{incoming} is deleted then. \name{queue-out} finally takes the header file from \name{outgoing} to generate the resulting message. This data flow is shown in figure \ref{fig:queue-data-flow}.
   1.415  
   1.416 @@ -493,13 +577,62 @@
   1.417  Data files do not change at all within the system. They are written in default local plain text format. Required translation is done in the receiver and transport modules.
   1.418  
   1.419  
   1.420 -%\begin{verbatim}
   1.421 -%s f /          envelope data
   1.422 -%p i |          NL
   1.423 -%o l |       /  header lines
   1.424 -%o e |  mail |  NL
   1.425 -%l   \       \  mail body
   1.426 -%\end{verbatim}
   1.427 +\begin{tabular}[hbt]{ l l }
   1.428 +
   1.429 +\mbox{ queue-in:} & \mbox{
   1.430 +\begin{tabular}[hbt]{| c | c | c |}
   1.431 +	\hline
   1.432 + incoming & outgoing & pool \\
   1.433 +	\hline
   1.434 +	\hline
   1.435 + - & - & - \\
   1.436 +	\hline
   1.437 + 0600 & - & - \\
   1.438 +	\hline
   1.439 + 0600 & - & 0600 \\
   1.440 +	\hline
   1.441 + 0700 & - & 0600 \\
   1.442 +	\hline
   1.443 +\end{tabular}
   1.444 +} \\
   1.445 +
   1.446 +\quad & \\
   1.447 +
   1.448 +\mbox{scanning:} & \mbox{
   1.449 +\begin{tabular}[hbt]{| c | c | c |}
   1.450 +	\hline
   1.451 + incoming & outgoing & pool \\
   1.452 +	\hline
   1.453 +	\hline
   1.454 + 0700 & - & 0600 \\
   1.455 +	\hline
   1.456 + 0700 & 0600 & 0600 \\
   1.457 +	\hline
   1.458 + 0700 & 0700 & 0600 \\
   1.459 +	\hline
   1.460 + - & 0700 & 0600 \\
   1.461 +	\hline
   1.462 +\end{tabular}
   1.463 +} \\
   1.464 +
   1.465 +\quad & \\
   1.466 +
   1.467 +\mbox{queue-out:} & \mbox{
   1.468 +\begin{tabular}[hbt]{| c | c | c |}
   1.469 +	\hline
   1.470 + incoming & outgoing & pool \\
   1.471 +	\hline
   1.472 +	\hline
   1.473 + - & 0700 & 0600 \\
   1.474 +	\hline
   1.475 + - & 0700 & - \\
   1.476 +	\hline
   1.477 + - & - & - \\
   1.478 +	\hline
   1.479 +\end{tabular}
   1.480 +} \\
   1.481 +
   1.482 +\end{tabular}
   1.483  
   1.484  A sample header file.
   1.485  \begin{verbatim}
   1.486 @@ -523,7 +656,7 @@
   1.487  
   1.488  
   1.489  
   1.490 -\subsection{Rights and permission}
   1.491 +\subsubsection*{Rights and permission}
   1.492  
   1.493  The user set required for \qmail\ seems to be too complex. One special user, like \postfix\ uses, is more appropriate. \name{root} privilege and \name{setuid} permission is avoided as much as possible.
   1.494  
   1.495 @@ -567,31 +700,47 @@
   1.496  
   1.497  
   1.498  
   1.499 +http://fanf.livejournal.com/50917.html %how not to design an mta - the sendmail command
   1.500 +http://fanf.livejournal.com/51349.html %how not to design an mta - partitioning for security
   1.501 +http://fanf.livejournal.com/61132.html %how not to design an mta - local delivery
   1.502 +http://fanf.livejournal.com/64941.html %how not to design an mta - spool file format
   1.503 +http://fanf.livejournal.com/65203.html %how not to design an mta - spool file logistics
   1.504 +http://fanf.livejournal.com/65911.html %how not to design an mta -   more about log-structured MTA queues
   1.505 +http://fanf.livejournal.com/67297.html %how not to design an mta -   more log-structured MTA queues
   1.506 +http://fanf.livejournal.com/70432.html %how not to design an mta - address verification
   1.507 +http://fanf.livejournal.com/72258.html %how not to design an mta - content scanning
   1.508 +
   1.509 +
   1.510 +
   1.511 +
   1.512 +
   1.513 +
   1.514 +
   1.515 +
   1.516  
   1.517  
   1.518  
   1.519  \section{Directions to go}
   1.520  
   1.521 +Now how could \masqmail\ be like in, say, five years?
   1.522 +
   1.523  This section discusses about what shapes \masqmail\ could have---which directions the development could go to.
   1.524  
   1.525  
   1.526 -\subsubsection*{\masqmail\ in five years}
   1.527  
   1.528 -Now how could \masqmail\ be like in, say, five years?
   1.529  
   1.530 ----
   1.531 +1) fix the current version
   1.532  
   1.533 -A design from scratch?
   1.534 -<< what would be needed (effort) >>
   1.535 +
   1.536 +2) create a new one
   1.537  But how is the effort of this complete rewrite compared to what is gained afterwards?
   1.538 -
   1.539  << would one create it at all? >>
   1.540  
   1.541 ----
   1.542  
   1.543 +pro---contra
   1.544  
   1.545  
   1.546 -\subsubsection*{Work to do}
   1.547 +
   1.548  
   1.549  << short term goals --- long term goals >>
   1.550