docs/diploma

annotate thesis/tex/4-MasqmailsFuture.tex @ 232:1afdb3f85e69

reworked features and parts of functional requirements
author meillo@marmaro.de
date Sat, 10 Jan 2009 00:29:21 +0100
parents 47af8eb539cf
children a6be202e1b49
rev   line source
meillo@109 1 \chapter{\masqmail's present and future}
meillo@93 2
meillo@185 3 This chapter \dots %fixme write text here
meillo@185 4
meillo@185 5
meillo@185 6
meillo@185 7
meillo@137 8 \section{Existing code base}
meillo@185 9
meillo@142 10 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.
meillo@142 11
meillo@93 12
meillo@185 13 \subsubsection*{The source code}
meillo@185 14
meillo@219 15 \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 has higher precedence in linking, though.
meillo@185 16
meillo@219 17 The only mandatory dependency is \name{glib}---a cross-platform software utility library, originated in the \NAME{GTK+} project. It provides safe replacements for many standard library functions, especially for the string functions. It also offers handy data containers, easy-to-use implementations of data structures, and much more.
meillo@185 18
meillo@225 19 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 programs use \masqmail\ source code; they only add a file with a \verb+main()+ function each.
meillo@185 20
meillo@232 21 \masqmail\ lacks 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 at compile time. Adding maildir support, 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 code that is hard to read.
meillo@185 22 %fixme: refer to ifdef-considered-harmful ?
meillo@185 23
meillo@185 24
meillo@185 25
meillo@137 26 \subsubsection*{Features}
meillo@219 27 \label{sec:masqmail-features}
meillo@93 28
meillo@232 29 \masqmail\ supports two channels for incoming mail: (1) Standard input, used when \path{masqmail} is executed on the command line and (2) a \NAME{TCP} socket, used by local or remote clients that talk \SMTP. The outgoing channels for mail are: (1) direct delivery to local mailboxes (in \name{mbox} or \name{maildir} format), (2) local pipes to pass mail to a program (e.g.\ gateways to \NAME{UUCP}, gateways to fax, or \NAME{MDA}s), and (3) \NAME{TCP} sockets to transfer mail to other \MTA{}s using the \SMTP\ protocol.
meillo@93 30
meillo@232 31 Outgoing \SMTP\ connections feature \SMTP-\NAME{AUTH} and \SMTP-after-\NAME{POP} authentication, but incoming connections do not. Using wrappers for outgoing connections is supported. This allows encrypted communication through a gateway application like \name{openssl}.
meillo@93 32
meillo@232 33 Mail queuing and alias expansion is both supported.
meillo@142 34
meillo@232 35 \masqmail\ focuses on non-permanent online connections, thus a concept of online routes is used. One may configure any number of routes to send mail. Each route can have criteria to determine if some message is allowed to be sent over it. This concept is explained in section \ref{sec:masqmail-routes} in detail. Mail to destinations outside the local network gets queued until an online connections is available.
meillo@232 36
meillo@232 37 The \masqmail\ executable can be called under various names for sendmail-compatibility reasons. This is organized by symbolic links with different names pointing to the \masqmail\ executable. The \sendmail\ names are \path{/usr/lib/sendmail} and \path{/usr/sbin/sendmail} because many programs expect the \mta\ to be located there. Further more \sendmail\ supports calling it with a different name instead of supplying command line arguments. The best known of this shortcuts is \path{mailq}, which is equivalent to calling it with the argument \verb+-bq+. \masqmail\ recognizes the shortcuts \path{mailq}, \path{smtpd}, \path{mailrm}, \path{runq}, \path{rmail}, and \path{in.smtpd}. The first two are inspired by \sendmail. Not implemented is the shortcut \path{newaliases} because \masqmail\ does not generate binary representations of the alias file.\footnote{A shell script named \path{newaliases}, that invokes \texttt{masqmail -bi}, can provide the command to satisfy other software needing it.} \path{hoststat} and \path{purgestat} are missing for complete sendmail-compatibility.
meillo@109 38 %masqmail: mailq, mailrm, runq, rmail, smtpd/in.smtpd
meillo@109 39 %sendmail: hoststat, mailq, newaliases, purgestat, smtpd
meillo@109 40
meillo@219 41 Additional to the \mta\ job, \masqmail\ also offers mail retrieval services by being a \NAME{POP3} client. It can fetch mail from different remote locations, dependent on the active online connection.
meillo@109 42
meillo@137 43
meillo@132 44
meillo@132 45
meillo@132 46
meillo@132 47
meillo@177 48 \section{Requirements}
meillo@219 49 \label{sec:mta-requirements}
meillo@146 50
meillo@185 51 This section identifies the requirements for a modern \masqmail. Most of them will apply to modern \MTA{}s in general.
meillo@185 52
meillo@218 53
meillo@185 54
meillo@177 55
meillo@219 56 \subsection{Functional requirements}
meillo@146 57
meillo@232 58 Functional requirements are about the function of the software. They define what the program can do and in what way.
meillo@232 59 %fixme: add ref
meillo@232 60 The requirements are named ``RF'' for ``requirement, functional''.
meillo@219 61
meillo@219 62
meillo@232 63 \subsubsection*{RF1: Incoming and outgoing channels}
meillo@219 64
meillo@232 65 \sendmail-compatible \mta{}s must support at least two incoming channels: mail submitted using the \sendmail\ command, and mail received on a \NAME{TCP} port. Thus it is common to split the incoming channels into local and remote. This is done by \qmail\ and \postfix. The same way is \person{Hafiz}'s view \cite{hafiz05}.
meillo@219 66
meillo@232 67 \SMTP\ is the primary mail transport protocol today, but with the increasing need for new protocols (see section \ref{sec:what-will-be-important}) in mind, support for more than just \SMTP\ is good to have. New protocols will show up, maybe multiple protocols need to be supported then. This leads to multiple remote channels, one for each supported protocol as it was done in other \MTA{}s. Best would be interfaces to add further protocols as modules.
meillo@219 68
meillo@219 69
meillo@232 70 Outgoing mail is commonly either sent using \SMTP, piped into local commands (for example \path{uucp}), or delivered locally by appending to a mailbox. 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.
meillo@219 71
meillo@232 72 %todo: is the def of MTA: transfer between machines, or transfer between users?
meillo@232 73 Local mail delivery is a job that uses root privilege to be able to switch to any user in order to write to his mailbox. It is possible to deliver without being root privilege, but delivery to user's home folders is not generally possible then. Thus even the modular \MTA{}s \qmail\ and \postfix\ use root privilege for it. As mail delivery to local users is \emph{not} included in the basic job of an \MTA{} and introduces a lot of new complexity, why should the \MTA\ bother? In order to keep the system simple, reduce privilege, and to have programs that do one job well, the local delivery job should be handed over to a specialist: the \NAME{MDA}. \NAME{MDA}s know about the various mailbox formats and are aware of the problems of concurrent write access and the like. Hence passing the message, and the responsibility for it, over to an \NAME{MDA} seems to be best.
meillo@219 74
meillo@232 75 This means an outgoing connection that pipes mail into local commands is required. To other outgoing channels applies what was already said about incoming channels.
meillo@219 76
meillo@232 77 \begin{figure}
meillo@232 78 \begin{center}
meillo@232 79 \includegraphics[scale=0.75]{img/mta-channels.eps}
meillo@232 80 \end{center}
meillo@232 81 \caption{Incoming and outgoing channels required}
meillo@232 82 \label{fig:mta-channels}
meillo@232 83 \end{figure}
meillo@219 84
meillo@232 85 An overview on in and outgoing channels required for an \MTA, gives figure \ref{fig:mta-channels}.
meillo@219 86
meillo@219 87
meillo@219 88
meillo@219 89
meillo@232 90 \subsubsection*{RF2: Mail queuing}
meillo@219 91
meillo@232 92 Mail queuing removes the need to deliver instantly as a message is received. The queue provides fail-safe storage of mails until they are delivered. Mail queues are probably used in all \mta{}s, excluding the simple forwarders. The mail queue is essential for \masqmail, as \masqmail\ is used for non-permanent online connections. This means, mail must be queued until a online connection is available to send the message. This may be after a reboot. Hence the mail queue must provide persistence.
meillo@219 93
meillo@219 94 The mail queue and the module(s) 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 an already sent mail to be sent again.
meillo@219 95
meillo@219 96
meillo@219 97
meillo@219 98
meillo@232 99 \subsubsection*{RF3: Header sanitizing}
meillo@219 100
meillo@219 101 Mail coming into the system often lacks important header lines. At least the required ones must be added by 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. Changing the locally known domain part of email addresses to globally known ones is an example. \masqmail\ needs to be able to rewrite the domain part dependent on the route used to send the message, to prevent messages to get classified as spam.
meillo@219 102
meillo@225 103 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 contain. Multiple recipients lead to multiple different envelopes, containing all the same mail message.
meillo@219 104
meillo@219 105
meillo@219 106
meillo@219 107
meillo@232 108 \subsubsection*{RF4: Aliasing}
meillo@219 109
meillo@225 110 Email addresses can have aliases, thus they need to be expanded. Aliases can be of different kind: another local user, a remote user, a list containing local and 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 recipient's domain part may require a different route to be used.
meillo@219 111
meillo@219 112
meillo@219 113
meillo@219 114
meillo@232 115 \subsubsection*{RF5: Selecting a route}
meillo@219 116
meillo@232 117 One key feature of \masqmail\ is its ability to send mail out over different routes. The online state defines the active route to be used. A specific route may not be suited for all messages, thus these messages are hold back until a suiting route is active. For more information on this concept see section \ref{sec:masqmail-routes}.
meillo@219 118
meillo@219 119
meillo@219 120
meillo@219 121
meillo@232 122 \subsubsection*{RF6: Authentication}
meillo@219 123
meillo@232 124 One thing to avoid is being an \name{open relay}. Open relays allow to relay mail from everywhere to everywhere. This is a 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. It may be also wanted to refuse all connections to the \MTA\ except ones from a specific set of hosts.
meillo@219 125
meillo@232 126 Several ways to restrict access are available. The most simple one is restriction by the \NAME{IP} address. No extra complexity is added this way, but the \NAME{IP} addresses have to be static or within known ranges. This approach is often used to allow relaying for local nets. The access check can be done by the \MTA\ or by a guard (e.g.\ \NAME{TCP} \name{Wrappers}) before. The main advantage here is the minimal setup and maintainence work needed. This kind of access restriction is important to be implemented.
meillo@219 127
meillo@232 128 This authentication based on \NAME{IP} addresses is impossible in situations where hosts with changing \NAME{IP} addresses, that are not part of a known subnet, need access. Then a authentication mechanism based on some \emph{secret} is required. Three common approaches exist:
meillo@219 129 \begin{itemize}
meillo@232 130 \item \SMTP-after-\NAME{POP}: Uses authentication on the \NAME{POP} protocol to permit incoming \SMTP\ connections for a limited time afterwards. The variant \SMTP-after-\NAME{IMAP} exists too.
meillo@232 131 \item \SMTP\ authentication: An extension to \SMTP. It allows to request authentication before mail is accepted. Here no helper protocols are needed.
meillo@232 132 \item Certificates: The identity of a user or a host is confirmed by certificates that are signed by trusted authorities. Certificates are closely related to encryption, they do normally satisfy both needs: \NAME{SSL} tunnels encrypt the data transmission and allow to identify the remote user/host by his certificate.
meillo@219 133 \end{itemize}
meillo@232 134 At least one of the secret-based mechanisms should be supported.
meillo@219 135
meillo@219 136
meillo@219 137
meillo@232 138 \subsubsection*{RF7: Encryption}
meillo@219 139
meillo@232 140 Electronic mail is vulnerable to sniffing attacks, because in generic \SMTP\ all data transfer is unencrypted. Unencrypted is the message's content, the email addresses in header and envelope, but also authentication dialogs that transfer plain text passwords (e.g.\ \NAME{PLAIN} and \NAME{LOGIN}). Hence encryption is important.
meillo@219 141
meillo@219 142 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}.
meillo@219 143
meillo@232 144 Using secure tunnels, that are provided by external applications, is prefered as the \MTA\ needs not to bother with encryption then. Outgoing \SMTP\ connections can get encrypted using a secure tunnel, created by an external application (like \name{openssl}). But incoming connections, can not use external secure tunnels, because the remote \NAME{IP} address is hidden then; all connections appear to come from localhost instead. Figure \ref{fig:stunnel} depicts the situation of using an application like \name{stunnel} for incoming connections. The connection to port 25 comes from localhost, and that is the information the \MTA\ gets. Authentication based on \NAME{IP} addresses and many spam prevention methods are useless then.
meillo@219 145
meillo@232 146 \begin{figure}
meillo@232 147 \begin{center}
meillo@232 148 \includegraphics[scale=0.75]{img/stunnel.eps}
meillo@232 149 \end{center}
meillo@232 150 \caption{Using \name{stunnel} for incoming connections}
meillo@232 151 \label{fig:stunnel}
meillo@232 152 \end{figure}
meillo@219 153
meillo@232 154 \NAME{STARTTLS}---defined in \RFC2487---is what \mta{}s usually implement.
meillo@219 155
meillo@232 156
meillo@232 157 smtps on 465 (obsolete)
meillo@232 158
meillo@232 159 starttls on port 25 (state-of-the-art)
meillo@232 160
meillo@232 161
meillo@232 162 \subsubsection*{RF8: Spam prevention}
meillo@219 163
meillo@219 164 Spam is a major threat nowadays, but it is a war that is hard to win. The goal is to provide state-of-the-art spam protection, but not more (see section \ref{sec:swot-analysis}).
meillo@219 165
meillo@225 166 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 them self.
meillo@219 167
meillo@219 168 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{bayesian filters}) are checks that may be used. Running more checks leads to better results, but takes more system resources and more time.
meillo@219 169
meillo@219 170 Doing some basic checks during the \SMTP\ dialog seems to be a must.
meillo@219 171
meillo@219 172
meillo@219 173
meillo@232 174 \subsubsection*{RF9: Virus checking}
meillo@219 175
meillo@225 176 Related to spam is malicious 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's 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 \MTA\ responsible for the recipient seems to be at a good position to do this work, so it is often done there.
meillo@219 177
meillo@219 178 In any way should malware checking be performed by external programs that may be invoked by the \mta. But using mail deliver agents, like \name{procmail}, are better suited locations to invoke content scanners.
meillo@219 179
meillo@219 180 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 nice to have, though.
meillo@219 181
meillo@219 182
meillo@219 183
meillo@232 184 \subsubsection*{RF10: Archiving}
meillo@219 185
meillo@219 186 Mail archiving and auditability become more important as email establishes as technology for serious business communication. 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.
meillo@219 187
meillo@225 188 \postfix\ for example has a \texttt{always\_bcc} feature, to send a copy of every outgoing mail to a definable recipient. At least this functionality should be given, although a more complete approach is preferable.
meillo@219 189
meillo@219 190
meillo@219 191
meillo@219 192
meillo@219 193
meillo@219 194 \subsection{Non-functional requirements}
meillo@219 195
meillo@225 196 Here follows a list of non-functional requirements for \masqmail. These requirements specify the quality properties of software. The list is based on \person{Hafiz} \cite[page~2]{hafiz05}, with inspiration from \person{Spinellis} \cite[page~6]{spinellis06} and \person{Kan} \cite{kan03}.
meillo@185 197 %fixme: refer to ch01 and ch02
meillo@232 198 These non-functional requirements are named ``RG'' for ``requirement, general''.
meillo@146 199
meillo@146 200
meillo@232 201 \subsubsection*{RG1: Security}
meillo@225 202 \MTA{}s are critical points for computer security, as they are accessible from external networks. They must be secured with high effort. Properties like the need for high privilege level, from outside influenced work load, work on unsafe data, and demand for reliability, increase the need for security. \masqmail\ needs to be secure enough for its target field of operation.
meillo@177 203
meillo@177 204
meillo@232 205 \subsubsection*{RG2: Reliability}
meillo@196 206 Reliability is the second essential quality property for an \MTA. Mail for which the \MTA\ took responsibility must never get lost. The \MTA\ must not be \emph{the cause} of any mail loss, no matter what happens. Unreliable \mta{}s are of no value.
meillo@177 207
meillo@189 208
meillo@232 209 \subsubsection*{RG3: Robustness}
meillo@219 210 Being robust means handling errors properly. Small errors may get corrected, large errors may kill a process. Killed processes should restarted automatically and lead to a clean state again. Log messages should be written in every case. Robust software does not need a special environment, it creates a friendly environment itself. \person{Raymond}'s \name{Rule of Robustness} and his \name{Rule of Repair} are good descriptions \cite[pages~18--21]{raymond03}.
meillo@177 211
meillo@177 212
meillo@232 213 \subsubsection*{RG4: Extendability}
meillo@219 214 \masqmail's architecture needs to be extendable, to allow new features to be added afterwards. The reason for this need are changing requirements. New requirements appear, like more efficient mail transfer of large messages or a final solution for spam problem. Extendability is the ability of software to include new function with little work.
meillo@196 215
meillo@146 216
meillo@232 217 \subsubsection*{RG5: Maintainability}
meillo@219 218 Maintaining software takes much time and effort. \person{Spinellis} guesses ``40\,\% to 70\,\% of the effort that goes into a software system is expended after the system is written first time.'' \cite[page~1]{spinellis03}. This work is called \emph{maintaining}. Hence making software good to maintain will ease work afterwards.
meillo@146 219
meillo@189 220
meillo@232 221 \subsubsection*{RG6: Testability}
meillo@225 222 Good testability make maintenance easier too, because functionality is directly verifiable when changes are done, thus removing uncertainty. Modularized software makes testing easier, because parts can be tested without external influences. \person{Spinellis} sees testability as a sub-quality of maintainability.
meillo@189 223
meillo@189 224
meillo@232 225 \subsubsection*{RG7: Performance}
meillo@196 226 Also called ``efficiency''. Efficient software requires few time and few resources. The merge of communication hardware and its move from service providers to homes and to mobile devices, demand smaller and more resource-friendly software. The amount of mail will be lower, even if much more mail will be sent. More important will be the energy consumption and heat emission. These topics increased in relevance during the past years and they are expected to become more central.
meillo@146 227
meillo@146 228
meillo@232 229 \subsubsection*{RG8: Availability}
meillo@225 230 Availability is important for server programs. They must stay operational by blocking \name{denial of service} attacks and the like.
meillo@146 231
meillo@146 232
meillo@232 233 \subsubsection*{RG9: Portability}
meillo@225 234 Source code that compiles and runs on various operation systems is called portable. Portability can be achieved by using standard features of the programming language and common libraries. Basic rules to achieve portable code are defined by \person{Kernighan} and \person{Pike} \cite{kernighan99}. Portable code lets software spread faster.
meillo@189 235
meillo@189 236
meillo@232 237 \subsubsection*{RG10: Usability}
meillo@219 238 Usability, not mentioned by \person{Hafiz} (he focuses on architecture) but by \person{Spinellis} and \person{Kan}, is a property very important from the user's point of view. Software with bad usability is rarely used, no matter how good it is. If substitutes with better usability exist, the user will switch to one of them. Here, usability includes setting up and configuring; and the term ``users'' includes administrators. Having \mta{}s on home servers and workstations requires easy and standardized configuration. The common setups should be configurable with little action by the user. Complex configuration should be possible, but focused must be the most common form of configuration: choosing one of several common setups.
meillo@185 239
meillo@185 240
meillo@185 241
meillo@185 242
meillo@185 243
meillo@185 244
meillo@185 245
meillo@185 246
meillo@185 247 \section{Work to do}
meillo@185 248
meillo@219 249 After \masqmail's features were presented in section \ref{sec:masqmail-features} and the requirements for modern \mta{}s were identified in section \ref{sec:mta-requirements}, here the differences between them are shown.
meillo@185 250
meillo@185 251
meillo@187 252
meillo@187 253 \subsubsection*{Fulfilled requirements}
meillo@187 254
meillo@219 255 \masqmail's incoming and outgoing channels are the ones common to most \MTA{}s: the \path{sendmail} command and \SMTP\ for incoming mail; local delivery, piping to commands, and \SMTP\ for outgoing mail. Support for other protocols is not available. To add it, modifications at many places in the source are needed.
meillo@187 256
meillo@219 257 One single mail queue is used in \masqmail. The envelope and mail headers are generated when the mail is put into the queue. Aliasing is done on delivery, after the route to be used was determined. Headers can get rewritten then. These parts do all provide the functionality required.
meillo@187 258
meillo@219 259 Static authentication, based on \NAME{IP} addresses, can be with \person{Venema}'s \NAME{TCP} \name{Wrapper}, by editing the \path{hosts.allow} and \path{hosts.deny} files. Dynamic \SMTP\ authentication is supported in form of \NAME{SMTP-AUTH} and \SMTP-after-\NAME{POP}, but only for outgoing channels. Similar for encryption which is also only available for outgoing channels; here a wrapper application like \name{openssl} is needed. Support for authentication and encryption of incoming connections is completely missing, although it is a basic requirement for secure emailing.
meillo@187 260
meillo@219 261 \masqmail\ does not provide special support for spam filtering and content checking. But it is possible to use external filter applications by running two independent instances of \masqmail, connected by the filter application. The receiving \MTA\ instance accepts mail and pushes it into the filter application. The filter application receives mail, processes it, possible modifies it, and pushes it to a second \MTA\ instance. The second \MTA\ is responsible for further delivery of the mail.
meillo@219 262 %Appendix \ref{app:FIXME} shows configuration files to create such a setup.
meillo@225 263 This is a concept that works in general. However, real spam \emph{prevention}---to not even accept spam---or good filter interfaces are not available. But they are necessary for using \masqmail\ in an unsafe environment.
meillo@187 264
meillo@187 265 There is currently no way of archiving every message going through \masqmail.
meillo@187 266
meillo@187 267
meillo@196 268 Non-functional requirements are not so easy to be marked as fulfilled or not. Instead they are discussed here.
meillo@196 269
meillo@219 270 \masqmail\ needs to be ``secure enough'', but what is ``secure enough''? This depends on its target field. Currently \masqmail\ is targeted to workstations and private networks, with explicit warning to not use it on permanent online hosts \citeweb{masqmail:homepage2}. \masqmail's current security is bad. For instance does a long time known attack against \sendmail, described by \person{Sill} \cite[page~4]{sill02}, still outwit \masqmail. Its security, however, seems acceptable for use on workstations and private networks, if the environment is trustable. In environments where untrusted components or persons have access to \masqmail, its security is too low.
meillo@196 271
meillo@196 272 Similar for its reliability. It has been reported that \masqmail\ has not sent mail under some circumstances \citeweb{FIXME}. %fixme
meillo@219 273 Situations where only one part of sent message was removed from the queue, and the other part remained as garbage, showed off, too---even to the author of this thesis. Fortunately, lost email was no big problem yet, but \person{Kurth} warns:
meillo@219 274 \begin{quote}
meillo@219 275 There may still be serious bugs in [masqmail], so mail might get lost. But in the nearly two years of its existence so far there was only one time a bug which caused mail retrieved via pop3 to be lost in rare circumstances.
meillo@219 276 \hfill\citeweb{masqmail:homepage2}
meillo@219 277 \end{quote}
meillo@219 278 In summary: Current reliability is not good enough.
meillo@196 279
meillo@219 280 The logging behavior of \masqmail\ is good, although it does not cover all problem situations. For example, if the queue directory is world writeable by accident (or as action of an intruder), any user can remove messages from the queue or replace them with own ones. \masqmail\ does not even write a debug message in this case. The origin of this problem, however, is \masqmail's trust in its environment.
meillo@196 281
meillo@219 282 \masqmail's extendability is very poor. This is a general problem of monolithic software, but can thus be provided with high effort. \exim\ is an example for good extendability in a monolithic program.
meillo@196 283
meillo@225 284 The maintainability of \masqmail\ appears to be equivalent to other software of similar kind. Missing modularity and therefore more complexity makes the maintainer's work harder. In summary is \masqmail's maintainability bearable, like in average Free Software projects. The testability suffers from missing modularity. Testing program parts is hard to do. Anyhow, it is done by compiling parts of the source to special test programs.
meillo@196 285
meillo@225 286 The performance---efficiency---of \masqmail\ is good enough for its target field of operation, where this is a minor goal. This applies equal to availability. Hence no further work needs to be done her.
meillo@196 287
meillo@225 288 The code's portability is good with view on \unix-like operation systems. At least \name{Debian}, \name{Red Hat}, \NAME{SUSE}, \name{Slackware}, \name{Free}\NAME{BSD}, \name{Open}\NAME{BSD}, and \name{Net}\NAME{BSD} are reported to be able to compile and run \masqmail\ \citeweb{masqmail:homepage2}. Special requirements for the underlying file system are not known. Therefore, the portability is already good.
meillo@196 289
meillo@225 290 The usability, from the administrator's point of view, is very good. \masqmail\ was developed to suite a specific, limited job---its configuration does perfect match. The user's view does not reach to the \MTA, as it is hidden behind the \name{mail user agent}.
meillo@196 291
meillo@187 292
meillo@187 293
meillo@187 294 \subsubsection*{Missing parts}
meillo@187 295
meillo@225 296 Support for other protocols than \SMTP\ seems not to be necessary at the moment. Adding such support will need lots of work in many parts of \masqmail. Hence delaying this work until the support becomes mandatory, appears to be the best strategy. This way work can be saved if some protocols never become popular.
meillo@187 297
meillo@225 298 Authentication of incoming \SMTP\ connections is definitely needed and should be added soon. The same applies to encryption of incoming connections. These two features are essential for restricting relaying and for providing privacy.
meillo@187 299
meillo@219 300 As authentication can be a guard against spam, filter facilities have lower priority. But basic spam filtering and interfaces for external tools should be implemented in future. Content checking should be left over to the \NAME{MDA}, to deal with it during local delivery.
meillo@187 301
meillo@225 302 Archiving again is preferred to be implemented soon. It does not require much work, but enables all kinds of statistical analysis.
meillo@187 303
meillo@200 304 Non-functional requirements need improvement too.
meillo@185 305
meillo@219 306 \masqmail's security is bad, thus the program is forced into a limited field of operation. The field of operation even shrinks, as security becomes more important and networking and interaction increases. Save and trusted environment become rare. Improving security is an important thing to do.
meillo@185 307
meillo@219 308 Reliability is also to improve. It is a key quality property for an \MTA, and not good enough in \masqmail. Additionally, the program is lacking robustness. Checking the environment and reporting bad characteristics is wanted. Especially improving robustness in relation to the queue is favorable; applying ideas of \name{crash-only software}\cite{candea03} will be a good step.
meillo@185 309
meillo@219 310 Extendability, maintainability, and testability do all suffer from the monolithic architecture and are nearly impossible to improve without changing the programs structure. These properties can hardly be retrofitted into software. Extendability might become important in the future. The other two ease all further work on the software, and also improve security and reliability.
meillo@185 311
meillo@225 312 Performance is a property that is nice to have. But as performance improvements are in contrast to many other quality properties (reliability, maintainability, usability, capability \cite[page~5]{kan03}), jeopardizing these to gain some more performance should not be done. \person{Kernighan} and \person{Pike} state clear: ``[T]he first principle of optimization is \emph{don't}.''\cite[page~165]{kernighan99}. \masqmail\ is not a program to be used on large servers, but on small devices. Thus important for \masqmail\ could be energy and heat saving, maybe also system resources, but not performance. Anyway, simplicity and clearness are of higher value.
meillo@196 313
meillo@225 314 Portability among the various flavors of \unix\ systems is a goal, because these systems are the ones \MTA{}s run on usually. Portability problems with non-\unix\ platforms are primary expected to come from file systems lacking required features. But no special care should be taken here.
meillo@196 315
meillo@219 316 Configuration could be eased more, by providing configuration generators to be able to use \masqmail\ right ``out of the box'' after running one of several configuration scripts for common setups. This would improve \masqmail's usability for not technical educated people.
meillo@196 317
meillo@196 318
meillo@196 319
meillo@200 320 \subsubsection*{The need for structural changes}
meillo@196 321
meillo@219 322 Adding authentication and encryption support, for example, is limited to a narrow region in the code. Such features are addable to the current code base without much problem. In contrast does adding support for new protocols or mail processing interfaces to external programs require a lot of effort. Changes in many parts of the source code are required. It is a bad idea to implement large retro-fitted features into software that is critical about security and reliability, like \MTA{}s. Worse if these features need changes in the program's structure, like adding mail scanning interfaces would do.
meillo@196 323
meillo@225 324 If such large features are needed, it is best to redesign the program's structure and rebuild it. A program's structure is primary its architecture. Which is the most influencing design decision, and has the greatest impact on the program's future capabilities. The architecture defines what the program can do, and how it can be used. If the architecture does not fit to the requirements, development will reach a dead end \dots\ further work then will make everything worse. The only good solution is to change the architecture, which, sadly but most likely, means a redesign from scratch.
meillo@196 325
meillo@225 326 Quality properties, like security and reliability, as well as extendability and maintainability, can hardly be added afterwards---if at all. Only structural changes will improve them. Hence, if security, reliability, extendability (to add support for future mail transfer protocols), or maintainability shall be improved, a redesign of \masqmail\ is the only sane way to go.
meillo@146 327
meillo@200 328 %\person{Hafiz} adds: ``The major idea is that security cannot be retrofitted into an architecture.''\cite[page 64]{hafiz05}
meillo@187 329
meillo@200 330
meillo@200 331
meillo@200 332
meillo@200 333 \section{Discussion on MTA architecture}
meillo@187 334
meillo@225 335 \masqmail's current architecture is monolithic like \sendmail's and \exim's. But more than the other two, is it one block of interweaved code. \exim\ has a highly structured code with many internal interfaces, a good example is the one for authentication ``modules''. %fixme: add ref
meillo@219 336 \sendmail\ provides now, with its \name{milter} interface, standardized connection channels to external modules.
meillo@188 337 \masqmail\ has none of them; it is what \sendmail\ was in the beginning: a single large block.
meillo@161 338
meillo@219 339 Figure \ref{fig:masqmail-arch} is a call graph generated from \masqmail's source code, excluding logging functions. It gives a impression of how interweaved the internals are.
meillo@219 340 %fixme: what is included, what not?
meillo@161 341
meillo@161 342 \begin{figure}
meillo@161 343 \begin{center}
meillo@219 344 \vspace*{2ex}
meillo@211 345 \includegraphics[scale=0.75]{img/callgraph.eps}
meillo@161 346 \end{center}
meillo@200 347 \caption{Call graph of \masqmail\ to show its internal structure}
meillo@161 348 \label{fig:masqmail-arch}
meillo@161 349 \end{figure}
meillo@161 350
meillo@225 351 \sendmail\ improved its old architecture by adding the milter interface, to include further functionality by invoking external programs. \exim\ was designed, and is carefully maintained, with a modular-like code structure in mind. \qmail\ started from scratch with a ``security-first'' approach, \postfix\ improved on it, and \name{sendmail X}/\name{MeTA1} tries to adopt the best of \qmail\ and \postfix\ to completely replace the old \sendmail\ architecture. \person{Hafiz} describes this evolution of \mta\ architecture very well \cite{hafiz05}.
meillo@161 352
meillo@225 353 Every one of these programs is more modular, or became more modular over time, than \masqmail\ is. Modern requirements like spam protection and future requirements like---probably---the use of new mail transport protocols demand for modular designs in order to keep the software simple. Simplicity is a key property for security. ``[T]he essence of security engineering is to build systems that are as simple as possible.''\cite[page 45]{graff03}
meillo@161 354
meillo@219 355 \person{Hafiz} agrees: ``The goal of making software secure can be better achieved by making the design simple and easier to understand and verify.'' \cite[page 64]{hafiz05}. He identifies the security of \qmail\ to come from it's \name{compartmentalization}, which goes hand in hand with modularity:
meillo@163 356 \begin{quote}
meillo@218 357 A perfect example is the contrast between the feature envy early \sendmail\ architecture implemented as one process and the simple, modular architecture of \qmail. The security of \qmail\ comes from its compartmentalized simple processes that perform one task only and are therefore testable for security.
meillo@218 358 \hfill\cite[page 64]{hafiz05}
meillo@163 359 \end{quote}
meillo@219 360 Equal does \person{Dent} see the situation for \postfix: ``The modular architecture of Postfix forms the basis for much of its security.'' \cite[page 7]{dent04}
meillo@200 361
meillo@200 362 Modularity is also needed to satisfy modern \MTA\ requirements, in providing a clear interface to add functionality without increasing the overall complexity much.
meillo@161 363
meillo@188 364 Security comes from good design, as \person{Graff} and \person{van Wyk} explain:
meillo@163 365 \begin{quote}
meillo@225 366 Good design is the sword and shield of the security-conscious developer. Sound design defends your application from subversion or misuse, protecting your network and the information on it from internal and external attacks alike. It also provides a safe foundation for future extensions and maintenance of the software.
meillo@163 367 %
meillo@163 368 %Bad design makes life easier for attackers and harder for the good guys, especially if it contributes to a false sends of security while obscuring pertinent failings.
meillo@218 369 \hfill\cite[page 55]{graff03}
meillo@163 370 \end{quote}
meillo@161 371
meillo@161 372
meillo@219 373 All this leads to the wish of a rewrite of \masqmail, using a modern, modular architecture, \emph{if} further features need to be added---features that require changes in \masqmail's structure. But a rewrite is also mandatory, if \masqmail\ should become a modern \MTA, with good quality properties.
meillo@161 374
meillo@225 375 But redesigning and rewriting a software from scratch is hard. It takes time to design a new architecture, which then must prove it is secure and reliable. As well is much time and work needed to implement the design, test it, fix bugs, and so on. If flaws in the design appear during prototype implementation, it is necessary to start again. Thus the gain of a new design must overweight the effort needed.
meillo@161 376
meillo@188 377 \person{Wheeler}'s program \name{sloccount} calculates following estimations for \masqmail's code base as of version 0.2.21 (excluding library code):
meillo@188 378 {\small
meillo@188 379 \begin{verbatim}
meillo@188 380 Total Physical Source Lines of Code (SLOC) = 9,041
meillo@188 381 Development Effort Estimate, Person-Years (Person-Months) = 2.02 (24.22)
meillo@188 382 (Basic COCOMO model, Person-Months = 2.4 * (KSLOC**1.05))
meillo@188 383 Schedule Estimate, Years (Months) = 0.70 (8.39)
meillo@188 384 (Basic COCOMO model, Months = 2.5 * (person-months**0.38))
meillo@188 385 Estimated Average Number of Developers (Effort/Schedule) = 2.89
meillo@188 386 Total Estimated Cost to Develop = $ 272,690
meillo@188 387 (average salary = $56,286/year, overhead = 2.40).
meillo@188 388 SLOCCount, Copyright (C) 2001-2004 David A. Wheeler
meillo@188 389 \end{verbatim}
meillo@188 390 }
meillo@219 391 The development cost is not relevant for a \freesw\ project with volunteer developers, but the development time is. About 24 man-months are estimated. The current code base was written almost completely by Oliver \person{Kurth} within four years, in his spare time. This means he needed around twice as much time. Of course, he programmed as volunteer developer, not as employee with eight work-hours per day.
meillo@161 392
meillo@225 393 Given the assumptions that (1) an equal amount of code needs to be produced for a new \masqmail, (2) a third of existing code can be reused plus concepts and knowledge, and (3) development speed is like \person{Kurth}'s. Then it would take between two and three years to have a redesigned new \masqmail\ with the same features that \masqmail\ now has. Less time would be needed if a simpler architecture allows faster development, better testing, and less bugs.
meillo@200 394
meillo@177 395
meillo@177 396
meillo@177 397
meillo@177 398
meillo@196 399
meillo@196 400
meillo@196 401
meillo@196 402
meillo@196 403
meillo@196 404 \section{Result}
meillo@196 405
meillo@219 406 The most needed features---authentication and encryption---can be added to the current code base with changes in only few parts of the source. These changes should be made soon. Archiving of mail is another feature to add then. More complete logging coverage, reporting of unsafe environment, and fixing high risk security flaws are quality improvements to do. All this work should be done on basis of the current code.
meillo@196 407
meillo@219 408 All other work depends on how the plans for \masqmail's future look like.
meillo@196 409
meillo@219 410 What shall \masqmail\ be like, in, for instance, five years?
meillo@196 411
meillo@219 412 Two ways of further development come to mind.
meillo@196 413
meillo@225 414 First, stick to the old architecture and try to add features as possible. This approach needs less effort to be spent, because a working code is already present. Further development is only adding small increments to a exiting code base. But the further development goes, the larger is the work needed to add more functionality, and the more bugs will appear, caused by the increasing complexity. Quality of the software will decrease, because lacking of clear internal structure encourages further work to be quick fixes rather than good solutions.
meillo@196 415
meillo@225 416 Second, the way of designing \masqmail\ from scratch and rebuilding it. A lot of time and work is required to do this. Additionally, a new design from scratch introduces new risks: Is the design really better? Was thought of everything? Will there come problems not foreseeable now? Starting from scratch also means a step back. Against these disadvantages stands the gain from the new design: Further development will be easier and probably faster, overall quality will be better and easier to keep up, and dead ends for further development are better avoidable.
meillo@196 417
meillo@219 418 Essentially, the decision for one of the ways depends on the question whether \masqmail\ should remain what it is, then the first option seems to be the right one to choose. Or whether \masqmail\ should become a modern \mta\ which is able to expand to include new functionality, then the second option is to choose.
meillo@196 419
meillo@219 420 Security, extendability, and the other quality properties appear to have also crucial importance in this decision. If they are required for future versions of \masqmail, then a new design is a must.
meillo@196 421
meillo@225 422 \person{Graff} and \person{van Wyk} describe the situation well: ``[I]n today's world, your software is likely to have to operate in a very hostile security environment.'' \cite{graff03}. An old-fashioned \mta\ depends, for sure, on a dieing branch, called \name{trusted environments}. And nothing other than a fresh and better design will help to survive.
meillo@196 423
meillo@219 424 The suggested further development plan for \masqmail\ is:
meillo@219 425 \begin{enumerate}
meillo@225 426 \item The short time goal: Add the most needed features, being authentication and encryption, to the current code base. \item The long time goal: Design a new architecture that satisfies the requirements identified, especially the quality requirements. The implementation of this design shall then, after being usable and throughout tested, supersede the old \masqmail.
meillo@219 427 \end{enumerate}
meillo@196 428
meillo@219 429 This plan is similar to the change from \sendmail\ to \name{sendmail X}/\name{MeTA1}, except the \sendmail\ change was much too late.
meillo@196 430
meillo@219 431 The following chapter is about the work on the current code base, to reach the short time goals. The chapter afterwards then introduces a new, modern design for future versions of \masqmail.
meillo@196 432
meillo@219 433
meillo@219 434 %The plan is to first do the most needed stuff on the old design to make it still usable; then design a new version from scratch, for the future.