Installing maildrop

The typical sequence of commands to install maildrop is as follows:
 
   ./configure [options]
   make config.h
   make xconfig.h
   make
   make install-strip
The configure script creates Makefile, and autoconf.h. After running configure, you may want to edit autoconf.h, and config.h in order to make minor adjustments to the configuration.

The first two make commands are required to resolve some dependency idiosynchronies in the automake-generated Makefile.  The third make compiles maildrop, and the last make installs stripped executables.

When you run configure, you may get some warning messages asking you to install automake, autoconf, or even perl packages. These warning messages can be safely ignored.

Some versions of make may have problems handling the Makefile. If your make gives you errors, try using the gmake command instead - the GNU make.

NOTE: configure attempts to automatically configure the following options for maildrop according to your specific UNIX system. After running configure, you should review these options and make any necessary adjustments.

Operating system specific notes

This section will list any platform-depended issues.

Solaris

This problem has been reported for Solaris 2.6. Other Solaris versions or related platforms can be affected. Symptom - trying to run maildrop results in an error message saying that libstdc++ cannot be opened.

Solaris's run time linker has a problem running C++ applications which have the setuid or setgid bit set. On Solaris, libstdc++ (the runtime C++ library) is installed in /usr/local/lib. Solaris's runtime linker will only open shared libraries in /usr/lib for programs with the setuid or setgid bit set.

Maildrop is installed with the setuid and setgid bits set, so that maildrop can change to the recipient's userid and group id. There are three easy workarounds.

  1. If you can configure your mail transport agent to set the correct user and group IDs before running maildrop, maildrop will not need the setuid and setgid privileges. After running make install-strip, go ahead and manually turn these bits off for the maildrop, dotlock, and reformail.

  2. Create a soft link from /usr/lib/local to /usr/local/lib, and add /usr/lib/local to the LD_LIBRARY_PATH environment variable.

  3. Create a soft link to libstdc++ from /usr/lib to /usr/local/lib

Any sendmail platform

There are two quirks that anyone installing maildrop on a sendmail-based system should be aware of.

Note that this applies ONLY if you have maildrop defined as the local delivery agent in sendmail.cf. This will happen if maildrop is invoked from a .forward file. There are three possible solutions: do nothing, since no real harm is done, local mail simply gets delivered with some delay; you can change the default queueing method (in sendmail.cf) to queue messages; or, you can specify --enable-restrict-trusted=0 option to configure, and lift the restriction on the -d option. However, keep in mind that the --enable-restrict-trusted=0 option allows a malicious user use the -d option to mailbomb another local user's mailbox. This is why the option is enabled by default. Of course, the same can also be accomplished by funneling the mailbomb through sendmail, instead of running maildrop directly. However, I can only tighten things up on my end; I presume that throttling mechanisms are in place in sendmail to block that avenue of attack.

Options to configure

Although most configuration is done as described in the following section, I am migrating them to the configure script. Currently, configure support the following options:
  Early UNIX systems invoked the mail delivery agent and specified the account to which the message is addressed. The mail delivery agent is a program that's owned by root, and the set-user-id bit set. The mail delivery agent would then immediately reset its userid to whomever the message is addressed to.

Some mail systems run the delivery agent without specifying the recipient on the command line. The user id is set by the mail system before running the mail delivery agent. In this case, root privileges are not required, and you may manually remove the setuid bit after installing maildrop.

Some mail systems may use group privileges in order to write to the system mailbox directory. maildrop is installed with the set-group-id bit set as well, and the mail group is assumed to be 'mail'.  If a mail group other than 'mail' is used, specify it via the --enable-maildrop-gid option. You will also need to set the RESET_GID variable to 0 (see below). If RESET_GID is left alone to its default value of 1, maildrop will drop any acquired group ID right away, so its not necessary to remove the setgid bit. maildrop attempts to detect if this is the case, but you always need to confirm this.
 

See the manual page for maildropfilter for more information on these variables.

Selecting an alternate C++ compiler

maildrop is written in C++. Some systems may have more than one C++ compiler available. If the default C++ compiler that's selected by the configure script doesn't work, you may try an alternate C++ compiler. First, you must extract the tarball again, into a different directory. Then, before running ./configure, set the CXX environment variable to the C++ compiler to be used. For example, to select the CC compiler:
 
$ CXX=CC
$ export CXX
$ ./configure [options]
Then proceed as usual. The CXXFLAGS environment variable can also be used to override compiler flags that configure selects.

Configuring the location of the system mailbox

When maildrop has a message to deliver to a user, maildrop must know where users mailboxes are Different UNIX systems use different places to store E-mail, and different mechanisms to access it. And even on the same UNIX system you may have variations due to different mail software being used.

Here are just some of the possible scenarios that may exist that maildrop knows how to handle:
 

As you can see, there is a lot of variation in possible mail setups. It is important that maildrop is configured to match your existing mail setup.  The configure script tries to automatically figure out the correct settings, but you MUST always verify the output file, autoconf.h, to make sure that the settings are correct. Description of each variable defined in autoconf.h follows. In addition, there are certain variables defined in a different file, config.h. These are settings that autoconf.h cannot automatically determine.

DEFAULT_DEF

This variable specifies the initial setting for the DEFAULT variable in maildrop, which should be the location of the system default mailbox. If DEFAULT_DEF begins with a slash, it should refer to a directory, and maildrop will automatically append the user's name.

If it doesn't begin with a slash, maildrop will prepend the user's home directory to DEFAULT_DEF. To use maildrop with qmail, which normally delivers to $HOME/Mailbox, set DEFAULT_DEF to ./Mailbox.

The '=' character in DEFAULT_DEF gets replaced by progressive characters from the user name of the user whose mail is being delivered. For example, if mail to the user name "john" is delivered to /var/spool/mail/j/jo/john and mail to user "root" is delivered to /var/spool/mail/r/ro/root, DEFAULT_DEF should be set to /var/spool/mail/=/== (maildrop automatically appends the full user name as the last component).

If the DEFAULT_DEF/DEFAULT variable refers to a directory, maildrop assumes that it is delivering the message to a maildir, otherwise maildrop will deliver mail to a mailbox file, creating a new file if necessary. maildrop does not deliver mail to flat directory, like procmail. If you need to save messages in a directory, use the included program, maildirmake, to create a maildir directory.

MAILBOX_MODE and RESET_GID

Here are the required setting in two of the most common mailbox environments:
  MAILBOX_MODE are the permissions maildrop uses to create new mailbox files. If a mailbox file already exists, maildrop is not going to change its permissions.

RESET_GID indicates whether maildrop should immediately drop any set-group-id privileges. maildrop is installed with the set-group-id bit set with maildrop's group id set to the mail group. If system mailbox files have read/write access by both the user and the mail group, set RESET_GID to 0 to keep the mail group ID, and specify the mail group using the --enable-maildrop-gid flag to configure (see above).

TRUSTED_USERS

If --enable-restrict-trusted option given to the configure script is set to 1 (this is the default), maildrop allows only the users listed in this environment variable to use the -d option. See the online documentation for the description of the -d option.

Mail can be delivered in two different ways:
 

If --enable-restrict-trusted option given to the configure script is set to 0, anyone can use the -d option. That is not recommended, it leaves open a possibility for certain denial-of-service attacks.

Other configuration variables

The configure script also sets the following variables in autoconf.h. After running the configure script, you may need to make some adjustments to these variables also.

DEFAULT_PATH

This variable in "autoconf.h" sets the initial contents of the PATH variable, which is the initial system search path for commands invoked by maildrop as child processes.

SENDMAIL_DEF

This variable in "autoconf.h" sets the initial contents of the SENDMAIL variable, which is the local mail transport agent. maildrop runs this program when instructed to deliver mail to a mailbox whose name begins with the forwarding "!" character.

Other variables in autoconf.h

All the other variables are self explanatory, and rarely need to be changed.

Using maildrop with sendmail

Maildrop can be easily used as sendmail's local delivery agent, instead of procmail. Here is the suggested entry for sendmail.cf, courtesy of Eric J. Schwertfeger <ejs@bfd.com>:
 
Mlocal,         P=/usr/local/bin/maildrop, F=lsAw5:/|@SPfhn, S=10/30, R=20/40,
                T=DNS/RFC822/X-Unix,
                A=maildrop -d $u
You may also consider including the D, F, and M flags as well.

The -f option to maildrop

The -f option is new to version 0.55. The -f option sets the initial value of the FROM variable. If no -f option is given, maildrop looks at any From_ line in the message being delivered, otherwise it defaults to the name of the user who invoked maildrop.

If the --enable-keep-fromline option is set to 0, anyone may use the -f option. If --enable-keep-fromline is set to 1, only "trusted" users (as defined by --enable-trusted-users) may use the -f option (ignored for everyone else).

The initial value of the FROM variable is also used in the From_ line for the message when maildrop saves it in a mailbox file. Although a recipe may change the contents of the FROM variable, only the initial value gets saved in the From_ line.